]> git.sesse.net Git - ffmpeg/commitdiff
pthread_frame: forward error codes when flushing
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Tue, 30 Jun 2015 19:01:29 +0000 (21:01 +0200)
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Tue, 30 Jun 2015 22:32:21 +0000 (00:32 +0200)
This is the first part of the fix for ticket #4370.

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
libavcodec/pthread_frame.c

index a3fd1fff75828272576f55ca7cba4db1aa8e4384..d48ee33edf1885c56c08d25faea887ca9a97498f 100644 (file)
@@ -454,6 +454,9 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
         *got_picture_ptr = p->got_frame;
         picture->pkt_dts = p->avpkt.dts;
 
+        if (p->result < 0)
+            err = p->result;
+
         /*
          * A later call with avkpt->size == 0 may loop over all threads,
          * including this one, searching for a frame to return before being
@@ -471,6 +474,14 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
 
     fctx->next_finished = finished;
 
+    /*
+     * When no frame was found while flushing, but an error occured in
+     * any thread, return it instead of 0.
+     * Otherwise the error can get lost.
+     */
+    if (!avpkt->size && !*got_picture_ptr)
+        return err;
+
     /* return the size of the consumed packet if no error occurred */
     return (p->result >= 0) ? avpkt->size : p->result;
 }