[FFmpeg-devel,v4,1/4] lavc/libdavs2: fix sequence incomplete output error

Submitted by hwren on Nov. 2, 2018, 8:47 a.m.

Details

Message ID 1541148440-3603-1-git-send-email-hwrenx@126.com
State New
Headers show

Commit Message

hwren Nov. 2, 2018, 8:47 a.m.
Signed-off-by: hwren <hwrenx@126.com>
---
 libavcodec/libdavs2.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Carl Eugen Hoyos Nov. 2, 2018, 12:14 p.m.
2018-11-02 9:47 GMT+01:00, hwren <hwrenx@126.com>:
> Signed-off-by: hwren <hwrenx@126.com>
> ---
>  libavcodec/libdavs2.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
> index cadf995..e463b2e 100644
> --- a/libavcodec/libdavs2.c
> +++ b/libavcodec/libdavs2.c
> @@ -129,7 +129,16 @@ static int davs2_decode_frame(AVCodecContext *avctx,
> void *data,
>      int           ret      = DAVS2_DEFAULT;
>
>      if (!buf_size) {
> -        return 0;
> +        ret = davs2_decoder_flush(cad->decoder, &cad->headerset,
> &cad->out_frame);
> +        if (ret == DAVS2_END) {
> +            return 0;
> +        } else 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;
> +        } else {

> +            return AVERROR_EXTERNAL;

Do I understand correctly that this is not supposed to happen?
If it can happen, please print an error message.

Carl Eugen

Patch hide | download patch | download mbox

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index cadf995..e463b2e 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -129,7 +129,16 @@  static int davs2_decode_frame(AVCodecContext *avctx, void *data,
     int           ret      = DAVS2_DEFAULT;
 
     if (!buf_size) {
-        return 0;
+        ret = davs2_decoder_flush(cad->decoder, &cad->headerset, &cad->out_frame);
+        if (ret == DAVS2_END) {
+            return 0;
+        } else 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;
+        } else {
+            return AVERROR_EXTERNAL;
+        }
     }
 
     cad->packet.data = buf_ptr;