AAC encoder: fix wrong gain sacalefactor being set
authorClaudio Freire <klaussfreire@gmail.com>
Thu, 26 Nov 2015 06:37:29 +0000 (03:37 -0300)
committerClaudio Freire <klaussfreire@gmail.com>
Thu, 26 Nov 2015 06:37:29 +0000 (03:37 -0300)
In some conditions, where the first band was being zeroed
mainly, the wrong global gain scalefactor would be written
to the stream since it's always taken from the first band
regardless of whether it's been marked as zero or not.

So, always make sure it contians something useful.

libavcodec/aaccoder_twoloop.h

index e53257f..5e64d48 100644 (file)
@@ -693,6 +693,9 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
                 if (prev != -1) {
                     int sfdiff = sce->sf_idx[w*16+g] - prev + SCALE_DIFF_ZERO;
                     av_assert1(sfdiff >= 0 && sfdiff <= 2*SCALE_MAX_DIFF);
+                } else if (sce->zeroes[0]) {
+                    /** Set global gain to something useful */
+                    sce->sf_idx[0] = sce->sf_idx[w*16+g];
                 }
                 prev = sce->sf_idx[w*16+g];
             }