[FFmpeg-devel,v4,4/4] lavc/libdavs2: fix wrong return value

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

Details

Message ID 1541148440-3603-4-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 | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
index 4dbce73..d912dd8 100644
--- a/libavcodec/libdavs2.c
+++ b/libavcodec/libdavs2.c
@@ -147,14 +147,15 @@  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;
-        } else {
-            return AVERROR_EXTERNAL;
+            if (ret == 0 || ret == 1) {
+                *got_frame = ret;
+            }
         }
+        return ret;
     }
 
     cad->packet.data = buf_ptr;
@@ -173,8 +174,13 @@  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 {
+            return ret;
+        }
     }
 
     return buf_size;