Commit 9ed616a5 authored by Frank Galligan's avatar Frank Galligan
Browse files

Fix the initial references to frame buffers.

The old code would start in a mixed state, where all the reference
frames were pointing to frame buffer 0, but the reference counts
were 0. This is why we needed special code for the first frame.

Change-Id: I734961012917654ff8c0c8b317aac00ab75ded1a
parent da2da790
...@@ -238,8 +238,10 @@ static int get_free_fb(VP9_COMMON *cm) { ...@@ -238,8 +238,10 @@ static int get_free_fb(VP9_COMMON *cm) {
} }
static void ref_cnt_fb(int *buf, int *idx, int new_idx) { static void ref_cnt_fb(int *buf, int *idx, int new_idx) {
if (buf[*idx] > 0) const int ref_index = *idx;
buf[*idx]--;
if (ref_index > 0 && buf[ref_index] > 0)
buf[ref_index]--;
*idx = new_idx; *idx = new_idx;
......
...@@ -687,12 +687,6 @@ static void apply_frame_size(VP9D_COMP *pbi, int width, int height) { ...@@ -687,12 +687,6 @@ static void apply_frame_size(VP9D_COMP *pbi, int width, int height) {
if (cm->width != width || cm->height != height) { if (cm->width != width || cm->height != height) {
// Change in frame size. // Change in frame size.
if (cm->width == 0 || cm->height == 0) {
// Assign new frame buffer on first call.
cm->new_fb_idx = NUM_YV12_BUFFERS - 1;
cm->fb_idx_ref_cnt[cm->new_fb_idx] = 1;
}
// TODO(agrange) Don't test width/height, check overall size. // TODO(agrange) Don't test width/height, check overall size.
if (width > cm->width || height > cm->height) { if (width > cm->width || height > cm->height) {
// Rescale frame buffers only if they're not big enough already. // Rescale frame buffers only if they're not big enough already.
......
...@@ -125,6 +125,9 @@ VP9D_PTR vp9_create_decompressor(VP9D_CONFIG *oxcf) { ...@@ -125,6 +125,9 @@ VP9D_PTR vp9_create_decompressor(VP9D_CONFIG *oxcf) {
vp9_zero(*pbi); vp9_zero(*pbi);
// Initialize the references to not point to any frame buffers.
memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
if (setjmp(cm->error.jmp)) { if (setjmp(cm->error.jmp)) {
cm->error.setjmp = 0; cm->error.setjmp = 0;
vp9_remove_decompressor(pbi); vp9_remove_decompressor(pbi);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment