From 16ba5aeec0401bd9ef4b63097786effa0c313da7 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 28 Nov 2022 11:08:47 +0100 Subject: [PATCH] lavc SVT HEVC: set tiling only if video is big enough - tile must be at least 256x64 - there must be >1 tiles --- src/video_compress/libavcodec.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/video_compress/libavcodec.cpp b/src/video_compress/libavcodec.cpp index adfaa7038..60cc7a00d 100644 --- a/src/video_compress/libavcodec.cpp +++ b/src/video_compress/libavcodec.cpp @@ -1870,14 +1870,16 @@ static void configure_svt(AVCodecContext *codec_ctx, struct setparam_param *para if ("libsvt_hevc"s == codec_ctx->codec->name) { int tile_col_cnt = param->desc.width >= 1024 ? 4 : param->desc.width >= 512 ? 2 : 1; int tile_row_cnt = param->desc.height >= 256 ? 4 : param->desc.height >= 128 ? 2 : 1; - if (int ret = av_opt_set_int(codec_ctx->priv_data, "tile_row_cnt", tile_row_cnt, 0)) { - print_libav_error(LOG_LEVEL_WARNING, MOD_NAME "Unable Tile Row Count for SVT", ret); - } - if (int ret = av_opt_set_int(codec_ctx->priv_data, "tile_col_cnt", tile_col_cnt, 0)) { - print_libav_error(LOG_LEVEL_WARNING, MOD_NAME "Unable Tile Column Count for SVT", ret); - } - if (int ret = av_opt_set_int(codec_ctx->priv_data, "tile_slice_mode", 1, 0)) { - print_libav_error(LOG_LEVEL_WARNING, MOD_NAME "Unable Tile Slice Mode for SVT", ret); + if (tile_col_cnt * tile_row_cnt > 1 && param->desc.width >= 256 && param->desc.height >= 64) { + if (int ret = av_opt_set_int(codec_ctx->priv_data, "tile_row_cnt", tile_row_cnt, 0)) { + print_libav_error(LOG_LEVEL_WARNING, MOD_NAME "Unable Tile Row Count for SVT", ret); + } + if (int ret = av_opt_set_int(codec_ctx->priv_data, "tile_col_cnt", tile_col_cnt, 0)) { + print_libav_error(LOG_LEVEL_WARNING, MOD_NAME "Unable Tile Column Count for SVT", ret); + } + if (int ret = av_opt_set_int(codec_ctx->priv_data, "tile_slice_mode", 1, 0)) { + print_libav_error(LOG_LEVEL_WARNING, MOD_NAME "Unable Tile Slice Mode for SVT", ret); + } } } else { // libsvtav1 #if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(59, 21, 100)