Commit a50b0082 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'b114f6d4'

* commit 'b114f6d4':
  avconv: factor out flushing the filters

Conflicts:
	ffmpeg.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 93e7b7fb b114f6d4
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment