[FFmpeg-devel] [PATCH] lavc/qsvenc: add Tiles encode support for HEVC

Fu, Linjie linjie.fu at intel.com
Tue Dec 10 02:56:51 EET 2019


> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> Zhong Li
> Sent: Sunday, December 8, 2019 16:32
> To: FFmpeg development discussions and patches <ffmpeg-
> devel at ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvenc: add Tiles encode support
> for HEVC
> 
> Linjie Fu <linjie.fu at intel.com> 于2019年11月26日周二 下午12:04写道:
> >
> > Add -tile_rows and -tile_cols option to specify the number of tile rows
> > and columns for ICL+ (gen 11) platform.
> >
> > A tile must wholly contain all the slices within it. Slices cannot cross
> > tile boundaries. So the slice number would be implicitly resized to the
> > max(nSlice, nTile).
> >
> > Example:
> >     ffmpeg -v verbose -hwaccel qsv -init_hw_device qsv=hw
> >     -filter_hw_device hw -f rawvideo -s:v 1920x1080 -i ./input.nv12 -vf
> >     format=nv12,hwupload=extra_hw_frames=64 -c:v hevc_qsv -tile_rows 2
> >     -tile_cols 2 -slices 4 -y output.h265
> >
> > Also dump the actual quantity of encoded tiled rows and columns in run
> > time.
> >
> > Fix the enhancement #8400.
> >
> > Signed-off-by: Linjie Fu <linjie.fu at intel.com>
> > ---
> >  libavcodec/qsvenc.c      | 32 +++++++++++++++++++++++++++++++-
> >  libavcodec/qsvenc.h      |  7 +++++++
> >  libavcodec/qsvenc_hevc.c |  3 +++
> >  3 files changed, 41 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> > index e176d57..64814fc 100644
> > --- a/libavcodec/qsvenc.c
> > +++ b/libavcodec/qsvenc.c
> > @@ -139,6 +139,9 @@ static void dump_video_param(AVCodecContext
> *avctx, QSVEncContext *q,
> >  #if QSV_HAVE_CO3
> >      mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[2];
> >  #endif
> > +#if QSV_HAVE_EXT_HEVC_TILES
> > +    mfxExtHEVCTiles *exthevctiles = (mfxExtHEVCTiles *)coding_opts[3 +
> QSV_HAVE_CO_VPS];
> > +#endif
> >
> >      av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n",
> >             print_profile(info->CodecProfile), info->CodecLevel);
> > @@ -204,6 +207,12 @@ static void dump_video_param(AVCodecContext
> *avctx, QSVEncContext *q,
> >      av_log(avctx, AV_LOG_VERBOSE, "RateDistortionOpt: %s\n",
> >             print_threestate(co->RateDistortionOpt));
> >
> > +#if QSV_HAVE_EXT_HEVC_TILES
> > +    if (avctx->codec_id == AV_CODEC_ID_HEVC)
> > +        av_log(avctx, AV_LOG_VERBOSE, "NumTileColumns: %"PRIu16";
> NumTileRows: %"PRIu16"\n",
> > +               exthevctiles->NumTileColumns, exthevctiles->NumTileRows);
> > +#endif
> > +
> >  #if QSV_HAVE_CO2
> >      av_log(avctx, AV_LOG_VERBOSE,
> >             "RecoveryPointSEI: %s IntRefType: %"PRIu16";
> IntRefCycleSize: %"PRIu16"; IntRefQPDelta: %"PRId16"\n",
> > @@ -771,6 +780,16 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >      }
> >  #endif
> >
> > +#if QSV_HAVE_EXT_HEVC_TILES
> > +    if (avctx->codec_id == AV_CODEC_ID_HEVC) {
> > +        q->exthevctiles.Header.BufferId = MFX_EXTBUFF_HEVC_TILES;
> > +        q->exthevctiles.Header.BufferSz = sizeof(q->exthevctiles);
> > +        q->exthevctiles.NumTileColumns  = q->tile_cols;
> > +        q->exthevctiles.NumTileRows     = q->tile_rows;
> > +        q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer
> *)&q->exthevctiles;
> > +    }
> > +#endif
> > +
> >      if (!check_enc_param(avctx,q)) {
> >          av_log(avctx, AV_LOG_ERROR,
> >                 "some encoding parameters are not supported by the QSV "
> > @@ -887,7 +906,14 @@ static int
> qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q)
> >      };
> >  #endif
> >
> > -    mfxExtBuffer *ext_buffers[2 + QSV_HAVE_CO2 + QSV_HAVE_CO3 +
> QSV_HAVE_CO_VPS];
> > +#if QSV_HAVE_EXT_HEVC_TILES
> > +    mfxExtHEVCTiles hevc_tile_buf = {
> > +         .Header.BufferId = MFX_EXTBUFF_HEVC_TILES,
> > +         .Header.BufferSz = sizeof(hevc_tile_buf),
> > +    };
> > +#endif
> > +
> > +    mfxExtBuffer *ext_buffers[2 + QSV_HAVE_CO2 + QSV_HAVE_CO3 +
> QSV_HAVE_CO_VPS + QSV_HAVE_EXT_HEVC_TILES];
> 
> Should be checked with #if QSV_HAVE_EXT_HEVC_TILES""

Hi,

IMHO the check may be redundant. If  the version of MSDK  < 1.13,
QSV_HAVE_EXT_HEVC_TILES equals 0,  above expression is identical to
mfxExtBuffer *ext_buffers[2 + QSV_HAVE_CO2 + QSV_HAVE_CO3 + QSV_HAVE_CO_VPS + 0];

And there is no version check for CO2/CO3/VPS.

> The reset LGTM.

Thanks for the review.

- linjie


More information about the ffmpeg-devel mailing list