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

Submitted by hwren on Nov. 2, 2018, 1:30 p.m.

Details

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

Commit Message

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

Comments

hwren Nov. 15, 2018, 7:48 a.m.
Any comments on these patches?








At 2018-11-02 21:30:08, "hwren" <hwrenx@126.com> wrote:
>Signed-off-by: hwren <hwrenx@126.com>
>---
> libavcodec/libdavs2.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
>diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
>index cadf995..e36bfed 100644
>--- a/libavcodec/libdavs2.c
>+++ b/libavcodec/libdavs2.c
>@@ -129,7 +129,17 @@ 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 {
>+            av_log(avctx, AV_LOG_ERROR, "Decoder error: dump frames failed\n");
>+            return AVERROR_EXTERNAL;
>+        }
>     }
> 
>     cad->packet.data = buf_ptr;
>-- 
>2.7.4
Mark Thompson Nov. 18, 2018, 6:59 p.m.
On 02/11/18 13:30, hwren wrote:
> Signed-off-by: hwren <hwrenx@126.com>
> ---
>  libavcodec/libdavs2.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
> index cadf995..e36bfed 100644
> --- a/libavcodec/libdavs2.c
> +++ b/libavcodec/libdavs2.c
> @@ -129,7 +129,17 @@ 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;

This returns a library-internal value to the user, which doesn't look right.

> +        } else {
> +            av_log(avctx, AV_LOG_ERROR, "Decoder error: dump frames failed\n");
> +            return AVERROR_EXTERNAL;
> +        }
>      }
>  
>      cad->packet.data = buf_ptr;
> 
On 02/11/18 13:30, hwren wrote:
> Signed-off-by: hwren <hwrenx@126.com>
> ---
>  libavcodec/libdavs2.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
> index 3e59d41..6e4bd50 100644
> --- a/libavcodec/libdavs2.c
> +++ b/libavcodec/libdavs2.c
> @@ -147,15 +147,17 @@ static int davs2_decode_frame(AVCodecContext *avctx, void *data,
>      if (!buf_size) {
>          ret = davs2_decoder_flush(cad->decoder, &cad->headerset, &cad->out_frame);
>          if (ret == DAVS2_END) {
> -            return 0;
> +            ret = 0;
>          } else if (ret == DAVS2_GOT_FRAME) {
> -            *got_frame = davs2_dump_frames(avctx, &cad->out_frame, &cad->headerset, ret, frame);
> +            ret = davs2_dump_frames(avctx, &cad->out_frame, &cad->headerset, ret, frame);
>              davs2_decoder_frame_unref(cad->decoder, &cad->out_frame);
> -            return ret;
> +            if (ret == 0 || ret == 1) {
> +                *got_frame = ret;
> +            }
>          } else {
> -            av_log(avctx, AV_LOG_ERROR, "Decoder error: dump frames failed\n");
> -            return AVERROR_EXTERNAL;
> +            av_log(avctx, AV_LOG_ERROR, "Decoder error: flush frames failed\n");

So does this one.

>          }
> +        return ret;
>      }
>  
>      cad->packet.data = buf_ptr;
> @@ -174,8 +176,14 @@ static int davs2_decode_frame(AVCodecContext *avctx, void *data,
>      ret = davs2_decoder_recv_frame(cad->decoder, &cad->headerset, &cad->out_frame);
>  
>      if (ret != DAVS2_DEFAULT) {
> -        *got_frame = davs2_dump_frames(avctx, &cad->out_frame, &cad->headerset, ret, frame);
> +        ret = davs2_dump_frames(avctx, &cad->out_frame, &cad->headerset, ret, frame);
>          davs2_decoder_frame_unref(cad->decoder, &cad->out_frame);
> +        if (ret == 0 || ret == 1) {
> +            *got_frame = ret;
> +        } else {
> +            av_log(avctx, AV_LOG_ERROR, "Decoder error: dump frames failed\n");
> +            return ret;
> +        }
>      }
>  
>      return buf_size;
> 

Patches 2 and 3 applied.

Thanks,

- Mark

Patch hide | download patch | download mbox

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index cadf995..e36bfed 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -129,7 +129,17 @@  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 {
+            av_log(avctx, AV_LOG_ERROR, "Decoder error: dump frames failed\n");
+            return AVERROR_EXTERNAL;
+        }
     }
 
     cad->packet.data = buf_ptr;