aom: Remove some dead code

From b345b274d2b3d00ec5d8eb47b113f331547a65a9 Mon Sep 17 00:00:00 2001
From: Rachel Barker <[EMAIL REDACTED]>
Date: Thu, 15 Feb 2024 18:17:00 +0000
Subject: [PATCH] Remove some dead code

Change-Id: Iecdfa9361b41f337b2dac63532eaa7a616b74c8d
---
 aom_dsp/flow_estimation/disflow.h |  1 -
 aom_dsp/mathutils.h               |  1 -
 aom_dsp/rect.h                    | 35 --------------
 av1/common/tile_common.c          | 39 ----------------
 av1/common/tile_common.h          |  5 --
 av1/encoder/global_motion.c       | 77 -------------------------------
 av1/encoder/global_motion.h       | 31 -------------
 7 files changed, 189 deletions(-)
 delete mode 100644 aom_dsp/rect.h

diff --git a/aom_dsp/flow_estimation/disflow.h b/aom_dsp/flow_estimation/disflow.h
index 1ba5e230b8..ac3680004d 100644
--- a/aom_dsp/flow_estimation/disflow.h
+++ b/aom_dsp/flow_estimation/disflow.h
@@ -15,7 +15,6 @@
 #include <stdbool.h>
 
 #include "aom_dsp/flow_estimation/flow_estimation.h"
-#include "aom_dsp/rect.h"
 #include "aom_scale/yv12config.h"
 
 #ifdef __cplusplus
diff --git a/aom_dsp/mathutils.h b/aom_dsp/mathutils.h
index cbb6cf491f..26635fc4d1 100644
--- a/aom_dsp/mathutils.h
+++ b/aom_dsp/mathutils.h
@@ -17,7 +17,6 @@
 #include <string.h>
 
 #include "aom_dsp/aom_dsp_common.h"
-#include "aom_mem/aom_mem.h"
 
 static const double TINY_NEAR_ZERO = 1.0E-16;
 
diff --git a/aom_dsp/rect.h b/aom_dsp/rect.h
deleted file mode 100644
index 11bdaca979..0000000000
--- a/aom_dsp/rect.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2022, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 2 Clause License and
- * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
- * was not distributed with this source code in the LICENSE file, you can
- * obtain it at www.aomedia.org/license/software. If the Alliance for Open
- * Media Patent License 1.0 was not distributed with this source code in the
- * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
- */
-
-#ifndef AOM_AOM_DSP_RECT_H_
-#define AOM_AOM_DSP_RECT_H_
-
-#include "config/aom_config.h"
-
-#include <stdbool.h>
-
-// Struct representing a rectangle of pixels.
-// The axes are inclusive-exclusive, ie. the point (top, left) is included
-// in the rectangle but (bottom, right) is not.
-typedef struct {
-  int left, right, top, bottom;
-} PixelRect;
-
-static INLINE int rect_width(const PixelRect *r) { return r->right - r->left; }
-
-static INLINE int rect_height(const PixelRect *r) { return r->bottom - r->top; }
-
-static INLINE bool is_inside_rect(const int x, const int y,
-                                  const PixelRect *r) {
-  return (r->left <= x && x < r->right) && (r->top <= y && y < r->bottom);
-}
-
-#endif  // AOM_AOM_DSP_RECT_H_
diff --git a/av1/common/tile_common.c b/av1/common/tile_common.c
index b964f259b8..b9cd205831 100644
--- a/av1/common/tile_common.c
+++ b/av1/common/tile_common.c
@@ -177,45 +177,6 @@ int av1_get_sb_cols_in_tile(const AV1_COMMON *cm, const TileInfo *tile) {
                            cm->seq_params->mib_size_log2);
 }
 
