# HG changeset patch # User superdump # Date 1221753771 0 # Node ID 13ee9bb8572174d045764869f94f0c9195a172fa # Parent 20dd4e5e5aa69f1b86dadaf00f0e0acfe1be0096 Zero 'idx' for each iteration of the coupling gain loop and as it is only used within this loop, we can move its declaration there too. This fixes bitstream desync when decoding streams containing CCEs. Based on a patch by Alex Converse (alex converse gmail com) diff -r 20dd4e5e5aa6 -r 13ee9bb85721 aac.c --- a/aac.c Thu Sep 18 15:48:37 2008 +0000 +++ b/aac.c Thu Sep 18 16:02:51 2008 +0000 @@ -950,7 +950,7 @@ */ static int decode_cce(AACContext * ac, GetBitContext * gb, ChannelElement * che) { int num_gain = 0; - int c, g, sfb, ret, idx = 0; + int c, g, sfb, ret; int sign; float scale; SingleChannelElement * sce = &che->ch[0]; @@ -985,6 +985,7 @@ return ret; for (c = 0; c < num_gain; c++) { + int idx = 0; int cge = 1; int gain = 0; float gain_cache = 1.;