diff options
author | Tim Walker <[email protected]> | 2016-09-17 15:14:08 +0200 |
---|---|---|
committer | Tim Walker <[email protected]> | 2016-09-17 15:46:34 +0200 |
commit | 38a566b396e2cdd72ab9647fe830034ce70329e6 (patch) | |
tree | c9ffc0a61401fd6b01ac8d4d5dc618b070915c71 /libhb | |
parent | 843e327e0d62e730c0d36d5cbe1e43d9dd329308 (diff) |
enc_qsv: flag all HEVC random access points as keyframes.
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/enc_qsv.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/libhb/enc_qsv.c b/libhb/enc_qsv.c index 4030cd30c..6871e0c76 100644 --- a/libhb/enc_qsv.c +++ b/libhb/enc_qsv.c @@ -1595,12 +1595,6 @@ static void compute_init_delay(hb_work_private_t *pv, mfxBitstream *bs) pv->init_delay = NULL; } -static int qsv_frame_is_key(mfxU16 FrameType) -{ - return ((FrameType & MFX_FRAMETYPE_IDR) || - (FrameType == MFX_FRAMETYPE_UNKNOWN)); -} - static void qsv_bitstream_slurp(hb_work_private_t *pv, mfxBitstream *bs) { hb_buffer_t *buf; @@ -1633,6 +1627,22 @@ static void qsv_bitstream_slurp(hb_work_private_t *pv, mfxBitstream *bs) bs->MaxLength = pv->job->qsv.ctx->enc_space->p_buf_max_size; buf->s.frametype = hb_qsv_frametype_xlat(bs->FrameType, &buf->s.flags); + if (pv->param.videoParam->mfx.CodecId == MFX_CODEC_HEVC) + { + size_t len = buf->size; + uint8_t *pos = buf->data; + uint8_t *end = pos + len; + while ((pos = hb_annexb_find_next_nalu(pos, &len)) != NULL) + { + if (HB_HEVC_NALU_KEYFRAME((pos[0] >> 1) & 0x3f)) + { + buf->s.flags |= HB_FLAG_FRAMETYPE_KEY; + break; + } + len = end - pos; + continue; + } + } buf->s.start = buf->s.renderOffset = bs->TimeStamp; buf->s.stop = buf->s.start + get_frame_duration(pv, buf); buf->s.duration = buf->s.stop - buf->s.start; @@ -1686,7 +1696,7 @@ static void qsv_bitstream_slurp(hb_work_private_t *pv, mfxBitstream *bs) * If we have a chapter marker pending and this frame's PTS * is at or after the marker's PTS, use it as the chapter start. */ - if (qsv_frame_is_key(bs->FrameType)) + if (buf->s.flags & HB_FLAG_FRAMETYPE_KEY) { hb_chapter_dequeue(pv->chapter_queue, buf); } |