]> granicus.if.org Git - libvpx/commitdiff
vp9-dynamic resize: Fix bug on releasing scaled reference.
authorMarco <marpan@google.com>
Mon, 8 Feb 2016 18:41:13 +0000 (10:41 -0800)
committerMarco <marpan@google.com>
Tue, 9 Feb 2016 19:10:28 +0000 (11:10 -0800)
When the codec frame size is the same as the reference frame size,
release the scaled reference before assigning it a new buf_idx.
Only affects 1 pass non-svc mode, where the scaled references are
release only under certain conditions (to prevent un-needed scaling
of the references every frame).

Modified a unittest that can trigger this bug without this change.

https://code.google.com/p/chromium/issues/detail?id=582598

Change-Id: I9a884e36ebd7608b1641ec2a469e20a4f829cf43

test/resize_test.cc
vp9/encoder/vp9_encoder.c

index 1c9ef228015ea317575cc5fde5b69b08e9e8a319..c5f05f31048eeaa2b9964d1c84494057b8917501 100644 (file)
@@ -127,6 +127,20 @@ unsigned int ScaleForFrameNumber(unsigned int frame, unsigned int val) {
     return val / 2;
   if (frame < 180)
     return val * 3 / 4;
+  if (frame < 190)
+    return val;
+  if (frame < 200)
+    return val * 3 / 4;
+  if (frame < 210)
+    return val / 2;
+  if (frame < 220)
+    return val * 3 / 4;
+  if (frame < 230)
+    return val;
+  if (frame < 240)
+    return val / 2;
+  if (frame < 250)
+    return val * 3 / 4;
   return val;
 }
 
@@ -134,7 +148,7 @@ class ResizingVideoSource : public ::libvpx_test::DummyVideoSource {
  public:
   ResizingVideoSource() {
     SetSize(kInitialWidth, kInitialHeight);
-    limit_ = 200;
+    limit_ = 300;
   }
 
   virtual ~ResizingVideoSource() {}
index 65d5d76a7a660b69f2c499724906569fc62de57f..bd9813a774329ac53b89b9a696eaa24644ae7086 100644 (file)
@@ -2975,8 +2975,19 @@ void vp9_scale_references(VP9_COMP *cpi) {
         }
 #endif  // CONFIG_VP9_HIGHBITDEPTH
       } else {
-        const int buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
-        RefCntBuffer *const buf = &pool->frame_bufs[buf_idx];
+        int buf_idx;
+        RefCntBuffer *buf = NULL;
+        if (cpi->oxcf.pass == 0 && !cpi->use_svc) {
+          // Check for release of scaled reference.
+          buf_idx = cpi->scaled_ref_idx[ref_frame - 1];
+          buf = (buf_idx != INVALID_IDX) ? &pool->frame_bufs[buf_idx] : NULL;
+          if (buf != NULL) {
+            --buf->ref_count;
+            cpi->scaled_ref_idx[ref_frame - 1] = INVALID_IDX;
+          }
+        }
+        buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
+        buf = &pool->frame_bufs[buf_idx];
         buf->buf.y_crop_width = ref->y_crop_width;
         buf->buf.y_crop_height = ref->y_crop_height;
         cpi->scaled_ref_idx[ref_frame - 1] = buf_idx;