summaryrefslogtreecommitdiff
path: root/libavcodec/pthread_frame.c
diff options
context:
space:
mode:
authorMuhammad Faiz <mfcc64@gmail.com>2017-04-28 17:19:13 +0700
committerMuhammad Faiz <mfcc64@gmail.com>2017-04-30 05:48:21 +0700
commitd535e0c14004a15bb38ea288fa9a4f2e27d26f6b (patch)
treeef4a714e4d1bdd2ec9839eb36a79e96290756ebf /libavcodec/pthread_frame.c
parent399c7ab9c6bc9e683c5a60b34d50290ae563e2f1 (diff)
avcodec/pthread_frame, decode: allow errors to happen on draining
So, all frames and errors are correctly reported in order. Also limit the numbers of error during draining to prevent infinite loop. This fix fate failure with THREADS>=4: make fate-h264-attachment-631 THREADS=4 This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f. Suggested-by: wm4, Ronald S. Bultje, Marton Balint Reviewed-by: w4 <nfxjfg@googlemail.com> Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com> Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
Diffstat (limited to 'libavcodec/pthread_frame.c')
-rw-r--r--libavcodec/pthread_frame.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 13d682842d..363b139f71 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -509,8 +509,8 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
/*
* Return the next available frame from the oldest thread.
* If we're at the end of the stream, then we have to skip threads that
- * didn't output a frame, because we don't want to accidentally signal
- * EOF (avpkt->size == 0 && *got_picture_ptr == 0).
+ * didn't output a frame/error, because we don't want to accidentally signal
+ * EOF (avpkt->size == 0 && *got_picture_ptr == 0 && err >= 0).
*/
do {
@@ -526,20 +526,19 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
av_frame_move_ref(picture, p->frame);
*got_picture_ptr = p->got_frame;
picture->pkt_dts = p->avpkt.dts;
-
- if (p->result < 0)
- err = p->result;
+ 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
+ * including this one, searching for a frame/error to return before being
* stopped by the "finished != fctx->next_finished" condition.
- * Make sure we don't mistakenly return the same frame again.
+ * Make sure we don't mistakenly return the same frame/error again.
*/
p->got_frame = 0;
+ p->result = 0;
if (finished >= avctx->thread_count) finished = 0;
- } while (!avpkt->size && !*got_picture_ptr && finished != fctx->next_finished);
+ } while (!avpkt->size && !*got_picture_ptr && err >= 0 && finished != fctx->next_finished);
update_context_from_thread(avctx, p->avctx, 1);