aom: rtc: Update default_extra_cfg for CONFIG_REALTIME_ONLY

From 7e1785a94969232ef83a6393fb136b95b0c7af4c Mon Sep 17 00:00:00 2001
From: Marco Paniconi <[EMAIL REDACTED]>
Date: Tue, 20 Aug 2024 14:47:32 -0700
Subject: [PATCH] rtc: Update default_extra_cfg for CONFIG_REALTIME_ONLY

For CONFIG_REALTIME_ONLY: update the default_extra_cfg
to correspond to the recommended settings used for realtime
coding.

Also, some settings are changed for encoder_usage_cfg,
for AOM_USAGE_REALTIME, whether the build is a normal build
or realtime-only build.

Bug: 359341194
Change-Id: Ie9d5e63c9773cfd0b345cca7bb2537df193aa219
---
 av1/av1_cx_iface.c         | 87 ++++++++++++++++----------------------
 test/monochrome_test.cc    |  5 ++-
 test/rt_end_to_end_test.cc | 48 ++++++++++-----------
 3 files changed, 65 insertions(+), 75 deletions(-)

diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 83b331061..b062da133 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -369,22 +369,9 @@ static const struct av1_extracfg default_extra_cfg[] = {
       0,               // sb_qp_sweep
   },
 #endif  // !CONFIG_REALTIME_ONLY
