summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-06-22 23:54:51 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-06-23 00:09:09 +0200
commitc69f7299473d9b5a0bdae7dfddf464fefc3d16af (patch)
tree90e82c6dd6ecdcea6d34dbcebd86bf8023838656
parent7e6cf364537e6f4b421318219eb0920b1f115f83 (diff)
ffmpeg: fix reinitializing with threads while flushing
With threads the decoder has a delay and will thus have multiple frames at EOF left in its buffers which will be returned when flushing the decoder. The code that extracts such frames from the decoder at the end does not pull frames from the filtergraph, thus when one of these frames causes the filtergraph to be reinited, the frames still inside the graph at that point re lost This commit changes the flushing to be more similar to normal decoding and 1 frame at a time Fixes hqx fate with threads Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--ffmpeg.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 91e4734e8a..2c17525286 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2147,6 +2147,8 @@ static int output_packet(InputStream *ist, const AVPacket *pkt)
if (!got_output) {
continue;
}
+ if (got_output && !pkt)
+ break;
}
/* handle stream copy */
@@ -2185,7 +2187,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt)
do_streamcopy(ist, ost, pkt);
}
- return 0;
+ return got_output;
}
static void print_sdp(void)
@@ -3315,12 +3317,14 @@ static int process_input(int file_index)
if (exit_on_error)
exit_program(1);
}
- ifile->eof_reached = 1;
for (i = 0; i < ifile->nb_streams; i++) {
ist = input_streams[ifile->ist_index + i];
- if (ist->decoding_needed)
- output_packet(ist, NULL);
+ if (ist->decoding_needed) {
+ ret = output_packet(ist, NULL);
+ if (ret>0)
+ return 0;
+ }
/* mark all outputs that don't go through lavfi as finished */
for (j = 0; j < nb_output_streams; j++) {
@@ -3332,6 +3336,7 @@ static int process_input(int file_index)
}
}
+ ifile->eof_reached = 1;
return AVERROR(EAGAIN);
}