-PixelRect av1_get_tile_rect(const TileInfo *tile_info, const AV1_COMMON *cm,
-                            int is_uv) {
-  PixelRect r;
-
-  // Calculate position in the Y plane
-  r.left = tile_info->mi_col_start * MI_SIZE;
-  r.right = tile_info->mi_col_end * MI_SIZE;
-  r.top = tile_info->mi_row_start * MI_SIZE;
-  r.bottom = tile_info->mi_row_end * MI_SIZE;
-
-  // If upscaling is enabled, the tile limits need scaling to match the
-  // upscaled frame where the restoration units live. To do this, scale up the
-  // top-left and bottom-right of the tile.
-  if (av1_superres_scaled(cm)) {
-    av1_calculate_unscaled_superres_size(&r.left, &r.top,
-                                         cm->superres_scale_denominator);
-    av1_calculate_unscaled_superres_size(&r.right, &r.bottom,
-                                         cm->superres_scale_denominator);
-  }
-
-  const int frame_w = cm->superres_upscaled_width;
-  const int frame_h = cm->superres_upscaled_height;
-
-  // Make sure we don't fall off the bottom-right of the frame.
-  r.right = AOMMIN(r.right, frame_w);
-  r.bottom = AOMMIN(r.bottom, frame_h);
-
-  // Convert to coordinates in the appropriate plane
-  const int ss_x = is_uv && cm->seq_params->subsampling_x;
-  const int ss_y = is_uv && cm->seq_params->subsampling_y;
-
-  r.left = ROUND_POWER_OF_TWO(r.left, ss_x);
-  r.right = ROUND_POWER_OF_TWO(r.right, ss_x);
-  r.top = ROUND_POWER_OF_TWO(r.top, ss_y);
-  r.bottom = ROUND_POWER_OF_TWO(r.bottom, ss_y);
-
-  return r;
-}
-
 void av1_get_uniform_tile_size(const AV1_COMMON *cm, int *w, int *h) {
   const CommonTileParams *const tiles = &cm->tiles;
   if (tiles->uniform_spacing) {
diff --git a/av1/common/tile_common.h b/av1/common/tile_common.h
index 5383ae940b..851125fb58 100644
--- a/av1/common/tile_common.h
+++ b/av1/common/tile_common.h
@@ -17,7 +17,6 @@ extern "C" {
 #endif
 
 #include "config/aom_config.h"
-#include "aom_dsp/rect.h"
 
 struct AV1Common;
 struct SequenceHeader;
@@ -43,10 +42,6 @@ void av1_tile_set_col(TileInfo *tile, const struct AV1Common *cm, int col);
 int av1_get_sb_rows_in_tile(const struct AV1Common *cm, const TileInfo *tile);
 int av1_get_sb_cols_in_tile(const struct AV1Common *cm, const TileInfo *tile);
 
-// Return the pixel extents of the given tile
-PixelRect av1_get_tile_rect(const TileInfo *tile_info,
-                            const struct AV1Common *cm, int is_uv);
-
 // Define tile maximum width and area
 // There is no maximum height since height is limited by area and width limits
 // The minimum tile width or height is fixed at one superblock
diff --git a/av1/encoder/global_motion.c b/av1/encoder/global_motion.c
index 0847a39e68..0ae47809c6 100644
--- a/av1/encoder/global_motion.c
+++ b/av1/encoder/global_motion.c
@@ -30,83 +30,6 @@
 // Border over which to compute the global motion
 #define ERRORADV_BORDER 0
 
-/* clang-format off */
-// Error metric used for global motion evaluation.
-// For 8-bit input, the pixel error used to index this table will always
-// be between -255 and +255. But for 10- and 12-bit input, we use interpolation
-// which means that we need to support indices of -256 and +256 as well.
-// Therefore, the table is offset so that logical index 0 corresponds to
-// error_measure_lut[256].
-const int error_measure_lut[513] = {
-    // pow 0.7
-    16384, 16384, 16339, 16294, 16249, 16204, 16158, 16113,
-    16068, 16022, 15977, 15932, 15886, 15840, 15795, 15749,
-    15703, 15657, 15612, 15566, 15520, 15474, 15427, 15381,
-    15335, 15289, 15242, 15196, 15149, 15103, 15056, 15010,
-    14963, 14916, 14869, 14822, 14775, 14728, 14681, 14634,
-    14587, 14539, 14492, 14445, 14397, 14350, 14302, 14254,
-    14206, 14159, 14111, 14063, 14015, 13967, 13918, 13870,
-    13822, 13773, 13725, 13676, 13628, 13579, 13530, 13481,
-    13432, 13383, 13334, 13285, 13236, 13187, 13137, 13088,
-    13038, 12988, 12939, 12889, 12839, 12789, 12739, 12689,
-    12639, 12588, 12538, 12487, 12437, 12386, 12335, 12285,
-    12234, 12183, 12132, 12080, 12029, 11978, 11926, 11875,
-    11823, 11771, 11719, 11667, 11615, 11563, 11511, 11458,
-    11406, 11353, 11301, 11248, 11195, 11142, 11089, 11036,
-    10982, 10929, 10875, 10822, 10768, 10714, 10660, 10606,
-    10552, 10497, 10443, 10388, 10333, 10279, 10224, 10168,
-    10113, 10058, 10002,  9947,  9891,  9835,  9779,  9723,
-     9666,  9610,  9553,  9497,  9440,  9383,  9326,  9268,
-     9211,  9153,  9095,  9037,  8979,  8921,  8862,  8804,
-     8745,  8686,  8627,  8568,  8508,  8449,  8389,  8329,
-     8269,  8208,  8148,  8087,  8026,  7965,  7903,  7842,
-     7780,  7718,  7656,  7593,  7531,  7468,  7405,  7341,
-     7278,  7214,  7150,  7086,  7021,  6956,  6891,  6826,
-     6760,  6695,  6628,  6562,  6495,  6428,  6361,  6293,
-     6225,  6157,  6089,  6020,  5950,  5881,  5811,  5741,
-     5670,  5599,  5527,  5456,  5383,  5311,  5237,  5164,
-     5090,  5015,  4941,  4865,  4789,  4713,  4636,  4558,
-     4480,  4401,  4322,  4242,  4162,  4080,  3998,  3916,
-     3832,  3748,  3663,  3577,  3490,  3402,  3314,  3224,
-     3133,  3041,  2948,  2854,  2758,  2661,  2562,  2461,
-     2359,  2255,  2148,  2040,  1929,  1815,  1698,  1577,
-     1452,  1323,  1187,  1045,   894,   731,   550,   339,
-        0,   339,   550,   731,   894,  1045,  1187,  1323,
-     1452,  1577,  1698,  1815,  1929,  2040,  2148,  2255,
-     2359,  2461,  2562,  2661,  2758,  2854,  2948,  3041,
-     3133,  3224,  3314,  3402,  3490,  3577,  3663,  3748,
-     3832,  3916,  3998,  4080,  4162,  4242,  4322,  4401,
-     4480,  4558,  4636,  4713,  4789,  4865,  4941,  5015,
-     5090,  5164,  5237,  5311,  5383,  5456,  5527,  5599,
-     5670,  5741,  5811,  5881,  5950,  6020,  6089,  6157,
-     6225,  6293,  6361,  6428,  6495,  6562,  6628,  6695,
-     6760,  6826,  6891,  6956,  7021,  7086,  7150,  7214,
-     7278,  7341,  7405,  7468,  7531,  7593,  7656,  7718,
-     7780,  7842,  7903,  7965,  8026,  8087,  8148,  8208,
-     8269,  8329,  8389,  8449,  8508,  8568,  8627,  8686,
-     8745,  8804,  8862,  8921,  8979,  9037,  9095,  9153,
-     9211,  9268,  9326,  9383,  9440,  9497,  9553,  9610,
-     9666,  9723,  9779,  9835,  9891,  9947, 10002, 10058,
-    10113, 10168, 10224, 10279, 10333, 10388, 10443, 10497,
-    10552, 10606, 10660, 10714, 10768, 10822, 10875, 10929,
-    10982, 11036, 11089, 11142, 11195, 11248, 11301, 11353,
-    11406, 11458, 11511, 11563, 11615, 11667, 11719, 11771,
-    11823, 11875, 11926, 11978, 12029, 12080, 12132, 12183,
-    12234, 12285, 12335, 12386, 12437, 12487, 12538, 12588,
-    12639, 12689, 12739, 12789, 12839, 12889, 12939, 12988,
-    13038, 13088, 13137, 13187, 13236, 13285, 13334, 13383,
-    13432, 13481, 13530, 13579, 13628, 13676, 13725, 13773,
-    13822, 13870, 13918, 13967, 14015, 14063, 14111, 14159,
-    14206, 14254, 14302, 14350, 14397, 14445, 14492, 14539,
-    14587, 14634, 14681, 14728, 14775, 14822, 14869, 14916,
-    14963, 15010, 15056, 15103, 15149, 15196, 15242, 15289,
-    15335, 15381, 15427, 15474, 15520, 15566, 15612, 15657,
-    15703, 15749, 15795, 15840, 15886, 15932, 15977, 16022,
-    16068, 16113, 16158, 16204, 16249, 16294, 16339, 16384,
-    16384,
-};
-/* clang-format on */
-
 int av1_is_enough_erroradvantage(double best_erroradvantage, int params_cost) {
   return best_erroradvantage < erroradv_tr &&
          best_erroradvantage * params_cost < erroradv_prod_tr;
diff --git a/av1/encoder/global_motion.h b/av1/encoder/global_motion.h
index 793bf92729..de46a0e1f2 100644
--- a/av1/encoder/global_motion.h
+++ b/av1/encoder/global_motion.h
@@ -98,37 +98,6 @@ void av1_compute_feature_segmentation_map(uint8_t *segment_map, int width,
                                           int height, int *inliers,
                                           int num_inliers);
 
-extern const int error_measure_lut[513];
-
-static INLINE int error_measure(int err) {
-  return error_measure_lut[256 + err];
-}
-
-#if CONFIG_AV1_HIGHBITDEPTH
-static INLINE int highbd_error_measure(int err, int bd) {
-  const int b = bd - 8;
-  const int bmask = (1 << b) - 1;
-  const int v = (1 << b);
-
-  // Split error into two parts and do an interpolated table lookup
-  // To compute the table index and interpolation value, we want to calculate
-  // the quotient and remainder of err / 2^b. But it is very important that
-  // the division must round down, and the remainder must be positive,
-  // ie. in the range [0, 2^b).
-  //
-  // In C, the >> and & operators do what we want, but the / and % operators
-  // give the wrong results for negative inputs. So we must use >> and & here.
-  //
-  // For example, if bd == 10 and err == -5, compare the results:
-  //       (-5) >> 2 = -2, (-5) & 3 =  3
-  //   vs. (-5) / 4  = -1, (-5) % 4 = -1
-  const int e1 = err >> b;
-  const int e2 = err & bmask;
-  return error_measure_lut[256 + e1] * (v - e2) +
-         error_measure_lut[257 + e1] * e2;
-}
-#endif  // CONFIG_AV1_HIGHBITDEPTH
-
 int64_t av1_segmented_frame_error(int use_hbd, int bd, const uint8_t *ref,
                                   int ref_stride, uint8_t *dst, int dst_stride,
                                   int p_width, int p_height,