[FFmpeg-cvslog] pthread_frame: don't return stale error codes after flush

wm4 git at videolan.org
Thu Apr 6 18:52:59 EEST 2017


ffmpeg | branch: master | wm4 <nfxjfg at googlemail.com> | Thu Apr  6 17:35:32 2017 +0200| [15a23a83326d70e470a6b5c8d71e55257bffd97b] | committer: wm4

pthread_frame: don't return stale error codes after flush

Consider the following sequence of events:

- open a codec without AV_CODEC_CAP_DELAY
- decode call fails with an error
- ff_thread_flush() is called
- drain packet is sent

Then the last step would make ff_thread_decode_frame() return an error,
because p->result can still be set to an error value. This is because
submit_packet returns immediately if AV_CODEC_CAP_DELAY is not set, and
no worker thread gets the chance to reset p->result, yet its value is
trusted by ff_thread_decode_frame().

Fix this by clearing the error fields on flush.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=15a23a83326d70e470a6b5c8d71e55257bffd97b
---

 libavcodec/pthread_frame.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index c246c2f..aaf576d 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -861,6 +861,7 @@ void ff_thread_flush(AVCodecContext *avctx)
         // Make sure decode flush calls with size=0 won't return old frames
         p->got_frame = 0;
         av_frame_unref(p->frame);
+        p->result = 0;
 
         release_delayed_buffers(p);
 



More information about the ffmpeg-cvslog mailing list