-  // Settings changed for realtime only build:
-  // cpu_used: 7
-  // enable_tpl_model: 0
-  // enable_restoration: 0
-  // enable_obmc: 0
-  // deltaq_mode: NO_DELTA_Q
-  // enable_global_motion usage: 0
-  // enable_warped_motion at sequence level: 0
-  // allow_warped_motion at frame level: 0
-  // coeff_cost_upd_freq: COST_UPD_OFF
-  // mode_cost_upd_freq: COST_UPD_OFF
-  // mv_cost_upd_freq: COST_UPD_OFF
-  // dv_cost_upd_freq: COST_UPD_OFF
   {
       AOM_USAGE_REALTIME,  // usage
-      7,                   // cpu_used
+      10,                  // cpu_used
       1,                   // enable_auto_alt_ref
       0,                   // enable_auto_bwd_ref
       0,                   // noise_sensitivity
@@ -396,7 +383,7 @@ static const struct av1_extracfg default_extra_cfg[] = {
       0,                   // tile_rows
       0,                   // auto_tiles
       0,                   // enable_tpl_model
-      1,                   // enable_keyframe_filtering
+      0,                   // enable_keyframe_filtering
       7,                   // arnr_max_frames
       5,                   // arnr_strength
       0,                   // min_gf_interval; 0 -> default decision
@@ -410,7 +397,7 @@ static const struct av1_extracfg default_extra_cfg[] = {
       "./rate_map.txt",                           // rate distribution input
       AOM_DIST_METRIC_PSNR,                       // dist_metric
       10,                                         // cq_level
-      0,                                          // rc_max_intra_bitrate_pct
+      300,                                        // rc_max_intra_bitrate_pct
       0,                                          // rc_max_inter_bitrate_pct
       0,                                          // gf_cbr_boost_pct
       0,                                          // lossless
@@ -429,9 +416,9 @@ static const struct av1_extracfg default_extra_cfg[] = {
       0,                                          // mtu_size
       AOM_TIMING_UNSPECIFIED,       // No picture timing signaling in bitstream
       0,                            // frame_parallel_decoding_mode
-      1,                            // enable dual filter
+      0,                            // enable dual filter
       0,                            // enable delta quant in chroma planes
-      NO_AQ,                        // aq_mode
+      CYCLIC_REFRESH_AQ,            // aq_mode
       NO_DELTA_Q,                   // deltaq_mode
       100,                          // deltaq_strength
       0,                            // delta lf mode
@@ -455,42 +442,42 @@ static const struct av1_extracfg default_extra_cfg[] = {
       0,  // fpmt_unit_test
 #endif
       1,    // CDF update mode
-      1,    // enable rectangular partitions
-      1,    // enable ab shape partitions
-      1,    // enable 1:4 and 4:1 partitions
+      0,    // enable rectangular partitions
+      0,    // enable ab shape partitions
+      0,    // enable 1:4 and 4:1 partitions
       4,    // min_partition_size
       128,  // max_partition_size
-      1,    // enable intra edge filter
-      1,    // frame order hint
-      1,    // enable 64-pt transform usage
+      0,    // enable intra edge filter
+      0,    // frame order hint
+      0,    // enable 64-pt transform usage
       1,    // enable flip and identity transform
       1,    // enable rectangular transform usage
-      1,    // dist-wtd compound
-      7,    // max_reference_frames
+      0,    // dist-wtd compound
+      3,    // max_reference_frames
       0,    // enable_reduced_reference_set
-      1,    // enable_ref_frame_mvs sequence level
-      1,    // allow ref_frame_mvs frame level
-      1,    // enable masked compound at sequence level
-      1,    // enable one sided compound at sequence level
-      1,    // enable interintra compound at sequence level
-      1,    // enable smooth interintra mode
-      1,    // enable difference-weighted compound
-      1,    // enable interinter wedge compound
-      1,    // enable interintra wedge compound
+      0,    // enable_ref_frame_mvs sequence level
+      0,    // allow ref_frame_mvs frame level
+      0,    // enable masked compound at sequence level
+      0,    // enable one sided compound at sequence level
+      0,    // enable interintra compound at sequence level
+      0,    // enable smooth interintra mode
+      0,    // enable difference-weighted compound
+      0,    // enable interinter wedge compound
+      0,    // enable interintra wedge compound
       0,    // enable_global_motion usage
       0,    // enable_warped_motion at sequence level
       0,    // allow_warped_motion at frame level
-      1,    // enable filter intra at sequence level
-      1,    // enable smooth intra modes usage for sequence
-      1,    // enable Paeth intra mode usage for sequence
-      1,    // enable CFL uv intra mode usage for sequence
+      0,    // enable filter intra at sequence level
+      0,    // enable smooth intra modes usage for sequence
+      0,    // enable Paeth intra mode usage for sequence
+      0,    // enable CFL uv intra mode usage for sequence
       1,    // enable directional intra mode usage for sequence
       1,    // enable D45 to D203 intra mode usage for sequence
-      1,    // superres
-      1,    // enable overlay
-      1,    // enable palette
-      1,    // enable intrabc
-      1,    // enable angle delta
+      0,    // superres
+      0,    // enable overlay
+      0,    // enable palette
+      0,    // enable intrabc
+      0,    // enable angle delta
 #if CONFIG_DENOISE
       0,   // noise_level
       32,  // noise_block_size
@@ -501,7 +488,7 @@ static const struct av1_extracfg default_extra_cfg[] = {
       0,  // reduced_tx_type_set
       0,  // use_intra_dct_only
       0,  // use_inter_dct_only
-      0,  // use_intra_default_tx_only
+      1,  // use_intra_default_tx_only
       1,  // enable_tx_size_search
       0,  // quant_b_adapt
       0,  // vbr_corpus_complexity_lap
@@ -4764,12 +4751,12 @@ static const aom_codec_enc_cfg_t encoder_usage_cfg[] = {
       256,          // rc_target_bitrate
       0,            // rc_min_quantizer
       63,           // rc_max_quantizer
-      25,           // rc_undershoot_pct
-      25,           // rc_overshoot_pct
+      50,           // rc_undershoot_pct
+      50,           // rc_overshoot_pct
 
-      6000,  // rc_buf_sz
-      4000,  // rc_buf_initial_sz
-      5000,  // rc_buf_optimal_sz
+      1000,  // rc_buf_sz
+      600,   // rc_buf_initial_sz
+      600,   // rc_buf_optimal_sz
 
       50,    // rc_2pass_vbr_bias_pct
       0,     // rc_2pass_vbr_minsection_pct
diff --git a/test/monochrome_test.cc b/test/monochrome_test.cc
index c157275d4..ca180f699 100644
--- a/test/monochrome_test.cc
+++ b/test/monochrome_test.cc
@@ -31,7 +31,7 @@ const double kPsnrThreshold[3] = { 29.0, 41.5, 41.5 };
 // kPsnrFluctuation represents the maximum allowed psnr fluctuation w.r.t first
 // frame. The indices correspond to one/two-pass, allintra and realtime
 // encoding modes.
-const double kPsnrFluctuation[3] = { 2.5, 0.3, 16.0 };
+const double kPsnrFluctuation[3] = { 2.5, 0.3, 17.0 };
 
 class MonochromeTest
     : public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode, int,
@@ -183,6 +183,9 @@ TEST_P(MonochromeRealtimeTest, TestMonochromeEncoding) {
   cfg_.monochrome = 1;
   // Run at low bitrate.
   cfg_.rc_target_bitrate = 40;
+  cfg_.rc_buf_sz = 6000;
+  cfg_.rc_buf_initial_sz = 4000;
+  cfg_.rc_buf_optimal_sz = 5000;
   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
 
   // Check that the chroma planes are equal across all frames
diff --git a/test/rt_end_to_end_test.cc b/test/rt_end_to_end_test.cc
index 1e9238c06..2703d2c01 100644
--- a/test/rt_end_to_end_test.cc
+++ b/test/rt_end_to_end_test.cc
@@ -32,33 +32,33 @@ const int kBitrate = 500;
 std::unordered_map<std::string,
                    std::unordered_map<int, std::unordered_map<int, double>>>
     kPsnrThreshold = { { "park_joy_90p_8_420.y4m",
-                         { { 5, { { 0, 35.4 }, { 3, 36.3 } } },
-                           { 6, { { 0, 35.3 }, { 3, 36.2 } } },
-                           { 7, { { 0, 34.9 }, { 3, 35.8 } } },
-                           { 8, { { 0, 35.0 }, { 3, 35.8 } } },
-                           { 9, { { 0, 34.9 }, { 3, 35.5 } } },
-                           { 10, { { 0, 34.7 }, { 3, 35.3 } } } } },
+                         { { 5, { { 0, 35.3 }, { 3, 36.2 } } },
+                           { 6, { { 0, 35.2 }, { 3, 36.1 } } },
+                           { 7, { { 0, 34.8 }, { 3, 35.7 } } },
+                           { 8, { { 0, 34.9 }, { 3, 35.7 } } },
+                           { 9, { { 0, 34.9 }, { 3, 35.4 } } },
+                           { 10, { { 0, 34.6 }, { 3, 35.2 } } } } },
                        { "paris_352_288_30.y4m",
-                         { { 5, { { 0, 36.2 }, { 3, 36.7 } } },
-                           { 6, { { 0, 36.1 }, { 3, 36.48 } } },
-                           { 7, { { 0, 35.5 }, { 3, 36.0 } } },
-                           { 8, { { 0, 35.8 }, { 3, 36.4 } } },
-                           { 9, { { 0, 35.5 }, { 3, 36.0 } } },
-                           { 10, { { 0, 35.3 }, { 3, 35.9 } } } } },
+                         { { 5, { { 0, 36.1 }, { 3, 36.6 } } },
+                           { 6, { { 0, 36.0 }, { 3, 36.3 } } },
+                           { 7, { { 0, 35.4 }, { 3, 35.9 } } },
+                           { 8, { { 0, 35.7 }, { 3, 36.3 } } },
+                           { 9, { { 0, 35.4 }, { 3, 35.9 } } },
+                           { 10, { { 0, 35.2 }, { 3, 35.8 } } } } },
                        { "niklas_1280_720_30.y4m",
-                         { { 5, { { 0, 34.4 }, { 3, 34.2 } } },
-                           { 6, { { 0, 34.1 }, { 3, 34.0 } } },
-                           { 7, { { 0, 33.5 }, { 3, 33.1 } } },
-                           { 8, { { 0, 33.3 }, { 3, 33.3 } } },
-                           { 9, { { 0, 33.3 }, { 3, 33.3 } } },
-                           { 10, { { 0, 33.1 }, { 3, 33.1 } } } } },
+                         { { 5, { { 0, 34.3 }, { 3, 34.1 } } },
+                           { 6, { { 0, 34.0 }, { 3, 33.9 } } },
+                           { 7, { { 0, 33.4 }, { 3, 33.0 } } },
+                           { 8, { { 0, 33.2 }, { 3, 33.2 } } },
+                           { 9, { { 0, 33.2 }, { 3, 33.2 } } },
+                           { 10, { { 0, 33.0 }, { 3, 32.9 } } } } },
                        { "hantro_collage_w352h288_nv12.yuv",
-                         { { 5, { { 0, 34.4 }, { 3, 34.2 } } },
-                           { 6, { { 0, 34.1 }, { 3, 34.1 } } },
-                           { 7, { { 0, 33.6 }, { 3, 33.6 } } },
-                           { 8, { { 0, 33.3 }, { 3, 33.3 } } },
-                           { 9, { { 0, 33.3 }, { 3, 33.3 } } },
-                           { 10, { { 0, 33.1 }, { 3, 33.1 } } } } } };
+                         { { 5, { { 0, 34.3 }, { 3, 34.1 } } },
+                           { 6, { { 0, 34.0 }, { 3, 34.0 } } },
+                           { 7, { { 0, 33.5 }, { 3, 33.5 } } },
+                           { 8, { { 0, 33.2 }, { 3, 33.2 } } },
+                           { 9, { { 0, 33.2 }, { 3, 33.2 } } },
+                           { 10, { { 0, 33.1 }, { 3, 33.0 } } } } } };
 
 typedef struct {
   const char *filename;