diff options
author | Mark Thompson <sw@jkqxz.net> | 2022-03-17 14:41:50 +0800 |
---|---|---|
committer | Haihao Xiang <haihao.xiang@intel.com> | 2022-04-11 11:38:43 +0800 |
commit | 99b333e5ff5a91de2a5d740bbc9fa344154511c1 (patch) | |
tree | b8f66b368c9b5c84a411ab3646aba9572e8c5df5 /libavcodec/vaapi_encode.c | |
parent | a285968a0b122484635846babd9a1e8183e70fb0 (diff) | |
download | ffmpeg-99b333e5ff5a91de2a5d740bbc9fa344154511c1.tar.gz |
vaapi_encode: Move block size calculation after entrypoint selection
The block size can be dependent on the profile and entrypoint selected.
It defaults to 16x16, with codecs able to override this choice with their
own function.
Signed-off-by: Fei Wang <fei.w.wang@intel.com>
Diffstat (limited to 'libavcodec/vaapi_encode.c')
-rw-r--r-- | libavcodec/vaapi_encode.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 21a0ed0827..0e2f5ed447 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -2117,6 +2117,8 @@ static av_cold int vaapi_encode_init_slice_structure(AVCodecContext *avctx) return 0; } + av_assert0(ctx->slice_block_height > 0 && ctx->slice_block_width > 0); + ctx->slice_block_rows = (avctx->height + ctx->slice_block_height - 1) / ctx->slice_block_height; ctx->slice_block_cols = (avctx->width + ctx->slice_block_width - 1) / @@ -2506,6 +2508,20 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx) if (err < 0) goto fail; + if (ctx->codec->get_encoder_caps) { + err = ctx->codec->get_encoder_caps(avctx); + if (err < 0) + goto fail; + } else { + // Assume 16x16 blocks. + ctx->surface_width = FFALIGN(avctx->width, 16); + ctx->surface_height = FFALIGN(avctx->height, 16); + if (ctx->codec->flags & FLAG_SLICE_CONTROL) { + ctx->slice_block_width = 16; + ctx->slice_block_height = 16; + } + } + err = vaapi_encode_init_rate_control(avctx); if (err < 0) goto fail; |