diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-06-27 20:21:25 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-27 21:22:45 +0300 |
commit | a50b00822784f6b098eb634132ad75394f1d26c0 (patch) | |
tree | 6b6ed6e4060c4ca6bc0c3c7ef06a617376a7a36e /ffmpeg.c | |
parent | 93e7b7fb346441dd2bafa8caef4df596f1fae1cb (diff) | |
parent | b114f6d48a06a4dad6882bc83e07463905f004c4 (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.c | 48 |
1 files changed, 27 insertions, 21 deletions
@@ -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; |