]> granicus.if.org Git - libvpx/commitdiff
Fixed a few sanity checks.
authorZoe Liu <zoeliu@google.com>
Tue, 10 Nov 2015 01:21:11 +0000 (17:21 -0800)
committerZoe Liu <zoeliu@google.com>
Wed, 11 Nov 2015 18:38:17 +0000 (10:38 -0800)
Change-Id: Ieec4a7be5945dc6de192e2d8292ab978baf47f53

vp9/decoder/vp9_decoder.c
vp9/decoder/vp9_decoder.h

index 4e88819b1aeaaa671621e37414a09deda2a16299..f5da07ea02be60202825ffb924ae67258322e3cc 100644 (file)
@@ -243,7 +243,7 @@ static void swap_frame_buffers(VP9Decoder *pbi) {
     decrease_ref_count(old_idx, frame_bufs, pool);
 
     // Release the reference frame in reference map.
-    if ((mask & 1) && old_idx >= 0) {
+    if (mask & 1) {
       decrease_ref_count(old_idx, frame_bufs, pool);
     }
     cm->ref_frame_map[ref_index] = cm->next_ref_frame_map[ref_index];
@@ -350,7 +350,7 @@ int vp9_receive_compressed_data(VP9Decoder *pbi,
         decrease_ref_count(old_idx, frame_bufs, pool);
 
         // Release the reference frame in reference map.
-        if ((mask & 1) && old_idx >= 0) {
+        if (mask & 1) {
           decrease_ref_count(old_idx, frame_bufs, pool);
         }
         ++ref_index;
index 4a5188f8f95ee2056b22a67e5865531d072b64b8..afa400941d9cd0736a11267795dac7eb6c3e93c6 100644 (file)
@@ -128,7 +128,7 @@ void vp9_decoder_remove(struct VP9Decoder *pbi);
 
 static INLINE void decrease_ref_count(int idx, RefCntBuffer *const frame_bufs,
                                       BufferPool *const pool) {
-  if (idx >= 0) {
+  if (idx >= 0 && frame_bufs[idx].ref_count > 0) {
     --frame_bufs[idx].ref_count;
     // A worker may only get a free framebuffer index when calling get_free_fb.
     // But the private buffer is not set up until finish decoding header.