]> git.sesse.net Git - ffmpeg/commitdiff
vorbisdec: Accept 0 amplitude_bits
authorLuca Barbato <lu_zero@gentoo.org>
Sun, 24 Feb 2013 15:56:15 +0000 (16:56 +0100)
committerLuca Barbato <lu_zero@gentoo.org>
Mon, 25 Feb 2013 06:34:00 +0000 (07:34 +0100)
The specification does not prevent an encoder to write the amplitude 0
as 0 amplitude_bits.

Our get_bits() implementation might not support a zero sized read
properly, thus the additional branch.

libavcodec/vorbisdec.c

index 7575ee4181917a001f30dbcdff5bffcdd2e318be..0513d972da83b2b5972a99308fda336dd9b82fba 100644 (file)
@@ -602,13 +602,6 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
                 return AVERROR_INVALIDDATA;
             }
             floor_setup->data.t0.amplitude_bits = get_bits(gb,  6);
-            /* zero would result in a div by zero later *
-             * 2^0 - 1 == 0                             */
-            if (!floor_setup->data.t0.amplitude_bits) {
-                av_log(vc->avccontext, AV_LOG_ERROR,
-                       "Floor 0 amplitude bits is 0.\n");
-                return AVERROR_INVALIDDATA;
-            }
             floor_setup->data.t0.amplitude_offset = get_bits(gb, 8);
             floor_setup->data.t0.num_books        = get_bits(gb, 4) + 1;
 
@@ -1059,6 +1052,9 @@ static int vorbis_floor0_decode(vorbis_context *vc,
     unsigned amplitude, book_idx;
     unsigned blockflag = vc->modes[vc->mode_number].blockflag;
 
+    if (!vf->amplitude_bits)
+        return 1;
+
     amplitude = get_bits(&vc->gb, vf->amplitude_bits);
     if (amplitude > 0) {
         float last = 0;