Skip to content

Commit

Permalink
lavc/qsvenc: add tile encoding support for VP9
Browse files Browse the repository at this point in the history
Add -tile_rows and -tile_cols options to specify the number of tile
rows and columns

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
  • Loading branch information
Haihao Xiang authored and xhaihao committed Jan 29, 2022
1 parent 4cc7239 commit 80801e5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/encoders.texi
Original file line number Diff line number Diff line change
Expand Up @@ -3512,6 +3512,12 @@ These options are used by vp9_qsv
@item profile2
@item profile3
@end table

@item @var{tile_cols}
Number of columns for tiled encoding (requires libmfx >= 1.29).

@item @var{tile_rows}
Number of rows for tiled encoding (requires libmfx >= 1.29).
@end table

@section snow
Expand Down
4 changes: 4 additions & 0 deletions libavcodec/qsvenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,10 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q)
q->extvp9param.Header.BufferId = MFX_EXTBUFF_VP9_PARAM;
q->extvp9param.Header.BufferSz = sizeof(q->extvp9param);
q->extvp9param.WriteIVFHeaders = MFX_CODINGOPTION_OFF;
#if QSV_HAVE_EXT_VP9_TILES
q->extvp9param.NumTileColumns = q->tile_cols;
q->extvp9param.NumTileRows = q->tile_rows;
#endif
q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->extvp9param;
}
#endif
Expand Down
1 change: 1 addition & 0 deletions libavcodec/qsvenc.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#define QSV_HAVE_EXT_HEVC_TILES QSV_VERSION_ATLEAST(1, 13)
#define QSV_HAVE_EXT_VP9_PARAM QSV_VERSION_ATLEAST(1, 26)
#define QSV_HAVE_EXT_VP9_TILES QSV_VERSION_ATLEAST(1, 29)

#define QSV_HAVE_TRELLIS QSV_VERSION_ATLEAST(1, 8)
#define QSV_HAVE_MAX_SLICE_SIZE QSV_VERSION_ATLEAST(1, 9)
Expand Down
10 changes: 10 additions & 0 deletions libavcodec/qsvenc_vp9.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ static const AVOption options[] = {
{ "profile2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_VP9_2 }, INT_MIN, INT_MAX, VE, "profile" },
{ "profile3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_VP9_3 }, INT_MIN, INT_MAX, VE, "profile" },

#if QSV_HAVE_EXT_VP9_TILES
/* The minimum tile width in luma pixels is 256, set maximum tile_cols to 32 for 8K video */
{ "tile_cols", "Number of columns for tiled encoding", OFFSET(qsv.tile_cols), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 32, VE },
/* Set maximum tile_rows to 4 per VP9 spec */
{ "tile_rows", "Number of rows for tiled encoding", OFFSET(qsv.tile_rows), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 4, VE },
#else
{ "tile_cols", "(not supported)", OFFSET(qsv.tile_cols), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 0, VE },
{ "tile_rows", "(not supported)", OFFSET(qsv.tile_rows), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 0, VE },
#endif

{ NULL },
};

Expand Down

0 comments on commit 80801e5

Please sign in to comment.