From 9addd7499cc06bac2c04f1aa2bd287a1ee1b67f3 Mon Sep 17 00:00:00 2001 From: Wan-Teh Chang Date: Fri, 5 Oct 2018 11:27:01 -0700 Subject: [PATCH] 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 libaom CL is https://aomedia-review.googlesource.com/c/aom/+/72445. Change-Id: I9166f0fbe1a7898c8b611b1535fcc74b4f766997 --- vp9/common/vp9_onyxc_int.h | 7 +++---- vp9/encoder/vp9_encoder.c | 4 ++-- vp9/encoder/vp9_encoder.h | 2 +- vp9/encoder/vp9_rd.c | 1 + 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 45d3b0f82..c94f30b85 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -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) diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index e9dbd0eee..6404fa0cc 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -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) { diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h index b8922dc56..72dbb5341 100644 --- a/vp9/encoder/vp9_encoder.h +++ b/vp9/encoder/vp9_encoder.h @@ -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; diff --git a/vp9/encoder/vp9_rd.c b/vp9/encoder/vp9_rd.c index 2e4a4fe9f..c5319bd87 100644 --- a/vp9/encoder/vp9_rd.c +++ b/vp9/encoder/vp9_rd.c @@ -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; -- 2.40.0