diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc index d23e2d14d8..28a8e5f846 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc @@ -292,10 +292,16 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings, SET_ENCODER_PARAM_OR_RETURN_ERROR(AV1E_SET_ENABLE_PALETTE, 0); } - if (cfg_.g_threads == 4 && cfg_.g_w == 640 && - (cfg_.g_h == 360 || cfg_.g_h == 480)) { - SET_ENCODER_PARAM_OR_RETURN_ERROR(AV1E_SET_TILE_ROWS, - static_cast(log2(cfg_.g_threads))); + if (cfg_.g_threads == 8) { + // Values passed to AV1E_SET_TILE_ROWS and AV1E_SET_TILE_COLUMNS are log2() + // based. + // Use 4 tile columns x 2 tile rows for 8 threads. + SET_ENCODER_PARAM_OR_RETURN_ERROR(AV1E_SET_TILE_ROWS, 1); + SET_ENCODER_PARAM_OR_RETURN_ERROR(AV1E_SET_TILE_COLUMNS, 2); + } else if (cfg_.g_threads == 4) { + // Use 2 tile columns x 2 tile rows for 4 threads. + SET_ENCODER_PARAM_OR_RETURN_ERROR(AV1E_SET_TILE_ROWS, 1); + SET_ENCODER_PARAM_OR_RETURN_ERROR(AV1E_SET_TILE_COLUMNS, 1); } else { SET_ENCODER_PARAM_OR_RETURN_ERROR(AV1E_SET_TILE_COLUMNS, static_cast(log2(cfg_.g_threads))); @@ -399,7 +405,9 @@ int LibaomAv1Encoder::NumberOfThreads(int width, // Keep the number of encoder threads equal to the possible number of // column/row tiles, which is (1, 2, 4, 8). See comments below for // AV1E_SET_TILE_COLUMNS/ROWS. - if (width * height >= 640 * 360 && number_of_cores > 4) { + if (width * height > 1280 * 720 && number_of_cores > 8) { + return 8; + } else if (width * height >= 640 * 360 && number_of_cores > 4) { return 4; } else if (width * height >= 320 * 180 && number_of_cores > 2) { return 2;