[FFmpeg-cvslog] vorbisdec: Accept 0 amplitude_bits

Luca Barbato git at videolan.org
Sun Mar 3 12:11:01 CET 2013


ffmpeg | branch: release/1.1 | Luca Barbato <lu_zero at gentoo.org> | Sun Feb 24 16:56:15 2013 +0100| [c6c4dc69354f72376708ded9bb56af4a58082f1d] | committer: Reinhard Tartler

vorbisdec: Accept 0 amplitude_bits

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.
(cherry picked from commit 23bd9ef4b209c789d5473d75f89a2e411d343d80)

Conflicts:

	libavcodec/vorbisdec.c

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

 libavcodec/vorbisdec.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index cfa89be..884cd5b 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -603,13 +603,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 == 0) {
-                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;
 
@@ -1063,6 +1056,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;



More information about the ffmpeg-cvslog mailing list