aom: Report bad tile dims in av1_get_uniform_tile_size

From 31df8e1cff75de744956084307c59aa06f555302 Mon Sep 17 00:00:00 2001
From: Wan-Teh Chang <[EMAIL REDACTED]>
Date: Thu, 29 Feb 2024 16:58:13 -0800
Subject: [PATCH] Report bad tile dims in av1_get_uniform_tile_size

Replace assertions with error reporting in av1_get_uniform_tile_size()
if not all tiles have the same dimensions.

Bug: oss-fuzz:67058
Change-Id: Ic18076430b5600242fcea7a2a9043672fc2abae4
---
 av1/common/tile_common.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/av1/common/tile_common.c b/av1/common/tile_common.c
index b9cd20583..31ab9c8c5 100644
--- a/av1/common/tile_common.c
+++ b/av1/common/tile_common.c
@@ -187,7 +187,12 @@ void av1_get_uniform_tile_size(const AV1_COMMON *cm, int *w, int *h) {
       const int tile_width_sb =
           tiles->col_start_sb[i + 1] - tiles->col_start_sb[i];
       const int tile_w = tile_width_sb * cm->seq_params->mib_size;
-      assert(i == 0 || tile_w == *w);  // ensure all tiles have same dimension
+      // ensure all tiles have same dimension
+      if (i != 0 && tile_w != *w) {
+        aom_internal_error(cm->error, AOM_CODEC_UNSUP_BITSTREAM,
+                           "tile %d does not have the same width: %d != %d", i,
+                           tile_w, *w);
+      }
       *w = tile_w;
     }
 
@@ -195,7 +200,12 @@ void av1_get_uniform_tile_size(const AV1_COMMON *cm, int *w, int *h) {
       const int tile_height_sb =
           tiles->row_start_sb[i + 1] - tiles->row_start_sb[i];
       const int tile_h = tile_height_sb * cm->seq_params->mib_size;
-      assert(i == 0 || tile_h == *h);  // ensure all tiles have same dimension
+      // ensure all tiles have same dimension
+      if (i != 0 && tile_h != *h) {
+        aom_internal_error(cm->error, AOM_CODEC_UNSUP_BITSTREAM,
+                           "tile %d does not have the same height: %d != %d", i,
+                           tile_h, *h);
+      }
       *h = tile_h;
     }
   }