Commit 813529e457 for aom

commit 813529e457d6e8c10cf3cf55de69a6e81b2f7ae4
Author: Wan-Teh Chang <wtc@google.com>
Date:   Fri Feb 27 15:55:31 2026 -0800

    Move frame_size_limit from AV1_COMMON to AV1Decoder

    frame_size_limit belongs in AV1Decoder because it is only used by the
    decoder. This requires passing frame_size_limit to several functions in
    av1/decoder/decodeframe.c.

    A cleanup for the CL
    https://aomedia-review.git.corp.google.com/c/aom/+/207461.

    Bug: 485932002
    Change-Id: Idbd3dc313f8dd1cbb5eac2cecbf689494f6635e4

diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c
index f880df8aa9..50baa4803c 100644
--- a/av1/av1_dx_iface.c
+++ b/av1/av1_dx_iface.c
@@ -488,14 +488,13 @@ static aom_codec_err_t init_decoder(aom_codec_alg_priv_t *ctx) {
   // thread or loopfilter thread.
   frame_worker_data->pbi->max_threads = ctx->cfg.threads;
   frame_worker_data->pbi->inv_tile_order = ctx->invert_tile_order;
-  frame_worker_data->pbi->common.decode_frame_size_limit =
-      ctx->frame_size_limit;
   frame_worker_data->pbi->common.tiles.large_scale = ctx->tile_mode;
   frame_worker_data->pbi->is_annexb = ctx->is_annexb;
   frame_worker_data->pbi->dec_tile_row = ctx->decode_tile_row;
   frame_worker_data->pbi->dec_tile_col = ctx->decode_tile_col;
   frame_worker_data->pbi->operating_point = ctx->operating_point;
   frame_worker_data->pbi->output_all_layers = ctx->output_all_layers;
+  frame_worker_data->pbi->frame_size_limit = ctx->frame_size_limit;
   frame_worker_data->pbi->ext_tile_debug = ctx->ext_tile_debug;
   frame_worker_data->pbi->row_mt = ctx->row_mt;
   frame_worker_data->pbi->is_fwd_kf_present = 0;
diff --git a/av1/common/av1_common_int.h b/av1/common/av1_common_int.h
index b3edab0d66..715fe2ced7 100644
--- a/av1/common/av1_common_int.h
+++ b/av1/common/av1_common_int.h
@@ -821,13 +821,6 @@ typedef struct AV1Common {
    */
   uint8_t superres_scale_denominator;

-  /*!
-   * If nonzero, the maximum frame size (width * height). 0 means unlimited.
-   * Note: Only used by the decoder. Defined in the AV1_COMMON struct for
-   * convenience.
-   */
-  unsigned int decode_frame_size_limit;
-
   /*!
    * buffer_removal_times[op_num] specifies the frame removal time in units of
    * DecCT clock ticks counted from the removal time of the last random access
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 32974c215d..b6ee3ace02 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1949,19 +1949,18 @@ static inline void setup_superres(AV1_COMMON *const cm,
   }
 }

-static inline void resize_context_buffers(AV1_COMMON *cm, int width,
-                                          int height) {
+static inline void resize_context_buffers(AV1_COMMON *cm, int width, int height,
+                                          unsigned int frame_size_limit) {
 #if CONFIG_SIZE_LIMIT
   if (width > DECODE_WIDTH_LIMIT || height > DECODE_HEIGHT_LIMIT)
     aom_internal_error(cm->error, AOM_CODEC_CORRUPT_FRAME,
                        "Dimensions of %dx%d beyond allowed size of %dx%d.",
                        width, height, DECODE_WIDTH_LIMIT, DECODE_HEIGHT_LIMIT);
 #endif
-  if (cm->decode_frame_size_limit &&
-      (uint64_t)width * height > cm->decode_frame_size_limit) {
+  if (frame_size_limit && (uint64_t)width * height > frame_size_limit) {
     aom_internal_error(cm->error, AOM_CODEC_CORRUPT_FRAME,
                        "Dimensions of %dx%d beyond allowed size of %u.", width,
-                       height, cm->decode_frame_size_limit);
+                       height, frame_size_limit);
   }
   if (cm->width != width || cm->height != height) {
     const int new_mi_rows = CEIL_POWER_OF_TWO(height, MI_SIZE_LOG2);
@@ -2025,6 +2024,7 @@ static inline void setup_buffer_pool(AV1_COMMON *cm) {

 static inline void setup_frame_size(AV1_COMMON *cm,
                                     int frame_size_override_flag,
+                                    unsigned int frame_size_limit,
                                     struct aom_read_bit_buffer *rb) {
   const SequenceHeader *const seq_params = cm->seq_params;
   int width, height;
@@ -2044,7 +2044,7 @@ static inline void setup_frame_size(AV1_COMMON *cm,
   }

   setup_superres(cm, rb, &width, &height);
-  resize_context_buffers(cm, width, height);
+  resize_context_buffers(cm, width, height, frame_size_limit);
   setup_render_size(cm, rb);
   setup_buffer_pool(cm);
 }
@@ -2063,6 +2063,7 @@ static inline int valid_ref_frame_img_fmt(aom_bit_depth_t ref_bit_depth,
 }

 static inline void setup_frame_size_with_refs(AV1_COMMON *cm,
+                                              unsigned int frame_size_limit,
                                               struct aom_read_bit_buffer *rb) {
   int width, height;
   int found = 0;
@@ -2085,7 +2086,7 @@ static inline void setup_frame_size_with_refs(AV1_COMMON *cm,
         cm->render_width = buf->render_width;
         cm->render_height = buf->render_height;
         setup_superres(cm, rb, &width, &height);
-        resize_context_buffers(cm, width, height);
+        resize_context_buffers(cm, width, height, frame_size_limit);
         found = 1;
         break;
       }
@@ -2099,7 +2100,7 @@ static inline void setup_frame_size_with_refs(AV1_COMMON *cm,

     read_frame_size(rb, num_bits_width, num_bits_height, &width, &height);
     setup_superres(cm, rb, &width, &height);
-    resize_context_buffers(cm, width, height);
+    resize_context_buffers(cm, width, height, frame_size_limit);
     setup_render_size(cm, rb);
   }

@@ -4927,7 +4928,7 @@ static int read_uncompressed_header(AV1Decoder *pbi,
   }

   if (current_frame->frame_type == KEY_FRAME) {
-    setup_frame_size(cm, frame_size_override_flag, rb);
+    setup_frame_size(cm, frame_size_override_flag, pbi->frame_size_limit, rb);

     if (features->allow_screen_content_tools && !av1_superres_scaled(cm))
       features->allow_intrabc = aom_rb_read_bit(rb);
@@ -4939,7 +4940,7 @@ static int read_uncompressed_header(AV1Decoder *pbi,
     if (current_frame->frame_type == INTRA_ONLY_FRAME) {
       cm->cur_frame->film_grain_params_present =
           seq_params->film_grain_params_present;
-      setup_frame_size(cm, frame_size_override_flag, rb);
+      setup_frame_size(cm, frame_size_override_flag, pbi->frame_size_limit, rb);
       if (features->allow_screen_content_tools && !av1_superres_scaled(cm))
         features->allow_intrabc = aom_rb_read_bit(rb);

@@ -5016,9 +5017,10 @@ static int read_uncompressed_header(AV1Decoder *pbi,
       }

       if (!features->error_resilient_mode && frame_size_override_flag) {
-        setup_frame_size_with_refs(cm, rb);
+        setup_frame_size_with_refs(cm, pbi->frame_size_limit, rb);
       } else {
-        setup_frame_size(cm, frame_size_override_flag, rb);
+        setup_frame_size(cm, frame_size_override_flag, pbi->frame_size_limit,
+                         rb);
       }

       if (features->cur_frame_force_integer_mv) {
diff --git a/av1/decoder/decoder.h b/av1/decoder/decoder.h
index 006c1c4d39..02ad429618 100644
--- a/av1/decoder/decoder.h
+++ b/av1/decoder/decoder.h
@@ -339,6 +339,8 @@ typedef struct AV1Decoder {
 #endif
   int operating_point;
   int current_operating_point;
+  // If nonzero, the maximum frame size (width * height). 0 means unlimited.
+  unsigned int frame_size_limit;
   int seen_frame_header;
   // The expected start_tile (tg_start syntax element) of the next tile group.
   int next_start_tile;