[FFmpeg-cvslog] avcodec/apac: stop adding samples if we run out of bits on EOF

Paul B Mahol git at videolan.org
Fri Nov 25 19:34:02 EET 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Nov 25 18:34:21 2022 +0100| [5d7f3b2639923cf054cab917a11ec90ae600ec07] | committer: Paul B Mahol

avcodec/apac: stop adding samples if we run out of bits on EOF

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

 libavcodec/apac.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavcodec/apac.c b/libavcodec/apac.c
index e9f6a0dd88..784abb622c 100644
--- a/libavcodec/apac.c
+++ b/libavcodec/apac.c
@@ -196,10 +196,14 @@ static int apac_decode(AVCodecContext *avctx, AVFrame *frame,
                 return AVERROR_INVALIDDATA;
             }
 
-            if (get_bits_left(gb) < c->block_length * c->bit_length && pkt->size) {
-                c->have_code = 1;
-                s->cur_ch = ch;
-                goto end;
+            if (get_bits_left(gb) < c->block_length * c->bit_length) {
+                if (pkt->size) {
+                    c->have_code = 1;
+                    s->cur_ch = ch;
+                    goto end;
+                } else {
+                    break;
+                }
             }
 
             for (int i = 0; i < c->block_length; i++) {



More information about the ffmpeg-cvslog mailing list