When no codebook is used, huff_lsbs can be more than 24 and still decode to 
original values once filters are applied.

Signed-off-by: Jai Luthra <m...@jailuthra.in>
---
 libavcodec/mlpdec.c | 2 +-
 libavcodec/mlpenc.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

Fixes lossless check failures caused with https://lynne.ee/files/sample.flac

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 39c40914cd..22a6efd63d 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -829,7 +829,7 @@ static int read_channel_params(MLPDecodeContext *m, 
unsigned int substr,
     cp->codebook  = get_bits(gbp, 2);
     cp->huff_lsbs = get_bits(gbp, 5);
 
-    if (cp->huff_lsbs > 24) {
+    if (cp->codebook > 0 && cp->huff_lsbs > 24) {
         av_log(m->avctx, AV_LOG_ERROR, "Invalid huff_lsbs.\n");
         cp->huff_lsbs = 0;
         return AVERROR_INVALIDDATA;
diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index af04648097..4e60ffd217 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -987,6 +987,9 @@ static void write_decoding_params(MLPEncodeContext *ctx, 
PutBitContext *pb,
                     put_bits(pb, 1, 0);
                 }
             }
+            if (cp->codebook > 0 && cp->huff_lsbs > 24) {
+                av_log(ctx->avctx, AV_LOG_ERROR, "Invalid Huff LSBs\n");
+            }
 
             put_bits(pb, 2, cp->codebook );
             put_bits(pb, 5, cp->huff_lsbs);
-- 
2.25.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to