From d6382e4469e8864477139636207d0c056066e526 Mon Sep 17 00:00:00 2001 From: Yunqing Wang Date: Thu, 2 Feb 2023 16:30:09 -0800 Subject: [PATCH] Fix uninitialized mesh feature for BEST mode At BEST encoding mode, the mesh search range wasn't initialized for non FC_GRAPHICS_ANIMATION content type, which actually/mistakenly used speed 0's setting. Fixed it by adding the initialization. There were 2 ways to fix this. Patchset 1 set to use speed 0's setting for non FC_GRAPHICS_ANIMATION type. This didn't change BEST mode's encoding results much, and only a couple of clips' results were changed. Borg result for BEST mode: avg_psnr: ovr_psnr: ssim: encoding_spdup: lowres2: -0.004 -0.003 -0.000 0.030 midres2: -0.006 -0.009 -0.012 0.033 hdres2: 0.002 0.002 0.004 0.015 Patchset 2 set to use BEST's setting for non FC_GRAPHICS_ANIMATION type. However, the majority of test clips' BDrate got changed up to ~0.5% (gain or loss), and overall it didn't give better performance than patchset 1. So, we chose to use patchset 1. Change-Id: Ibbf578dad04420e6ba22cb9a3ddec137a7e4deef --- vp9/encoder/vp9_speed_features.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index 0431d8a..41a742c 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -16,8 +16,11 @@ #include "vpx_dsp/vpx_dsp_common.h" // Mesh search patters for various speed settings -static MESH_PATTERN best_quality_mesh_pattern[MAX_MESH_STEP] = { - { 64, 4 }, { 28, 2 }, { 15, 1 }, { 7, 1 } +// Define 2 mesh density levels for FC_GRAPHICS_ANIMATION content type and non +// FC_GRAPHICS_ANIMATION content type. +static MESH_PATTERN best_quality_mesh_pattern[2][MAX_MESH_STEP] = { + { { 64, 4 }, { 28, 2 }, { 15, 1 }, { 7, 1 } }, + { { 64, 8 }, { 28, 4 }, { 15, 1 }, { 7, 1 } }, }; #if !CONFIG_REALTIME_ONLY @@ -991,10 +994,14 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi, int speed) { sf->exhaustive_searches_thresh = (cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) ? (1 << 20) : INT_MAX; - if (cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) { + { + const int mesh_density_level = + (cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) ? 0 : 1; for (i = 0; i < MAX_MESH_STEP; ++i) { - sf->mesh_patterns[i].range = best_quality_mesh_pattern[i].range; - sf->mesh_patterns[i].interval = best_quality_mesh_pattern[i].interval; + sf->mesh_patterns[i].range = + best_quality_mesh_pattern[mesh_density_level][i].range; + sf->mesh_patterns[i].interval = + best_quality_mesh_pattern[mesh_density_level][i].interval; } } -- 2.7.4