Merge commit 'b114f6d48a06a4dad6882bc83e07463905f004c4'

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

Conflicts:
	ffmpeg.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-06-27 19:21:25 +02:00
commit a50b008227
1 changed files with 27 additions and 21 deletions

View File

@ -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;