Message ID | 1583923168-9324-1-git-send-email-linjie.fu@intel.com |
---|---|
State | Accepted |
Commit | c2d000ec27af1a5cd5341a67e941e0313879ab18 |
Headers | show |
Series | [FFmpeg-devel] lavc/qsvenc_hevc: add qmax/qmin support for HEVC encoding | expand |
Context | Check | Description |
---|---|---|
andriy/ffmpeg-patchwork | success | Make fate finished |
On Wed, Mar 11, 2020 at 11:44 AM Linjie Fu <linjie.fu@intel.com> wrote: > Add qmax/qmin support for HEVC software bitrate control(SWBRC). > > Limitations: > - RateControlMethod != MFX_RATECONTROL_CQP > - with EXTBRC ON > > Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com> > Signed-off-by: Linjie Fu <linjie.fu@intel.com> > --- > > Relative code in MSDK for the limitation: > > https://github.com/Intel-Media-SDK/MediaSDK/blob/master/_studio/mfx_lib/encode_hw/hevc/agnostic/g9/hevcehw_g9_legacy.cpp#L4267 > > libavcodec/qsvenc.c | 11 +++++------ > libavcodec/qsvenc_hevc.c | 2 ++ > 2 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c > index 52b4e43..2c22eb7 100644 > --- a/libavcodec/qsvenc.c > +++ b/libavcodec/qsvenc.c > @@ -732,6 +732,11 @@ FF_ENABLE_DEPRECATION_WARNINGS > if (q->adaptive_b >= 0) > q->extco2.AdaptiveB = q->adaptive_b ? MFX_CODINGOPTION_ON > : MFX_CODINGOPTION_OFF; > #endif > + } > + > + if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == > AV_CODEC_ID_HEVC) { > + if (q->extbrc >= 0) > + q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : > MFX_CODINGOPTION_OFF; > > #if QSV_VERSION_ATLEAST(1, 9) > if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > > avctx->qmax) { > @@ -747,12 +752,6 @@ FF_ENABLE_DEPRECATION_WARNINGS > q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI; > } > #endif > - } > - > - if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == > AV_CODEC_ID_HEVC) { > - if (q->extbrc >= 0) > - q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : > MFX_CODINGOPTION_OFF; > - > q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2; > q->extco2.Header.BufferSz = sizeof(q->extco2); > > diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c > index 27e2232..3bdca7d 100644 > --- a/libavcodec/qsvenc_hevc.c > +++ b/libavcodec/qsvenc_hevc.c > @@ -262,6 +262,8 @@ static const AVCodecDefault qsv_enc_defaults[] = { > // same as the x264 default > { "g", "248" }, > { "bf", "8" }, > + { "qmin", "-1" }, > + { "qmax", "-1" }, > { "trellis", "-1" }, > { "flags", "+cgop" }, > #if FF_API_PRIVATE_OPT > -- > 2.7.4 > > > looks reasonable regards Max
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of > Max Dmitrichenko > Sent: Wednesday, March 11, 2020 19:37 > To: FFmpeg development discussions and patches <ffmpeg- > devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvenc_hevc: add qmax/qmin > support for HEVC encoding > > On Wed, Mar 11, 2020 at 11:44 AM Linjie Fu <linjie.fu@intel.com> wrote: > > > Add qmax/qmin support for HEVC software bitrate control(SWBRC). > > > > Limitations: > > - RateControlMethod != MFX_RATECONTROL_CQP > > - with EXTBRC ON > > > > Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com> > > Signed-off-by: Linjie Fu <linjie.fu@intel.com> > > --- > > > > Relative code in MSDK for the limitation: > > > > https://github.com/Intel-Media- > SDK/MediaSDK/blob/master/_studio/mfx_lib/encode_hw/hevc/agnostic/g9 > /hevcehw_g9_legacy.cpp#L4267 > > > > libavcodec/qsvenc.c | 11 +++++------ > > libavcodec/qsvenc_hevc.c | 2 ++ > > 2 files changed, 7 insertions(+), 6 deletions(-) > > > > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c > > index 52b4e43..2c22eb7 100644 > > --- a/libavcodec/qsvenc.c > > +++ b/libavcodec/qsvenc.c > > @@ -732,6 +732,11 @@ FF_ENABLE_DEPRECATION_WARNINGS > > if (q->adaptive_b >= 0) > > q->extco2.AdaptiveB = q->adaptive_b ? > MFX_CODINGOPTION_ON > > : MFX_CODINGOPTION_OFF; > > #endif > > + } > > + > > + if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == > > AV_CODEC_ID_HEVC) { > > + if (q->extbrc >= 0) > > + q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : > > MFX_CODINGOPTION_OFF; > > > > #if QSV_VERSION_ATLEAST(1, 9) > > if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > > > avctx->qmax) { > > @@ -747,12 +752,6 @@ FF_ENABLE_DEPRECATION_WARNINGS > > q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI; > > } > > #endif > > - } > > - > > - if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == > > AV_CODEC_ID_HEVC) { > > - if (q->extbrc >= 0) > > - q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : > > MFX_CODINGOPTION_OFF; > > - > > q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2; > > q->extco2.Header.BufferSz = sizeof(q->extco2); > > > > diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c > > index 27e2232..3bdca7d 100644 > > --- a/libavcodec/qsvenc_hevc.c > > +++ b/libavcodec/qsvenc_hevc.c > > @@ -262,6 +262,8 @@ static const AVCodecDefault qsv_enc_defaults[] = { > > // same as the x264 default > > { "g", "248" }, > > { "bf", "8" }, > > + { "qmin", "-1" }, > > + { "qmax", "-1" }, > > { "trellis", "-1" }, > > { "flags", "+cgop" }, > > #if FF_API_PRIVATE_OPT > > -- > > 2.7.4 > > > > > > > looks reasonable Thanks for review.
Linjie Fu <linjie.fu@intel.com> 于2020年3月11日周三 下午6:44写道: > > Add qmax/qmin support for HEVC software bitrate control(SWBRC). > > Limitations: > - RateControlMethod != MFX_RATECONTROL_CQP > - with EXTBRC ON > > Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com> > Signed-off-by: Linjie Fu <linjie.fu@intel.com> > --- > > Relative code in MSDK for the limitation: > https://github.com/Intel-Media-SDK/MediaSDK/blob/master/_studio/mfx_lib/encode_hw/hevc/agnostic/g9/hevcehw_g9_legacy.cpp#L4267 > > libavcodec/qsvenc.c | 11 +++++------ > libavcodec/qsvenc_hevc.c | 2 ++ > 2 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c > index 52b4e43..2c22eb7 100644 > --- a/libavcodec/qsvenc.c > +++ b/libavcodec/qsvenc.c > @@ -732,6 +732,11 @@ FF_ENABLE_DEPRECATION_WARNINGS > if (q->adaptive_b >= 0) > q->extco2.AdaptiveB = q->adaptive_b ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; > #endif > + } > + > + if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) { > + if (q->extbrc >= 0) > + q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; > > #if QSV_VERSION_ATLEAST(1, 9) > if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) { > @@ -747,12 +752,6 @@ FF_ENABLE_DEPRECATION_WARNINGS > q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI; > } > #endif > - } > - > - if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) { > - if (q->extbrc >= 0) > - q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; > - > q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2; > q->extco2.Header.BufferSz = sizeof(q->extco2); > > diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c > index 27e2232..3bdca7d 100644 > --- a/libavcodec/qsvenc_hevc.c > +++ b/libavcodec/qsvenc_hevc.c > @@ -262,6 +262,8 @@ static const AVCodecDefault qsv_enc_defaults[] = { > // same as the x264 default > { "g", "248" }, > { "bf", "8" }, > + { "qmin", "-1" }, > + { "qmax", "-1" }, > { "trellis", "-1" }, > { "flags", "+cgop" }, > #if FF_API_PRIVATE_OPT > -- > 2.7.4 LGTM, will apply
> From: Zhong Li <lizhong1008@gmail.com> > Sent: Thursday, March 12, 2020 10:07 > To: FFmpeg development discussions and patches <ffmpeg- > devel@ffmpeg.org> > Cc: Rogozhkin, Dmitry V <dmitry.v.rogozhkin@intel.com>; Fu, Linjie > <linjie.fu@intel.com> > Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvenc_hevc: add qmax/qmin > support for HEVC encoding > > Linjie Fu <linjie.fu@intel.com> 于2020年3月11日周三 下午6:44写道: > > > > Add qmax/qmin support for HEVC software bitrate control(SWBRC). > > > > Limitations: > > - RateControlMethod != MFX_RATECONTROL_CQP > > - with EXTBRC ON > > > > Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com> > > Signed-off-by: Linjie Fu <linjie.fu@intel.com> > > --- > > > > Relative code in MSDK for the limitation: > > https://github.com/Intel-Media- > SDK/MediaSDK/blob/master/_studio/mfx_lib/encode_hw/hevc/agnostic/g9 > /hevcehw_g9_legacy.cpp#L4267 > > > > libavcodec/qsvenc.c | 11 +++++------ > > libavcodec/qsvenc_hevc.c | 2 ++ > > 2 files changed, 7 insertions(+), 6 deletions(-) > > > > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c > > index 52b4e43..2c22eb7 100644 > > --- a/libavcodec/qsvenc.c > > +++ b/libavcodec/qsvenc.c > > @@ -732,6 +732,11 @@ FF_ENABLE_DEPRECATION_WARNINGS > > if (q->adaptive_b >= 0) > > q->extco2.AdaptiveB = q->adaptive_b ? > MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; > > #endif > > + } > > + > > + if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == > AV_CODEC_ID_HEVC) { > > + if (q->extbrc >= 0) > > + q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : > MFX_CODINGOPTION_OFF; > > > > #if QSV_VERSION_ATLEAST(1, 9) > > if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx- > >qmax) { > > @@ -747,12 +752,6 @@ FF_ENABLE_DEPRECATION_WARNINGS > > q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI; > > } > > #endif > > - } > > - > > - if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == > AV_CODEC_ID_HEVC) { > > - if (q->extbrc >= 0) > > - q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : > MFX_CODINGOPTION_OFF; > > - > > q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2; > > q->extco2.Header.BufferSz = sizeof(q->extco2); > > > > diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c > > index 27e2232..3bdca7d 100644 > > --- a/libavcodec/qsvenc_hevc.c > > +++ b/libavcodec/qsvenc_hevc.c > > @@ -262,6 +262,8 @@ static const AVCodecDefault qsv_enc_defaults[] = { > > // same as the x264 default > > { "g", "248" }, > > { "bf", "8" }, > > + { "qmin", "-1" }, > > + { "qmax", "-1" }, > > { "trellis", "-1" }, > > { "flags", "+cgop" }, > > #if FF_API_PRIVATE_OPT > > -- > > 2.7.4 > > LGTM, will apply A kind ping. - Linjie
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 52b4e43..2c22eb7 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -732,6 +732,11 @@ FF_ENABLE_DEPRECATION_WARNINGS if (q->adaptive_b >= 0) q->extco2.AdaptiveB = q->adaptive_b ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; #endif + } + + if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) { + if (q->extbrc >= 0) + q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; #if QSV_VERSION_ATLEAST(1, 9) if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) { @@ -747,12 +752,6 @@ FF_ENABLE_DEPRECATION_WARNINGS q->extco2.MaxQPP = q->extco2.MaxQPB = q->extco2.MaxQPI; } #endif - } - - if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC) { - if (q->extbrc >= 0) - q->extco2.ExtBRC = q->extbrc ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF; - q->extco2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2; q->extco2.Header.BufferSz = sizeof(q->extco2); diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index 27e2232..3bdca7d 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -262,6 +262,8 @@ static const AVCodecDefault qsv_enc_defaults[] = { // same as the x264 default { "g", "248" }, { "bf", "8" }, + { "qmin", "-1" }, + { "qmax", "-1" }, { "trellis", "-1" }, { "flags", "+cgop" }, #if FF_API_PRIVATE_OPT