diff mbox series

[FFmpeg-devel] avcodec/alsdec: Fixed decoding error for mono audio files

Message ID 20210507110725.1580-1-michael@niedermayer.cc
State Accepted
Commit f7987ce966aaad841d584988e00454c685bff36f
Headers show
Series [FFmpeg-devel] avcodec/alsdec: Fixed decoding error for mono audio files | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer May 7, 2021, 11:07 a.m. UTC
From: noboru2000 <noboru@ieee.org>

A highest_decoded_channel flag is modified to serve as meant.

Signed-off-by: noboru2000 <noboru@ieee.org>

Regression since: a11aa5f3ed7ee4d2385a7b725d43f6070d790b4c
Fixes: Sin48k16bit1ch.mp4

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/alsdec.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Thilo Borgmann May 7, 2021, 3:05 p.m. UTC | #1
Am 07.05.21 um 13:07 schrieb Michael Niedermayer:
> From: noboru2000 <noboru@ieee.org>
> 
> A highest_decoded_channel flag is modified to serve as meant.
> 
> Signed-off-by: noboru2000 <noboru@ieee.org>
> 
> Regression since: a11aa5f3ed7ee4d2385a7b725d43f6070d790b4c
> Fixes: Sin48k16bit1ch.mp4
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/alsdec.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

LGTM.

-Thilo
diff mbox series

Patch

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 0aada77450..ba873ec53a 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1632,7 +1632,7 @@  static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
     AVCodecContext *avctx    = ctx->avctx;
     GetBitContext *gb = &ctx->gb;
     unsigned int div_blocks[32];                ///< block sizes.
-    unsigned int c;
+    int c;
     unsigned int js_blocks[2];
     uint32_t bs_info = 0;
     int ret;
@@ -1810,14 +1810,17 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
     else
         ctx->cur_frame_length = sconf->frame_length;
 
-    ctx->highest_decoded_channel = 0;
+    ctx->highest_decoded_channel = -1;
     // decode the frame data
     if ((invalid_frame = read_frame_data(ctx, ra_frame)) < 0)
         av_log(ctx->avctx, AV_LOG_WARNING,
                "Reading frame data failed. Skipping RA unit.\n");
 
-    if (ctx->highest_decoded_channel == 0)
+    if (ctx->highest_decoded_channel == -1) {
+        av_log(ctx->avctx, AV_LOG_WARNING,
+               "No channel data decoded.\n");
         return AVERROR_INVALIDDATA;
+    }
 
     ctx->frame_id++;