[FFmpeg-devel] [PATCH] ffmpeg: send EOF to lavfi even if flushing the decoder fails.

Nicolas George nicolas.george at normalesup.org
Thu Aug 9 16:17:47 CEST 2012


Based on commpt f154ef1 by Anton Khirnov.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 ffmpeg.c |   21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index b2963bb..3a33ef8 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1413,20 +1413,17 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
     update_benchmark(NULL);
     ret = avcodec_decode_audio4(avctx, decoded_frame, got_output, pkt);
     update_benchmark("decode_audio %d.%d", ist->file_index, ist->st->index);
-    if (ret < 0) {
-        return ret;
-    }
     if (avctx->sample_rate <= 0) {
         av_log(avctx, AV_LOG_ERROR, "Sample rate %d invalid\n", avctx->sample_rate);
-        return AVERROR_INVALIDDATA;
+        ret = AVERROR_INVALIDDATA;
     }
 
-    if (!*got_output) {
-        /* no audio frame */
-        if (!pkt->size)
+    if (!*got_output || ret < 0) {
+        if (!pkt->size) {
             for (i = 0; i < ist->nb_filters; i++)
                 av_buffersrc_add_ref(ist->filters[i]->filter, NULL,
                                      AV_BUFFERSRC_FLAG_NO_COPY);
+        }
         return ret;
     }
 
@@ -1541,18 +1538,16 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
     ret = avcodec_decode_video2(ist->st->codec,
                                 decoded_frame, got_output, pkt);
     update_benchmark("decode_video %d.%d", ist->file_index, ist->st->index);
-    if (ret < 0)
-        return ret;
 
-    quality = same_quant ? decoded_frame->quality : 0;
-    if (!*got_output) {
-        /* no picture yet */
-        if (!pkt->size)
+    if (!*got_output || ret < 0) {
+        if (!pkt->size) {
             for (i = 0; i < ist->nb_filters; i++)
                 av_buffersrc_add_ref(ist->filters[i]->filter, NULL, AV_BUFFERSRC_FLAG_NO_COPY);
+        }
         return ret;
     }
 
+    quality = same_quant ? decoded_frame->quality : 0;
     if(ist->top_field_first>=0)
         decoded_frame->top_field_first = ist->top_field_first;
 
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list