Reduce the cpi->scaled_ref_idx array size by 1.

The last element of the cpi->scaled_ref_idx array was not used, so
reduce the array size by 1.

The corresponding libvpx CL is
https://chromium-review.googlesource.com/c/webm/libvpx/+/1265338.

BUG=aomedia:2110
BUG=aomedia:2193

Change-Id: I695f6162bacd07bc021ddda489c12a7f5f5ab4b3
diff --git a/av1/common/enums.h b/av1/common/enums.h
index 30a4463..db9303c 100644
--- a/av1/common/enums.h
+++ b/av1/common/enums.h
@@ -66,8 +66,10 @@
 #define REF_FRAMES_LOG2 3
 #define REF_FRAMES (1 << REF_FRAMES_LOG2)
 
-// 1 scratch frame for the new frame, 7 for scaled references on the encoder.
-#define FRAME_BUFFERS (REF_FRAMES + 1 + 7)
+// REF_FRAMES for the cm->ref_frame_map array, 1 scratch frame for the new
+// frame in cm->new_fb_idx, INTER_REFS_PER_FRAME for scaled references on the
+// encoder in the cpi->scaled_ref_idx array.
+#define FRAME_BUFFERS (REF_FRAMES + 1 + INTER_REFS_PER_FRAME)
 
 // 4 frame filter levels: y plane vertical, y plane horizontal,
 // u plane, and v plane
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 197a8be..93b0bcf 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -3796,7 +3796,7 @@
   AV1_COMMON *cm = &cpi->common;
   int i;
   // TODO(isbs): only refresh the necessary frames, rather than all of them
-  for (i = 0; i < REF_FRAMES; ++i) {
+  for (i = 0; i < INTER_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];
@@ -6753,7 +6753,8 @@
   }
 
   if (cpi->oxcf.pass != 0 || frame_is_intra_only(cm) == 1) {
-    for (i = 0; i < REF_FRAMES; ++i) cpi->scaled_ref_idx[i] = INVALID_IDX;
+    for (i = 0; i < INTER_REFS_PER_FRAME; ++i)
+      cpi->scaled_ref_idx[i] = INVALID_IDX;
   }
 
   cm->using_qmatrix = cpi->oxcf.using_qm;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 682b424..14ce6c1 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -618,10 +618,7 @@
   int cur_poc;  // DebugInfo
 
   unsigned int row_mt;
-  // The first REF_FRAMES - 1 elements of the scaled_ref_idx array are used
-  // for LAST_FRAME..ALTREF_FRAME. The last element of the array is not used.
-  // The array index for ref_frame is ref_frame - 1.
-  int scaled_ref_idx[REF_FRAMES];
+  int scaled_ref_idx[INTER_REFS_PER_FRAME];
   int ref_fb_idx[REF_FRAMES];
   int refresh_fb_idx;  // ref frame buffer index to refresh
 
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index d76c178..3073f6a 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -1258,6 +1258,7 @@
 YV12_BUFFER_CONFIG *av1_get_scaled_ref_frame(const AV1_COMP *cpi,
                                              int ref_frame) {
   const AV1_COMMON *const cm = &cpi->common;
+  assert(ref_frame >= LAST_FRAME && ref_frame <= ALTREF_FRAME);
   const int scaled_idx = cpi->scaled_ref_idx[ref_frame - 1];
   const int ref_idx = get_ref_frame_buf_idx(cpi, ref_frame);
   return (scaled_idx != ref_idx && scaled_idx != INVALID_IDX)