summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-06-27 19:21:25 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-06-27 20:22:45 +0200
commita50b00822784f6b098eb634132ad75394f1d26c0 (patch)
tree6b6ed6e4060c4ca6bc0c3c7ef06a617376a7a36e /ffmpeg.c
parent93e7b7fb346441dd2bafa8caef4df596f1fae1cb (diff)
parentb114f6d48a06a4dad6882bc83e07463905f004c4 (diff)
Merge commit 'b114f6d48a06a4dad6882bc83e07463905f004c4'
* commit 'b114f6d48a06a4dad6882bc83e07463905f004c4': avconv: factor out flushing the filters Conflicts: ffmpeg.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 8b3f34723e..3cb1f6207f 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1873,17 +1873,8 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
if (*got_output || ret<0 || pkt->size)
decode_error_stat[ret<0] ++;
- if (!*got_output || ret < 0) {
- if (!pkt->size) {
- for (i = 0; i < ist->nb_filters; i++)
-#if 1
- av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0);
-#else
- av_buffersrc_add_frame(ist->filters[i]->filter, NULL);
-#endif
- }
+ if (!*got_output || ret < 0)
return ret;
- }
ist->samples_decoded += decoded_frame->nb_samples;
ist->frames_decoded++;
@@ -2032,17 +2023,8 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
}
}
- if (!*got_output || ret < 0) {
- if (!pkt->size) {
- for (i = 0; i < ist->nb_filters; i++)
-#if 1
- av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0);
-#else
- av_buffersrc_add_frame(ist->filters[i]->filter, NULL);
-#endif
- }
+ if (!*got_output || ret < 0)
return ret;
- }
if(ist->top_field_first>=0)
decoded_frame->top_field_first = ist->top_field_first;
@@ -2187,6 +2169,21 @@ out:
return ret;
}
+static int send_filter_eof(InputStream *ist)
+{
+ int i, ret;
+ for (i = 0; i < ist->nb_filters; i++) {
+#if 1
+ ret = av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0);
+#else
+ ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL);
+#endif
+ if (ret < 0)
+ return ret;
+ }
+ return 0;
+}
+
/* pkt = NULL means EOF (needed to flush decoder buffers) */
static int process_input_packet(InputStream *ist, const AVPacket *pkt)
{
@@ -2271,7 +2268,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt)
return -1;
}
- if (ret < 0)
+ if (ret < 0 && !(!pkt && ist->decoding_needed))
return ret;
avpkt.dts=
@@ -2291,6 +2288,15 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt)
break;
}
+ /* after flushing, send an EOF on all the filter inputs attached to the stream */
+ if (!pkt && ist->decoding_needed && !got_output) {
+ int ret = send_filter_eof(ist);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n");
+ exit_program(1);
+ }
+ }
+
/* handle stream copy */
if (!ist->decoding_needed) {
ist->dts = ist->next_dts;