]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ac3dec.c
cosmetics: Reformat some function declarations.
[ffmpeg] / libavcodec / ac3dec.c
index efeb284b4a86a8b4989d89c224c338a6043af5d9..82091bc6e3f4f52fcc70d7410fcbf70e1322c47f 100644 (file)
@@ -416,17 +416,22 @@ static void calc_transform_coeffs_cpl(AC3DecodeContext *s)
 
     bin = s->start_freq[CPL_CH];
     for (band = 0; band < s->num_cpl_bands; band++) {
+        int band_start = bin;
         int band_end = bin + s->cpl_band_sizes[band];
-        for (; bin < band_end; bin++) {
-            for (ch = 1; ch <= s->fbw_channels; ch++) {
-                if (s->channel_in_cpl[ch]) {
+        for (ch = 1; ch <= s->fbw_channels; ch++) {
+            if (s->channel_in_cpl[ch]) {
+                int64_t cpl_coord = s->cpl_coords[ch][band];
+                for (bin = band_start; bin < band_end; bin++) {
                     s->fixed_coeffs[ch][bin] = ((int64_t)s->fixed_coeffs[CPL_CH][bin] *
-                                                (int64_t)s->cpl_coords[ch][band]) >> 23;
-                    if (ch == 2 && s->phase_flags[band])
-                        s->fixed_coeffs[ch][bin] = -s->fixed_coeffs[ch][bin];
+                                                cpl_coord) >> 23;
+                }
+                if (ch == 2 && s->phase_flags[band]) {
+                    for (bin = band_start; bin < band_end; bin++)
+                        s->fixed_coeffs[2][bin] = -s->fixed_coeffs[2][bin];
                 }
             }
         }
+        bin = band_end;
     }
 }
 
@@ -599,7 +604,6 @@ static void do_rematrixing(AC3DecodeContext *s)
 {
     int bnd, i;
     int end, bndend;
-    int tmp0, tmp1;
 
     end = FFMIN(s->end_freq[1], s->end_freq[2]);
 
@@ -607,10 +611,9 @@ static void do_rematrixing(AC3DecodeContext *s)
         if(s->rematrixing_flags[bnd]) {
             bndend = FFMIN(end, ff_ac3_rematrix_band_tab[bnd+1]);
             for(i=ff_ac3_rematrix_band_tab[bnd]; i<bndend; i++) {
-                tmp0 = s->fixed_coeffs[1][i];
-                tmp1 = s->fixed_coeffs[2][i];
-                s->fixed_coeffs[1][i] = tmp0 + tmp1;
-                s->fixed_coeffs[2][i] = tmp0 - tmp1;
+                int tmp0 = s->fixed_coeffs[1][i];
+                s->fixed_coeffs[1][i] += s->fixed_coeffs[2][i];
+                s->fixed_coeffs[2][i]  = tmp0 - s->fixed_coeffs[2][i];
             }
         }
     }
@@ -937,8 +940,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
             for(bnd=0; bnd<s->num_rematrixing_bands; bnd++)
                 s->rematrixing_flags[bnd] = get_bits1(gbc);
         } else if (!blk) {
-            av_log(s->avctx, AV_LOG_ERROR, "new rematrixing strategy must be present in block 0\n");
-            return -1;
+            av_log(s->avctx, AV_LOG_WARNING, "Warning: new rematrixing strategy not present in block 0\n");
+            s->num_rematrixing_bands = 0;
         }
     }
 
@@ -1164,7 +1167,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
     for(ch=1; ch<=s->channels; ch++) {
         float gain = s->mul_bias / 4194304.0f;
         if(s->channel_mode == AC3_CHMODE_DUALMONO) {
-            gain *= s->dynamic_range[ch-1];
+            gain *= s->dynamic_range[2-ch];
         } else {
             gain *= s->dynamic_range[0];
         }