This option can be used to repect original input I/IDR frame type. Signed-off-by: Zhong Li <zhong...@intel.com> --- libavcodec/qsvenc.c | 7 +++++++ libavcodec/qsvenc.h | 2 ++ 2 files changed, 9 insertions(+)
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 948751d..e534dcf 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1192,6 +1192,13 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, if (qsv_frame) { surf = &qsv_frame->surface; enc_ctrl = &qsv_frame->enc_ctrl; + + if (q->forced_idr >= 0 && frame->pict_type == AV_PICTURE_TYPE_I) { + enc_ctrl->FrameType = MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF; + if (q->forced_idr || frame->key_frame) + enc_ctrl->FrameType |= MFX_FRAMETYPE_IDR; + } else + enc_ctrl->FrameType = MFX_FRAMETYPE_UNKNOWN; } ret = av_new_packet(&new_pkt, q->packet_size); diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 055b4a6..1f97f77 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -87,6 +87,7 @@ { "adaptive_i", "Adaptive I-frame placement", OFFSET(qsv.adaptive_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \ { "adaptive_b", "Adaptive B-frame placement", OFFSET(qsv.adaptive_b), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \ { "b_strategy", "Strategy to choose between I/P/B-frames", OFFSET(qsv.b_strategy), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \ +{ "forced_idr", "Forcing I frames as IDR frames", OFFSET(qsv.forced_idr), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \ typedef int SetEncodeCtrlCB (AVCodecContext *avctx, const AVFrame *frame, mfxEncodeCtrl* enc_ctrl); @@ -168,6 +169,7 @@ typedef struct QSVEncContext { #endif char *load_plugins; SetEncodeCtrlCB *set_encode_ctrl_cb; + int forced_idr; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); -- 2.7.4 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel