]> git.sesse.net Git - ffmpeg/commitdiff
mlp: check huff_lsbs only when codebook is used
authorJai Luthra <me@jailuthra.in>
Sun, 2 Feb 2020 19:03:00 +0000 (00:33 +0530)
committerPaul B Mahol <onemda@gmail.com>
Tue, 4 Feb 2020 10:19:12 +0000 (11:19 +0100)
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 <me@jailuthra.in>
libavcodec/mlpdec.c
libavcodec/mlpenc.c

index 39c40914cd83fcb601a5ae73678adbb6554dd384..22a6efd63db2fe025f73047223577a0e952d1f87 100644 (file)
@@ -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;
index 8e45da45690d21b43959ca8b10c57b28016a648c..a9501c694f50852f370265bee906c5846b3c81c8 100644 (file)
@@ -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);