Skip to content

Commit ea7c45f

Browse files
ChaoX A Liulizhong1008
authored andcommitted
add the left mfxExtCodingOption2 param for AVC encode
(cherry picked from commit 128f0f3b82fdabb308394673c5e629ccaa792d13) Signed-off-by: ChaoX A Liu <chaox.a.liu@intel.com> Change-Id: I6560489a70d1d5c567e031786a5ed861b909b5bd
1 parent d07f636 commit ea7c45f

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

libavcodec/qsvenc.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
618618
if (q->extbrc >= 0)
619619
q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
620620

621+
622+
q->extco2.RepeatPPS = q->repeatPPS_off ? MFX_CODINGOPTION_OFF : MFX_CODINGOPTION_ON;
623+
q->extco2.NumMbPerSlice = q->numMb_per_slice;
624+
q->extco2.FixedFrameRate = q->fixed_framerate ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
625+
q->extco2.DisableVUI = q->disable_VUI ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
626+
q->extco2.BufferingPeriodSEI = q->buffing_periodSEI;
627+
q->extco2.EnableMAD = q->enableMAD ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
628+
q->extco2.UseRawRef = q->use_raw_ref ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF;
629+
630+
if (MFX_RATECONTROL_LA != q->param.mfx.RateControlMethod) {
631+
q->extco2.MaxQPI = q->maxQPI;
632+
q->extco2.MinQPI = q->minQPI;
633+
q->extco2.MaxQPP = q->maxQPP;
634+
q->extco2.MinQPP = q->minQPP;
635+
q->extco2.MaxQPB = q->maxQPB;
636+
q->extco2.MinQPB = q->maxQPB;
637+
}
638+
621639
if (q->max_frame_size >= 0)
622640
q->extco2.MaxFrameSize = q->max_frame_size;
623641
#if QSV_HAVE_MAX_SLICE_SIZE

libavcodec/qsvenc.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ typedef struct QSVEncContext {
141141
int max_frame_size;
142142
int max_slice_size;
143143

144+
int maxQPI;
145+
int minQPI;
146+
int maxQPP;
147+
int minQPP;
148+
int maxQPB;
149+
int minQPB;
150+
144151
int single_sei_nal_unit;
145152
int max_dec_frame_buffering;
146153
int trellis;
@@ -158,6 +165,15 @@ typedef struct QSVEncContext {
158165
int int_ref_qp_delta;
159166
int recovery_point_sei;
160167

168+
// options for mfxExtCodingOption2
169+
unsigned short repeatPPS_off;
170+
unsigned short numMb_per_slice;
171+
unsigned short fixed_framerate;
172+
unsigned short disable_VUI;
173+
unsigned short buffing_periodSEI;
174+
unsigned short enableMAD;
175+
unsigned short use_raw_ref;
176+
161177
// options for mfxExtCodingOption3
162178
unsigned short num_slice_I;
163179
unsigned short winbrc_maxavg_kbps;

libavcodec/qsvenc_h264.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,23 @@ static const AVOption options[] = {
141141
{ "main" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
142142
{ "high" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_HIGH }, INT_MIN, INT_MAX, VE, "profile" },
143143

144+
{ "maxQPI", "maxumum allowed QP value for I frame, valid range: 1-51; 0 is default value, no limitation on QP;cannot work with LA.", OFFSET(qsv.maxQPI), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 51, VE },
145+
{ "minQPI", "minimum allowed QP value for I frame, valid range: 1-51; 0 is default value, no limitation on QP;cannot work with LA.", OFFSET(qsv.minQPI), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 51, VE },
146+
{ "maxQPP", "maxumum allowed QP value for P frame, valid range: 1-51; 0 is default value, no limitation on QP;cannot work with LA.", OFFSET(qsv.maxQPP), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 51, VE },
147+
{ "minQPP", "minimum allowed QP value for P frame, valid range: 1-51; 0 is default value, no limitation on QP;cannot work with LA.", OFFSET(qsv.minQPP), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 51, VE },
148+
{ "maxQPB", "maxumum allowed QP value for B frame, valid range: 1-51; 0 is default value, no limitation on QP;cannot work with LA.", OFFSET(qsv.maxQPB), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 51, VE },
149+
{ "minQPB", "minimum allowed QP value for B frame, valid range: 1-51; 0 is default value, no limitation on QP;cannot work with LA.", OFFSET(qsv.minQPB), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 51, VE },
150+
144151
{ "a53cc" , "Use A53 Closed Captions (if available)", OFFSET(qsv.a53_cc), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, VE},
145152

153+
{ "repeatPPS", "The default is on and set flag will off the repetition", OFFSET(qsv.repeatPPS_off), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
154+
{ "numMbperslice", "This option specifies suggested slice size in number of macroblocks", OFFSET(qsv.numMb_per_slice), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
155+
{ "fixedframerate", "This option sets fixed_frame_rate_flag in VUI", OFFSET(qsv.fixed_framerate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
156+
{ "disableVUI", "This option sets fixed_frame_rate_flag in VUI", OFFSET(qsv.disable_VUI), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
157+
{ "bufferPeriodSEI","This option controls insertion of buffering period SEI in the encoded bitstrea", OFFSET(qsv.buffing_periodSEI), AV_OPT_TYPE_INT, { .i64 = MFX_BPSEI_DEFAULT }, MFX_BPSEI_DEFAULT, MFX_BPSEI_IFRAME, VE },
158+
{ "enableMAD", "Turn ON this flag to enable per-frame reporting of MAD", OFFSET(qsv.enableMAD), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
159+
{ "userawref", "Set flag to use raw frames for reference instead reconstructed frames", OFFSET(qsv.use_raw_ref), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
160+
146161
{ "numSlicei", "The number of slices for I", OFFSET(qsv.num_slice_I), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
147162
{ "winmaxavg", "Specifies the maximum bitrate averaged over a sliding window for MFX_RATECONTROL_LA/MFX_RATECONTROL_LA_HRD", OFFSET(qsv.winbrc_maxavg_kbps), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
148163
{ "winsize", "Specifies sliding used for MFX_RATECONTROL_LA/MFX_RATECONTROL_LA_HRD window size in frames", OFFSET(qsv.win_brc_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },

0 commit comments

Comments
 (0)