]> granicus.if.org Git - libvpx/commitdiff
Fix the initial references to frame buffers.
authorFrank Galligan <fgalligan@google.com>
Wed, 4 Dec 2013 23:11:00 +0000 (15:11 -0800)
committerFrank Galligan <fgalligan@google.com>
Thu, 5 Dec 2013 00:53:18 +0000 (16:53 -0800)
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

vp9/common/vp9_onyxc_int.h
vp9/decoder/vp9_decodeframe.c
vp9/decoder/vp9_onyxd_if.c

index 751accf02110a4be76ff3453af7087a14598d9c0..6d14128a8cf4fc1134dc9c8b4ea30635d2dd6a37 100644 (file)
@@ -238,8 +238,10 @@ static int get_free_fb(VP9_COMMON *cm) {
 }
 
 static void ref_cnt_fb(int *buf, int *idx, int new_idx) {
-  if (buf[*idx] > 0)
-    buf[*idx]--;
+  const int ref_index = *idx;
+
+  if (ref_index > 0 && buf[ref_index] > 0)
+    buf[ref_index]--;
 
   *idx = new_idx;
 
index 82bace00dee6376136825dfe3be64f9352aeccd8..516aa88cb0656a8df1cc67998e1b7b45632f6c2e 100644 (file)
@@ -687,12 +687,6 @@ static void apply_frame_size(VP9D_COMP *pbi, int width, int height) {
 
   if (cm->width != width || cm->height != height) {
     // 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.
     if (width > cm->width || height > cm->height) {
       // Rescale frame buffers only if they're not big enough already.
index 25fb3d6d2ce0bd01abd691cfac5191912ae15874..4c0cd45a958dc8bf5ba2052914aef58c7b79249a 100644 (file)
@@ -125,6 +125,9 @@ VP9D_PTR vp9_create_decompressor(VP9D_CONFIG *oxcf) {
 
   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)) {
     cm->error.setjmp = 0;
     vp9_remove_decompressor(pbi);