Correct a for loop in init_ref_frame_bufs.
The cm->ref_frame_map and pool->frame_bufs arrays are of different sizes
(REF_FRAMES and FRAME_BUFFERS, respectively), so init_ref_frame_bufs()
cannot iterate over these two arrays using the same for loop.
Also simplify the if statement in release_scaled_references().
Change-Id: Ida3d743f73c814915f9655c6a3306191e115d35d
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 47f2a5e..fdc409f 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -3787,9 +3787,8 @@
// TODO(isbs): only refresh the necessary frames, rather than all of them
for (i = 0; i < REF_FRAMES; ++i) {
const int idx = cpi->scaled_ref_idx[i];
- RefCntBuffer *const buf =
- idx != INVALID_IDX ? &cm->buffer_pool->frame_bufs[idx] : NULL;
- if (buf != NULL) {
+ if (idx != INVALID_IDX) {
+ RefCntBuffer *const buf = &cm->buffer_pool->frame_bufs[idx];
--buf->ref_count;
cpi->scaled_ref_idx[i] = INVALID_IDX;
}
@@ -3912,6 +3911,8 @@
cm->new_fb_idx = INVALID_IDX;
for (i = 0; i < REF_FRAMES; ++i) {
cm->ref_frame_map[i] = INVALID_IDX;
+ }
+ for (i = 0; i < FRAME_BUFFERS; ++i) {
pool->frame_bufs[i].ref_count = 0;
}
if (cm->seq_params.force_screen_content_tools) {
@@ -6503,8 +6504,7 @@
if (cpi->rc.is_src_frame_alt_ref) adjust_frame_rate(cpi, source);
// Find a free buffer for the new frame, releasing the reference
- // previously
- // held.
+ // previously held.
if (cm->new_fb_idx != INVALID_IDX) {
--pool->frame_bufs[cm->new_fb_idx].ref_count;
}