Browse code

ac3dec: fix processing of delta bit allocation information.

The number of dba segments is the coded value + 1.
The coupling dba offset starts at the first coupling band, not at zero.

Justin Ruggles authored on 2011/04/18 01:26:47
Showing 2 changed files
... ...
@@ -192,9 +192,9 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
192 192
 
193 193
     if (dba_mode == DBA_REUSE || dba_mode == DBA_NEW) {
194 194
         int i, seg, delta;
195
-        if (dba_nsegs >= 8)
195
+        if (dba_nsegs > 8)
196 196
             return -1;
197
-        band = 0;
197
+        band = band_start;
198 198
         for (seg = 0; seg < dba_nsegs; seg++) {
199 199
             band += dba_offsets[seg];
200 200
             if (band >= AC3_CRITICAL_BANDS || dba_lengths[seg] > AC3_CRITICAL_BANDS-band)
... ...
@@ -1173,8 +1173,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
1173 1173
         /* channel delta offset, len and bit allocation */
1174 1174
         for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
1175 1175
             if (s->dba_mode[ch] == DBA_NEW) {
1176
-                s->dba_nsegs[ch] = get_bits(gbc, 3);
1177
-                for (seg = 0; seg <= s->dba_nsegs[ch]; seg++) {
1176
+                s->dba_nsegs[ch] = get_bits(gbc, 3) + 1;
1177
+                for (seg = 0; seg < s->dba_nsegs[ch]; seg++) {
1178 1178
                     s->dba_offsets[ch][seg] = get_bits(gbc, 5);
1179 1179
                     s->dba_lengths[ch][seg] = get_bits(gbc, 4);
1180 1180
                     s->dba_values[ch][seg] = get_bits(gbc, 3);