aom: Declare all YV12_BUFFER_CONFIG * pointers as const

From db5207325d7ca6fee2e715671c976da7866145b1 Mon Sep 17 00:00:00 2001
From: Wan-Teh Chang <[EMAIL REDACTED]>
Date: Tue, 6 Feb 2024 07:31:58 -0800
Subject: [PATCH] Declare all YV12_BUFFER_CONFIG * pointers as const

Fix compiler warnings in -DCONFIG_TUNE_VMAF=1 builds caused by
https://aomedia-review.googlesource.com/c/aom/+/187061.

Change-Id: I9be8096770641218e634199d22ffaabe1b220322
---
 av1/encoder/tune_vmaf.c | 69 ++++++++++++++++++++---------------------
 av1/encoder/tune_vmaf.h |  6 ++--
 2 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/av1/encoder/tune_vmaf.c b/av1/encoder/tune_vmaf.c
index 4e5ffa387c..c8f0190c79 100644
--- a/av1/encoder/tune_vmaf.c
+++ b/av1/encoder/tune_vmaf.c
@@ -288,10 +288,10 @@ static AOM_INLINE void gaussian_blur(const int bit_depth,
   }
 }
 
-static AOM_INLINE double cal_approx_vmaf(const AV1_COMP *const cpi,
-                                         double source_variance,
-                                         YV12_BUFFER_CONFIG *const source,
-                                         YV12_BUFFER_CONFIG *const sharpened) {
+static AOM_INLINE double cal_approx_vmaf(
+    const AV1_COMP *const cpi, double source_variance,
+    const YV12_BUFFER_CONFIG *const source,
+    const YV12_BUFFER_CONFIG *const sharpened) {
   const int bit_depth = cpi->td.mb.e_mbd.bd;
   const bool cal_vmaf_neg =
       cpi->oxcf.tune_cfg.tuning == AOM_TUNE_VMAF_NEG_MAX_GAIN;
@@ -305,11 +305,11 @@ static AOM_INLINE double cal_approx_vmaf(const AV1_COMP *const cpi,
 }
 
 static double find_best_frame_unsharp_amount_loop(
-    const AV1_COMP *const cpi, YV12_BUFFER_CONFIG *const source,
-    YV12_BUFFER_CONFIG *const blurred, YV12_BUFFER_CONFIG *const sharpened,
-    double best_vmaf, const double baseline_variance,
-    const double unsharp_amount_start, const double step_size,
-    const int max_loop_count, const double max_amount) {
+    const AV1_COMP *const cpi, const YV12_BUFFER_CONFIG *const source,
+    const YV12_BUFFER_CONFIG *const blurred,
+    const YV12_BUFFER_CONFIG *const sharpened, double best_vmaf,
+    const double baseline_variance, const double unsharp_amount_start,
+    const double step_size, const int max_loop_count, const double max_amount) {
   const double min_amount = 0.0;
   int loop_count = 0;
   double approx_vmaf = best_vmaf;
@@ -328,13 +328,11 @@ static double find_best_frame_unsharp_amount_loop(
   return AOMMIN(max_amount, AOMMAX(unsharp_amount, min_amount));
 }
 
-static double find_best_frame_unsharp_amount(const AV1_COMP *const cpi,
-                                             YV12_BUFFER_CONFIG *const source,
-                                             YV12_BUFFER_CONFIG *const blurred,
-                                             const double unsharp_amount_start,
-                                             const double step_size,
-                                             const int max_loop_count,
-                                             const double max_filter_amount) {
+static double find_best_frame_unsharp_amount(
+    const AV1_COMP *const cpi, const YV12_BUFFER_CONFIG *const source,
+    const YV12_BUFFER_CONFIG *const blurred, const double unsharp_amount_start,
+    const double step_size, const int max_loop_count,
+    const double max_filter_amount) {
   const AV1_COMMON *const cm = &cpi->common;
   const int width = source->y_width;
   const int height = source->y_height;
@@ -376,7 +374,7 @@ static double find_best_frame_unsharp_amount(const AV1_COMP *const cpi,
 }
 
 void av1_vmaf_neg_preprocessing(AV1_COMP *const cpi,
-                                YV12_BUFFER_CONFIG *const source) {
+                                const YV12_BUFFER_CONFIG *const source) {
   const AV1_COMMON *const cm = &cpi->common;
   const int bit_depth = cpi->td.mb.e_mbd.bd;
   const int width = source->y_width;
@@ -403,7 +401,7 @@ void av1_vmaf_neg_preprocessing(AV1_COMP *const cpi,
 }
 
 void av1_vmaf_frame_preprocessing(AV1_COMP *const cpi,
-                                  YV12_BUFFER_CONFIG *const source) {
+                                  const YV12_BUFFER_CONFIG *const source) {
   const AV1_COMMON *const cm = &cpi->common;
   const int bit_depth = cpi->td.mb.e_mbd.bd;
   const int width = source->y_width;
@@ -442,7 +440,7 @@ void av1_vmaf_frame_preprocessing(AV1_COMP *const cpi,
 }
 
 void av1_vmaf_blk_preprocessing(AV1_COMP *const cpi,
-                                YV12_BUFFER_CONFIG *const source) {
+                                const YV12_BUFFER_CONFIG *const source) {
   const AV1_COMMON *const cm = &cpi->common;
   const int width = source->y_width;
   const int height = source->y_height;
@@ -881,8 +879,8 @@ static double calc_vmaf_motion_score(const AV1_COMP *const cpi,
 }
 
 static AOM_INLINE void get_neighbor_frames(const AV1_COMP *const cpi,
-                                           YV12_BUFFER_CONFIG **last,
-                                           YV12_BUFFER_CONFIG **next) {
+                                           const YV12_BUFFER_CONFIG **last,
+                                           const YV12_BUFFER_CONFIG **next) {
   const AV1_COMMON *const cm = &cpi->common;
   const GF_GROUP *gf_group = &cpi->ppi->gf_group;
   const int src_index =
@@ -920,7 +918,7 @@ int av1_get_vmaf_base_qindex(const AV1_COMP *const cpi, int current_qindex) {
   if (approx_sse < sse_threshold || approx_dvmaf < vmaf_threshold) {
     return current_qindex;
   }
-  YV12_BUFFER_CONFIG *cur_buf = cpi->source;
+  const YV12_BUFFER_CONFIG *cur_buf = cpi->source;
   if (cm->show_frame == 0) {
     const int src_index = gf_group->arf_src_offset[cpi->gf_frame_index];
     struct lookahead_entry *cur_entry = av1_lookahead_peek(
@@ -929,7 +927,7 @@ int av1_get_vmaf_base_qindex(const AV1_COMP *const cpi, int current_qindex) {
   }
   assert(cur_buf);
 
-  YV12_BUFFER_CONFIG *next_buf, *last_buf;
+  const YV12_BUFFER_CONFIG *next_buf, *last_buf;
   get_neighbor_frames(cpi, &last_buf, &next_buf);
   assert(last_buf);
 
@@ -954,8 +952,8 @@ int av1_get_vmaf_base_qindex(const AV1_COMP *const cpi, int current_qindex) {
 
 static AOM_INLINE double cal_approx_score(
     AV1_COMP *const cpi, double src_variance, double new_variance,
-    double src_score, YV12_BUFFER_CONFIG *const src,
-    YV12_BUFFER_CONFIG *const recon_sharpened) {
+    double src_score, const YV12_BUFFER_CONFIG *const src,
+    const YV12_BUFFER_CONFIG *const recon_sharpened) {
   double score;
   const uint32_t bit_depth = cpi->td.mb.e_mbd.bd;
   const bool cal_vmaf_neg =
@@ -967,11 +965,12 @@ static AOM_INLINE double cal_approx_score(
 
 static double find_best_frame_unsharp_amount_loop_neg(
     AV1_COMP *const cpi, double src_variance, double base_score,
-    YV12_BUFFER_CONFIG *const src, YV12_BUFFER_CONFIG *const recon,
-    YV12_BUFFER_CONFIG *const ref, YV12_BUFFER_CONFIG *const src_blurred,
-    YV12_BUFFER_CONFIG *const recon_blurred,
-    YV12_BUFFER_CONFIG *const src_sharpened,
-    YV12_BUFFER_CONFIG *const recon_sharpened, FULLPEL_MV *mvs,
+    const YV12_BUFFER_CONFIG *const src, const YV12_BUFFER_CONFIG *const recon,
+    const YV12_BUFFER_CONFIG *const ref,
+    const YV12_BUFFER_CONFIG *const src_blurred,
+    const YV12_BUFFER_CONFIG *const recon_blurred,
+    const YV12_BUFFER_CONFIG *const src_sharpened,
+    const YV12_BUFFER_CONFIG *const recon_sharpened, FULLPEL_MV *mvs,
     double best_score, const double unsharp_amount_start,
     const double step_size, const int max_loop_count, const double max_amount) {
   const double min_amount = 0.0;
@@ -999,8 +998,8 @@ static double find_best_frame_unsharp_amount_loop_neg(
 }
 
 static double find_best_frame_unsharp_amount_neg(
-    AV1_COMP *const cpi, YV12_BUFFER_CONFIG *const src,
-    YV12_BUFFER_CONFIG *const recon, YV12_BUFFER_CONFIG *const ref,
+    AV1_COMP *const cpi, const YV12_BUFFER_CONFIG *const src,
+    const YV12_BUFFER_CONFIG *const recon, const YV12_BUFFER_CONFIG *const ref,
     double base_score, const double unsharp_amount_start,
     const double step_size, const int max_loop_count,
     const double max_filter_amount) {
@@ -1076,8 +1075,8 @@ static double find_best_frame_unsharp_amount_neg(
 }
 
 void av1_update_vmaf_curve(AV1_COMP *cpi) {
-  YV12_BUFFER_CONFIG *source = cpi->source;
-  YV12_BUFFER_CONFIG *recon = &cpi->common.cur_frame->buf;
+  const YV12_BUFFER_CONFIG *source = cpi->source;
+  const YV12_BUFFER_CONFIG *recon = &cpi->common.cur_frame->buf;
   const int bit_depth = cpi->td.mb.e_mbd.bd;
   const GF_GROUP *const gf_group = &cpi->ppi->gf_group;
   const int layer_depth =
@@ -1099,7 +1098,7 @@ void av1_update_vmaf_curve(AV1_COMP *cpi) {
   }
 
   if (cpi->oxcf.tune_cfg.tuning == AOM_TUNE_VMAF_NEG_MAX_GAIN) {
-    YV12_BUFFER_CONFIG *last, *next;
+    const YV12_BUFFER_CONFIG *last, *next;
     get_neighbor_frames(cpi, &last, &next);
     double best_unsharp_amount_start =
         get_layer_value(cpi->vmaf_info.last_frame_unsharp_amount, layer_depth);
diff --git a/av1/encoder/tune_vmaf.h b/av1/encoder/tune_vmaf.h
index a04a29e6fe..404fd1029a 100644
--- a/av1/encoder/tune_vmaf.h
+++ b/av1/encoder/tune_vmaf.h
@@ -43,13 +43,13 @@ typedef struct {
 struct AV1_COMP;
 
 void av1_vmaf_blk_preprocessing(struct AV1_COMP *cpi,
-                                YV12_BUFFER_CONFIG *source);
+                                const YV12_BUFFER_CONFIG *source);
 
 void av1_vmaf_frame_preprocessing(struct AV1_COMP *cpi,
-                                  YV12_BUFFER_CONFIG *source);
+                                  const YV12_BUFFER_CONFIG *source);
 
 void av1_vmaf_neg_preprocessing(struct AV1_COMP *cpi,
-                                YV12_BUFFER_CONFIG *source);
+                                const YV12_BUFFER_CONFIG *source);
 
 void av1_set_mb_vmaf_rdmult_scaling(struct AV1_COMP *cpi);