Reduce the cpi->scaled_ref_idx array size by 1.
authorWan-Teh Chang <wtc@google.com>
Fri, 5 Oct 2018 18:27:01 +0000 (11:27 -0700)
committerWan-Teh Chang <wtc@google.com>
Mon, 8 Oct 2018 20:52:27 +0000 (13:52 -0700)
The last element of the cpi->scaled_ref_idx array was not used, so
reduce the array size by 1.

The corresponding libaom CL is
https://aomedia-review.googlesource.com/c/aom/+/72445.

Change-Id: I9166f0fbe1a7898c8b611b1535fcc74b4f766997

vp9/common/vp9_onyxc_int.h
vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_encoder.h
vp9/encoder/vp9_rd.c

index 45d3b0f..c94f30b 100644 (file)
@@ -37,10 +37,9 @@ extern "C" {
 #define REF_FRAMES_LOG2 3
 #define REF_FRAMES (1 << REF_FRAMES_LOG2)
 
-// 1 scratch frame for the new frame, 3 for scaled references on the encoder.
-// TODO(jkoleszar): These 3 extra references could probably come from the
-// normal reference pool.
-#define FRAME_BUFFERS (REF_FRAMES + 4)
+// 1 scratch frame for the new frame, REFS_PER_FRAME for scaled references on
+// the encoder.
+#define FRAME_BUFFERS (REF_FRAMES + 1 + REFS_PER_FRAME)
 
 #define FRAME_CONTEXTS_LOG2 2
 #define FRAME_CONTEXTS (1 << FRAME_CONTEXTS_LOG2)
index e9dbd0e..6404fa0 100644 (file)
@@ -3260,7 +3260,7 @@ static void release_scaled_references(VP9_COMP *cpi) {
       }
     }
   } else {
-    for (i = 0; i < MAX_REF_FRAMES; ++i) {
+    for (i = 0; i < REFS_PER_FRAME; ++i) {
       const int idx = cpi->scaled_ref_idx[i];
       if (idx != INVALID_IDX) {
         RefCntBuffer *const buf = &cm->buffer_pool->frame_bufs[idx];
@@ -6342,7 +6342,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
     level_rc_framerate(cpi, arf_src_index);
 
   if (cpi->oxcf.pass != 0 || cpi->use_svc || frame_is_intra_only(cm) == 1) {
-    for (i = 0; i < MAX_REF_FRAMES; ++i) cpi->scaled_ref_idx[i] = INVALID_IDX;
+    for (i = 0; i < REFS_PER_FRAME; ++i) cpi->scaled_ref_idx[i] = INVALID_IDX;
   }
 
   if (arf_src_index && cpi->sf.enable_tpl_model) {
index b8922dc..72dbb53 100644 (file)
@@ -526,7 +526,7 @@ typedef struct VP9_COMP {
   // For a still frame, this flag is set to 1 to skip partition search.
   int partition_search_skippable_frame;
 
-  int scaled_ref_idx[MAX_REF_FRAMES];
+  int scaled_ref_idx[REFS_PER_FRAME];
   int lst_fb_idx;
   int gld_fb_idx;
   int alt_fb_idx;
index 2e4a4fe..c5319bd 100644 (file)
@@ -631,6 +631,7 @@ YV12_BUFFER_CONFIG *vp9_get_scaled_ref_frame(const VP9_COMP *cpi,
   const VP9_COMMON *const cm = &cpi->common;
   const int scaled_idx = cpi->scaled_ref_idx[ref_frame - 1];
   const int ref_idx = get_ref_frame_buf_idx(cpi, ref_frame);
+  assert(ref_frame >= LAST_FRAME && ref_frame <= ALTREF_FRAME);
   return (scaled_idx != ref_idx && scaled_idx != INVALID_IDX)
              ? &cm->buffer_pool->frame_bufs[scaled_idx].buf
              : NULL;