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.
... | ... |
@@ -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 |
} |