aacenc: add support for coding of intensity stereo scalefactor indices

This commit adds support for the coding of intensity stereo scalefactor indices.
It does not do any marking of such bands and as such does no functional changes
to the encoder. It removes any old twoloop specific code for PNS and moves it
into a seperate function which handles setting of scalefactor indices for
PNS and IS bands.

Reviewed-by: Claudio Freire <[email protected]>
Signed-off-by: Michael Niedermayer <[email protected]>
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 897c3a1..3a512ff 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -389,7 +389,7 @@
                                  SingleChannelElement *sce)
 {
     int diff, off_sf = sce->sf_idx[0], off_pns = sce->sf_idx[0] - NOISE_OFFSET;
-    int noise_flag = 1;
+    int off_is = 0, noise_flag = 1;
     int i, w;
 
     for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
@@ -402,6 +402,10 @@
                         put_bits(&s->pb, NOISE_PRE_BITS, diff + NOISE_PRE);
                         continue;
                     }
+                } else if (sce->band_type[w*16 + i] == INTENSITY_BT  ||
+                           sce->band_type[w*16 + i] == INTENSITY_BT2) {
+                    diff = sce->sf_idx[w*16 + i] - off_is;
+                    off_is = sce->sf_idx[w*16 + i];
                 } else {
                     diff = sce->sf_idx[w*16 + i] - off_sf;
                     off_sf = sce->sf_idx[w*16 + i];