Browse code

AAC encoder: fix wrong gain sacalefactor being set

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.

Claudio Freire authored on 2015/11/26 15:37:29
Showing 1 changed files
... ...
@@ -693,6 +693,9 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
693 693
                 if (prev != -1) {
694 694
                     int sfdiff = sce->sf_idx[w*16+g] - prev + SCALE_DIFF_ZERO;
695 695
                     av_assert1(sfdiff >= 0 && sfdiff <= 2*SCALE_MAX_DIFF);
696
+                } else if (sce->zeroes[0]) {
697
+                    /** Set global gain to something useful */
698
+                    sce->sf_idx[0] = sce->sf_idx[w*16+g];
696 699
                 }
697 700
                 prev = sce->sf_idx[w*16+g];
698 701
             }