aom: rtc: Add get control for high_motion_content_screen

From 6fb5bfdf30282eebf47db5ca6f0dfecedcd0853c Mon Sep 17 00:00:00 2001
From: Marco Paniconi <[EMAIL REDACTED]>
Date: Fri, 28 Jun 2024 09:56:36 -0700
Subject: [PATCH] rtc: Add get control for high_motion_content_screen

Change-Id: Ibf160f7774e748f8b9cfc292ccb1c2d255989054
---
 aom/aomcx.h                 | 10 ++++++++++
 av1/av1_cx_iface.c          | 11 +++++++++++
 examples/svc_encoder_rtc.cc |  7 +++++++
 3 files changed, 28 insertions(+)

diff --git a/aom/aomcx.h b/aom/aomcx.h
index 835eab84de..594d463a34 100644
--- a/aom/aomcx.h
+++ b/aom/aomcx.h
@@ -1547,6 +1547,13 @@ enum aome_enc_control_id {
    */
   AV1E_SET_AUTO_TILES = 166,
 
+  /*!\brief Codec control to get the high motion screen content flag.
+   * int * parameter.
+   * Returns an integer.
+   * 1 means high motion screen content, 0 means not.
+   */
+  AV1E_GET_HIGH_MOTION_CONTENT_SCREEN_RTC = 167,
+
   // Any new encoder control IDs should be added above.
   // Maximum allowed encoder control ID is 229.
   // No encoder control ID should be added below.
@@ -2207,6 +2214,9 @@ AOM_CTRL_USE_TYPE(AV1E_SET_MAX_CONSEC_FRAME_DROP_CBR, int)
 AOM_CTRL_USE_TYPE(AV1E_SET_AUTO_TILES, unsigned int)
 #define AOM_CTRL_AV1E_SET_AUTO_TILES
 
+AOM_CTRL_USE_TYPE(AV1E_GET_HIGH_MOTION_CONTENT_SCREEN_RTC, int *)
+#define AOM_CTRL_AV1E_GET_HIGH_MOTION_CONTENT_SCREEN_RTC
+
 /*!\endcond */
 /*! @} - end defgroup aom_encoder */
 #ifdef __cplusplus
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index a03fed9fc2..403cb83bd7 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -4435,6 +4435,15 @@ static aom_codec_err_t ctrl_get_luma_cdef_strength(aom_codec_alg_priv_t *ctx,
   return AOM_CODEC_OK;
 }
 
+static aom_codec_err_t ctrl_get_high_motion_content_screen_rtc(
+    aom_codec_alg_priv_t *ctx, va_list args) {
+  int *arg = va_arg(args, int *);
+  AV1_COMP *const cpi = ctx->ppi->cpi;
+  if (arg == NULL) return AOM_CODEC_INVALID_PARAM;
+  *arg = cpi->rc.high_motion_screen_content;
+  return AOM_CODEC_OK;
+}
+
 static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
   { AV1_COPY_REFERENCE, ctrl_copy_reference },
   { AOME_USE_REFERENCE, ctrl_use_reference },
@@ -4598,6 +4607,8 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
   { AV1E_GET_TARGET_SEQ_LEVEL_IDX, ctrl_get_target_seq_level_idx },
   { AV1E_GET_NUM_OPERATING_POINTS, ctrl_get_num_operating_points },
   { AV1E_GET_LUMA_CDEF_STRENGTH, ctrl_get_luma_cdef_strength },
+  { AV1E_GET_HIGH_MOTION_CONTENT_SCREEN_RTC,
+    ctrl_get_high_motion_content_screen_rtc },
 
   CTRL_MAP_END,
 };
diff --git a/examples/svc_encoder_rtc.cc b/examples/svc_encoder_rtc.cc
index c9ff20cdf3..0e9eba9c53 100644
--- a/examples/svc_encoder_rtc.cc
+++ b/examples/svc_encoder_rtc.cc
@@ -1915,6 +1915,13 @@ int main(int argc, const char **argv) {
       cx_time_layer[layer] += aom_usec_timer_elapsed(&timer);
       frame_cnt_layer[layer] += 1;
 
+      // Get the high motion content flag.
+      int content_flag = 0;
+      if (aom_codec_control(&codec, AV1E_GET_HIGH_MOTION_CONTENT_SCREEN_RTC,
+                            &content_flag)) {
+        die_codec(&codec, "Failed to GET_HIGH_MOTION_CONTENT_SCREEN_RTC");
+      }
+
       got_data = 0;
       // For simulcast (mode 11): write out each spatial layer to the file.
       int ss_layers_write = (app_input.layering_mode == 11)