h264: only ref cur_pic in update_thread_context if it is initialized
authorAnton Khirnov <anton@khirnov.net>
Thu, 12 Feb 2015 11:26:58 +0000 (12:26 +0100)
committerAnton Khirnov <anton@khirnov.net>
Sat, 21 Feb 2015 08:34:17 +0000 (09:34 +0100)
It may be empty if the previous thread's decode call did not contain a
valid frame.

(cherry picked from commit 0dea4c77ccf5956561bb8991311b3d834bb5fa40)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavcodec/h264_slice.c

index 1ee7a3d..e47a448 100644 (file)
@@ -589,8 +589,11 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
 
     h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1);
     ff_h264_unref_picture(h, &h->cur_pic);
-    if ((ret = ff_h264_ref_picture(h, &h->cur_pic, &h1->cur_pic)) < 0)
-        return ret;
+    if (h1->cur_pic.f.buf[0]) {
+        ret = ff_h264_ref_picture(h, &h->cur_pic, &h1->cur_pic);
+        if (ret < 0)
+            return ret;
+    }
 
     h->workaround_bugs = h1->workaround_bugs;
     h->low_delay       = h1->low_delay;