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

Fu, Linjie linjie.fu at intel.com
Fri Nov 29 07:44:46 EET 2019


> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> mypopy at gmail.com
> Sent: Friday, November 29, 2019 13:03
> To: FFmpeg development discussions and patches <ffmpeg-
> devel at ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvenc: add Tiles encode support
> for HEVC
> 
> On Tue, Nov 26, 2019 at 12:04 PM Linjie Fu <linjie.fu at intel.com> wrote:
> >
> > 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;
> Is it have any other limition for the number of tile columns/rows ?

It depends on the  total number of row/column blocks and the work mode of encoder(VDEnc or VMEPAK).
The limitation varies:
https://github.com/Intel-Media-SDK/MediaSDK/blob/5a84af5fa61823a84f32e4b26d864730a927f48c/_studio/mfx_lib/encode_hw/h265/src/mfx_h265_encode_hw_par.cpp#L524

Hence I dumped the returned MFX_EXTBUFF_HEVC_TILES buffer to see the truly supported numbers
of Columns and Rows.

If the setting of row or col is out of range, this would help to inform user.

Thanks,

- linjie




More information about the ffmpeg-devel mailing list