[FFmpeg-cvslog] lavc/libdavs2: output delayed frames

hwrenx git at videolan.org
Mon Dec 3 08:43:32 EET 2018


ffmpeg | branch: master | hwrenx <hwrenx at 126.com> | Mon Dec  3 14:37:42 2018 +0800| [42597d6fa03c679c00ea8b42d6af53efab199eb6] | committer: Steven Liu

lavc/libdavs2: output delayed frames

Signed-off-by: hwrenx <hwrenx at 126.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=42597d6fa03c679c00ea8b42d6af53efab199eb6
---

 libavcodec/libdavs2.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 7fdafdab81..5100f9f7fb 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -125,6 +125,23 @@ static int davs2_dump_frames(AVCodecContext *avctx, davs2_picture_t *pic,
     return 1;
 }
 
+static int send_delayed_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame)
+{
+    DAVS2Context *cad      = avctx->priv_data;
+    int           ret      = DAVS2_DEFAULT;
+
+    ret = davs2_decoder_flush(cad->decoder, &cad->headerset, &cad->out_frame);
+    if (ret == DAVS2_ERROR) {
+        av_log(avctx, AV_LOG_ERROR, "Decoder error: can't flush delayed frame\n");
+        return AVERROR_EXTERNAL;
+    }
+    if (ret == DAVS2_GOT_FRAME) {
+        *got_frame = davs2_dump_frames(avctx, &cad->out_frame, &cad->headerset, ret, frame);
+        davs2_decoder_frame_unref(cad->decoder, &cad->out_frame);
+    }
+    return ret;
+}
+
 static av_cold int davs2_end(AVCodecContext *avctx)
 {
     DAVS2Context *cad = avctx->priv_data;
@@ -147,8 +164,9 @@ static int davs2_decode_frame(AVCodecContext *avctx, void *data,
     AVFrame      *frame    = data;
     int           ret      = DAVS2_DEFAULT;
 
+    /* end of stream, output what is still in the buffers */
     if (!buf_size) {
-        return 0;
+        return send_delayed_frame(avctx, frame, got_frame);
     }
 
     cad->packet.data = buf_ptr;



More information about the ffmpeg-cvslog mailing list