CHANGES FOR 980217 (config.c & monopred.c)
Warning message added to predictor reset handling

diff -r1.3 config.c
187a188,189
>         else
>             p->ele_is_cpe[i] = 0;
448c450
<       cidx = FChans + SChans + BChans + mip->nfch;
---
>       cidx = FChans + SChans + BChans + mip->nlch;
625a628
>             if (!s->present) continue;



CHANGES FOR 980212
changed SSR_Profile enum in interface.h from 3 to 2


CHANGES FOR 971130
< is 971125
> is 971130
44c44
<     {fhg_short,	fhg_short},
---
>     {fhg_short,	dol_short},
diff -b dec971125/decoder.c dec971130/decoder.c
333c333
< 			freq2time_adapt (wnd [wn], &wnd_shape [wn], coef [ch], state [ch], data [ch]);
---
> 			freq2time_adapt (wnd [wn], &wnd_shape_SSR[ch], coef [ch], state [ch], data [ch]);

SRQ CHANGES for 971125
Note:
if X is defined as type enum
then
#if (X == 0)
is always evaluated as false regardless of the value of X!

Therefore the body of coupling.c has not been compiled in a long time and
had NUMEROUS syntax errors!


Changed files:
all.h
	changed enum into #ifdef for ICChans, DCChans, XCChans and CChans
port.h
	changed function prototypes for coupling() and ind_coupling()
decoder.c
	changed CChan to CChans
	changed calls to coupling() and ind_coupling()
	removed unneeded array cc_data[][]
coupling.c
	many changes
	added cc_hufffac()
	fixed syntax errors
	fixed calls to coupling() and ind_coupling()


CHANGES 971113
< is dec971112
> is dec971113

diff -b dec971112/portio.c dec971113/portio.c
308a309
>    }
311d311
<     }
diff -b dec971112/decoder.c dec971113/decoder.c
140a141
>     int max_band;
175a177,183
> #endif
> 
> 
> #ifdef	SSR
> 	for(i = 0; i < Chans; i++){
> 		wnd_shape_SSR[i].prev_bk = 0;
> 	}
diff -b dec971112/gc.c dec971113/gc.c
70c70
< 	int	i;
---
> 	int	i,j;
78,79c78,79
< 	bandSigCh = (double **)calloc(ssr_decoder_band,sizeof(double *));
< 	for (i = 0; i < ssr_decoder_band; i++) {
---
> 	bandSigCh = (double **)calloc(NBANDS,sizeof(double *));
> 	for (i = 0; i < NBANDS; i++) {
80a81,86
> 	}
> 
> 	for(i = 0; i < NBANDS; i++){
> 		for(j = 0; j < BLOCK_LEN_LONG/NBANDS; j++){
> 			bandSigCh[i][j] = 0.0;
> 		}
diff -b dec971112/gc_imdct.c dec971113/gc_imdct.c
211a212,213
> 	double	window_imdct_1st[LFFT_SHORT/NBANDS*2];
> 	double	window_imdct_2nd_7th[LFFT_SHORT/NBANDS*2];
253,254c255,270
< 			window_imdct[i] = short_wind[i];
< 			window_imdct[LFFT_SHORT/NBANDS*2-1-i] = short_wind[i];
---
> 			if( previous_wnd_shape == WS_SIN ){
> 				window_imdct_1st[i] = short_wind[i]; 
> 			}
> 			else if(previous_wnd_shape == WS_DOL){
> 				window_imdct_1st[i] = dol_short_ssr[i];
> 			}
> 			if( wnd_shape == WS_SIN ){
> 				window_imdct_1st[LFFT_SHORT/NBANDS*2-1-i] = short_wind[i]; 
> 				window_imdct_2nd_7th[i] = short_wind[i]; 
> 				window_imdct_2nd_7th[LFFT_SHORT/NBANDS*2-1-i] = short_wind[i]; 
> 			}
> 			else if(wnd_shape == WS_DOL){
> 				window_imdct_1st[LFFT_SHORT/NBANDS*2-1-i] = dol_short_ssr[i];
> 				window_imdct_2nd_7th[i] = dol_short_ssr[i];
> 				window_imdct_2nd_7th[LFFT_SHORT/NBANDS*2-1-i] = dol_short_ssr[i];
> 			}
270a287,288
> 
> 		if(wnd_shape == WS_SIN){
274a293,301
> 		}
> 		else if(wnd_shape == WS_DOL){
> 			for(i = 0; i < LFFT_SHORT/NBANDS; i++){
> 				window_imdct[i+FLAT+LFFT/NBANDS] =
> 				dol_short_ssr[LFFT_SHORT/NBANDS-1-i];
> 			}
> 		}
> 
> 
282a310,311
> 
> 		if( previous_wnd_shape == WS_SIN ){
285a315,325
> 		}
> 		else if(previous_wnd_shape == WS_DOL){
> 			for(i = 0; i < LFFT_SHORT/NBANDS; i++){
> 				window_imdct[i+FLAT] = dol_short_ssr[i];
> 			}
> 
> 		}
> 		else{
> 			printf("previous_wnd_shape type error !! :%d \n",previous_wnd_shape);
> 		}
> 
313a354,363
> 			if(j == 0){
> 				for(k = 0; k < LFFT_SHORT/NBANDS*2; k++){
> 					window_imdct[k] = window_imdct_1st[k];
> 				}
> 			}
> 			else{
> 				for(k = 0; k < LFFT_SHORT/NBANDS*2; k++){
> 					window_imdct[k] = window_imdct_2nd_7th[k];
> 				}
> 			}
359c409
< 	imdct_in = (double *)calloc(ssr_decoder_band*LFFT/NBANDS,sizeof(double));
---
> 	imdct_in = (double *)calloc(NBANDS*LFFT/NBANDS,sizeof(double));
diff -b dec971112/gc_ipqf.c dec971113/gc_ipqf.c
243,245d242
< 			if(j > max_band-1 || j > (ssr_decoder_band-1))
< 				a_ipqfin[j] = 0.0;
<          else
diff -b dec971112/huffdec2.c dec971113/huffdec2.c
260c260
<     for(i=0; i<nec_info->number_pulse; i++) {
---
>     for(i=0; i<nec_info->number_pulse+1; i++) {

HRR CHANGES 10/97
< is dec970828
> is dec971112

diff -b dec970828/all.h dec971112/all.h
56c56
<     SChans	= 0,	/* side channels: */
---
>     SChans	= 2,	/* side channels: */
diff -b dec970828/decoder.c dec971112/decoder.c
57c57
<     restarttio();
---
>     
119,120c119,120
<         wnd[Chans], max_sfb[Chans], nsect[Chans], 
< 	*sect[Chans], d_bytes[Avjframe];
---
>         wnd[Chans], max_sfb[Chans],
> 	*cb_map[Chans], d_bytes[Avjframe];
150c150
< 	sect[i] = (byte *)mal1(2*(MAXBANDS+1)*sizeof(*sect[0]));
---
> 	cb_map[i] = (byte *)mal1(MAXBANDS*sizeof(*cb_map[0]));
179a180,184
>     restarttio();	    /* reset io counters  */
> 
>     if(!startblock())       /* read adif header   */
>       myexit(0);
> 
187,189c192,193
< 	/* call transport layer */
< 	if(startblock() < 0)
< 	    myexit(0);
---
> 	byte_align();
> 	
193a198
> 
202c207
< 		    nsect, sect, factors, 
---
> 		    cb_map, factors, 
227a233,234
>         if(debug['v'])
>           PRINT(SE, "\nele_id %d\n", ele_id);
247a255,256
>                     if (hasmask[wn] == 1)
>                         map_mask(info, group[wn], mask[wn], cb_map[right]);
259,260c268,269
< 		nsect[ch], sect[ch], factors[ch], 
< 		hasmask[wn], mask[wn], lpflag[wn], coef);
---
> 		group[wn], cb_map[ch], factors[ch], 
> 		lpflag[wn], coef);
diff -b dec970828/huffdec1.c dec971112/huffdec1.c
34c34
<     byte *nsect, byte **sect, short **factors, 
---
>     byte **cb_map, short **factors, 
99c99
< 	    &nsect[i], sect[i], coef[i], &global_gain, factors[i], tns[i]
---
> 	    cb_map[i], coef[i], &global_gain, factors[i], tns[i]
diff -b dec970828/huffdec2.c dec971112/huffdec2.c
283c283
<     byte *pns, byte *sect, Float *coef, short *global_gain, 
---
>     byte *cb_map, Float *coef, short *global_gain, 
290c290,291
<     int nsect, i, tot_sfb;
---
>     int nsect, i, cb, top, bot, tot_sfb;
>     byte sect[ 2*(MAXBANDS+1) ];
321d321
<     *pns = nsect;
324a325,341
>     /* generate "linear" description from section info
>      * stored as codebook for each scalefactor band and group
>      */
>     if (nsect) {
>       bot = 0;
>       for (i=0; i<nsect; i++) {
> 	cb = sect[2*i];
> 	top = sect[2*i + 1];
> 	for (; bot<top; bot++)
>           *cb_map++ = cb;
> 	bot = top;
>       }
>     }  else {
>       for (i=0; i<MAXBANDS; i++)
>         cb_map[i] = 0;
>     }
> 
485a503
> 
536a555,556
> 
> 
618d637
< 
620c639
<     for (i=0; i<info->bins_per_bk; i++)
---
>     for (i=0; i<info->bins_per_bk; i++) {
621a641
>     }
655d674
< 
diff -b dec970828/intensity.c dec971112/intensity.c
35,37c35,37
< intensity(MC_Info *mip, Info *info, int widx, int ch,
<     byte nsect, byte *sect, short *factors, 
<     byte hasmask, byte *mask, int *lpflag, Float *coef[Chans])
---
> intensity( MC_Info *mip, Info *info, int widx, int ch,
>     byte *group, byte *cb_map, short *factors, 
>     int *lpflag, Float *coef[Chans] )
39,40d38
<    int left, right, i, k, cb, sign_sect, sign_sfb, bot, top, sfb, ktop;
<     Float scale;
41a40,42
>     Float   *left, *right, *r, *l, scale;
>     int     cb, sign_sfb, sfb, n, nn, b, bb, nband;
>     short   *band;
46,56c47,48
<     left = cip->paired_ch;
<     right = ch;
< 
<     bot=0;
<     for (i=0; i<nsect; i++) {
< 	cb = sect[2*i];
< 	top = sect[2*i + 1];
< 	if ( (cb != INTENSITY_HCB) && (cb != INTENSITY_HCB) ) {
< 	    bot = top;
< 	    continue;
< 	}
---
>     right = coef[ ch ];
>     left  = coef[ cip->paired_ch ];
57a50,62
>     /* Intensity goes by group */
>     bb = 0;
>     for (b = 0; b < info->nsbk; ) {
> 	nband = info->sfb_per_sbk[b];
> 	band = info->sbk_sfb_top[b];
> 
> 	b = *group++;		/* b = index of last sbk in group */
> 	for (; bb < b; bb++) {	/* bb = sbk index */
> 	    n = 0;
> 	    for (sfb = 0; sfb < nband; sfb++){
> 		nn = band[sfb];	/* band is offset table, nn is last coef in band */
> 		cb = cb_map[sfb];
> 		if (cb == INTENSITY_HCB  ||  cb == INTENSITY_HCB2) {
59,63c64
< 	if (debug['i'])
< 	    PRINT(SE,"\nintensity cb %d from %d to %d\n", cb, bot, top);
< 	sign_sect = (cb == INTENSITY_HCB) ? 1 : -1;
< 	for (sfb=bot; sfb<top; sfb++) {
< 	    /* disable prediction */
---
> 		    /* disable prediction (only important for long blocks) */
66,72c67
< 	    /* if mask present, mask is used to flip sign per sfb */
< 	    if (hasmask) {
< 		sign_sfb = sign_sect * (mask[sfb]==0) ? 1 : -1;
< 	    }
< 	    else {
< 		sign_sfb = sign_sect;
< 	    }
---
> 	            sign_sfb = (cb == INTENSITY_HCB) ? 1 : -1;
77,82c72,81
< 		PRINT(SE,"applying IS coding of %f on ch %d at sfb %3d\n",
< 		    scale, ch, sfb);
< 	    k = (sfb==0) ? 0 : info->bk_sfb_top[sfb-1];
< 	    ktop = info->bk_sfb_top[sfb];
< 	    for ( ; k<ktop; k++) {
< 		coef[right][k] = coef[left][k] * scale;
---
> 			PRINT(SE,"applying IS coding of %f on ch %d at sfb %3d %d\n",
> 			    scale, ch, sfb, factors[sfb]);
> 	            
> 		    r = right + n;
> 		    l = left + n;
> 		    for (; n < nn; n++) {	/* n is coef index */
> 			*r++ = *l++ * scale;
> 		    }
> 		}
> 		n = nn;
83a83,85
> 	    right += info->bins_per_sbk[bb];
> 	    left += info->bins_per_sbk[bb];
> 	    factors += nband;
85c87
< 	bot = top;
---
> 	cb_map += info->sfb_per_sbk[bb-1];
diff -b dec970828/interface.h dec971112/interface.h
95d94
<     RESERVED_HCB	= 13,
97a97
>     RESERVED_HCB	= 13,
diff -b dec970828/monopred.c dec971112/monopred.c
67a68,69
> 
> /* Schuyler's bug fix */
72c74
<     ulong tmp, tmp1;
---
>     ulong tmp;
75d76
<     tmp1 = tmp;
81,83c82,85
< 	tmp = tmp1 & (ulong)0xff810000;
< 	*pf += *pt;     /* add 1/2 lsb and elided one */
< 	tmp &= (ulong)0xff800000;
---
>         tmp &= (ulong)0xff800000;       /* extract exponent and sign */
>         tmp |= (ulong)0x00010000;       /* insert 1 lsb */
>         *pf += *pt;                     /* add 1 lsb and elided one */
>         tmp &= (ulong)0xff800000;       /* extract exponent and sign */
87a90
> 
94a98,99
> 
> /* New bug fixed version */
96c101
< inv_table_flt_round(float *pf)
---
> inv_table_flt_round(float *ftmp)
98,104c103,110
<     float f1, f2;
<     f1 = 1.0;
<     f2 = *pf;
<     f2 = f1 + (f2 / (1<<15));	/* 15 not 16! */
<     f2 -= f1;
<     f2 *= (1<<15);
<     *pf = f2;
---
>   int exp;
>   double mnt;
>   float descale;
> 
>     mnt = frexp((double)*ftmp, &exp);
>     descale = (float)ldexp(1.0, exp + 15);
>     *ftmp += descale;
>     *ftmp -= descale;
137,139c143
< 
< #define FAST_QUANT
< 
---
> /* Bug-fixed version (big-little endian problem) */
143,144c147,149
<     int i, j;
<     short *p1, *p2;
---
>     int i;
>     short *p2;
>     ulong *p1_tmp;
146,148c151,152
< #ifdef	FAST_QUANT
<     fltclr((float *) tmp_psp, MAX_PRED_BINS*6);
<     p1 = (short *) tmp_psp;
---
> 
>     p1_tmp = (ulong *)tmp_psp;
150,161c154,157
<     for (i=0, j=0; i<MAX_PRED_BINS*6; i++, j+=2)
< 	p1[j] = p2[i];
< #else	
<     for (i=0; i<MAX_PRED_BINS; i++) {
< 	p1 = (short *) &tmp_psp[i];
< 	p2 = (short *) &psp[i];
< 	for (j=0; j<6; j++) {
< 	    *p1++ = *p2++;
< 	    *p1++ = 0;
< 	}
<     }
< #endif    
---
>     
>     for (i=0; i<MAX_PRED_BINS*6; i++)
> 	    p1_tmp[i] = ((ulong)p2[i])<<16;
> 
163a160,162
> #define FAST_QUANT
> 
> /* Bug-fixed version (big-little endian problem) */
168c167,168
<     short *p1, *p2;
---
>     short *p1;
>     ulong *p2_tmp;
172,174c172,176
<     p2 = (short *) tmp_psp;
<     for (i=0, j=0; i<MAX_PRED_BINS*6; i++, j+=2)
< 	    p1[i] = p2[j];
---
>     p2_tmp = (ulong *)tmp_psp;
> 
>     for (i=0; i<MAX_PRED_BINS*6;i++)
>       p1[i] = (short) (p2_tmp[i]>>16);
> 	    
177d178
< 	int k;
179,181c180,183
< 	p2 = (short *) &tmp_psp[i];
< 	for (j=0, k=0; j<6; j++, k+=2)
< 	    p1[j] = p2[k];
---
> 	  p2_tmp = (ulong *)tmp_psp;
> 
>   for (j=0; j<6; j++)
> 	    p1[j] = (short) (p2_tmp[i]>>16);
314c316
<     j = tmp >> 7;
---
>     j = (tmp >> 7);
319c321
<     j = tmp >> 7;
---
>     j = (tmp >> 7);
326d327
<     
419d419
< 	
445c445,447
< 	    for (j=LEN_PRED_RSTGRP-1; j>0; j--) {
---
> 
>           /* for loop modified because of bit-reversed group number */
> 	    for (j=0; j<LEN_PRED_RSTGRP-1; j++) {
449c451
< 	    prstgrp |= prstflag[0];
---
> 	    prstgrp |= prstflag[LEN_PRED_RSTGRP-1];
453c455
< 		for (j=LEN_PRED_RSTGRP-1; j>=0; j--)
---
> 		for (j=0; j<LEN_PRED_RSTGRP; j++)
Only in dec971112: noise_gen.c
diff -b dec970828/port.h dec971112/port.h
62c62
< int		getics(Info *info, int common_window, byte *win, byte *wshape, byte *group, byte *max_sfb, int *lpflag, int *prstflag, byte *pns, byte *sect, Float *coef, short *global_gain     , short *factors    , TNS_frame_info *tns    
---
> int		getics(Info *info, int common_window, byte *win, byte *wshape, byte *group, byte *max_sfb, int *lpflag, int *prstflag, byte *cb_map, Float *coef, short *global_gain     , short *factors    , TNS_frame_info *tns    
71c71
< int		huffdecode(int id, MC_Info *mip, byte *win, Wnd_Shape *wshape, byte *nsect, byte **sect, short **factors,  byte **group, byte *hasmask, byte **mask, byte *max_sfb, int **lpflag, int **prstflag, TNS_frame_info **tns, Float **coef);
---
> int		huffdecode(int id, MC_Info *mip, byte *win, Wnd_Shape *wshape, byte **cb_map, short **factors,  byte **group, byte *hasmask, byte **mask, byte *max_sfb, int **lpflag, int **prstflag, TNS_frame_info **tns, Float **coef);
83c83
< void		intensity(MC_Info *mip, Info *info, int widx, int ch, byte nsect, byte *sect, short *factors, byte hasmask, byte *mask, int *lpflag, Float *coef[Chans]);
---
> void		intensity(MC_Info *mip, Info *info, int widx, int ch, byte *group, byte *cb_map, short *factors, int *lpflag, Float *coef[Chans]);
89a90
> void            map_mask(Info *info, byte *group, byte *mask, byte *cb_map);
diff -b dec970828/portio.c dec971112/portio.c
59c59
<     PRINT(SE, "	-i prog_tag (ADIF header present)\n");
---
>     PRINT(SE, "	-i  (ADIF header present)\n");
98,104c98
< 	adif_header_present = 1;
< 	s = ARGF();
< 	current_program = atoi(s);
< 	if (current_program > ((1<<LEN_NUM_PCE)-1)) {
< 	    PRINT(SE, "Invalid program: %d\n",  current_program);
< 	    current_program = -1;
< 	}
---
> 	adif_header_present=1;
189c183
<     if (useAIFF)
---
>     if (useAIFF){
191c185,186
< 
---
> 	AIFF_sampleRate = samp_rate_info[mip->sampling_rate_idx].samp_rate; 
>     }	
diff -b dec970828/stereo.c dec971112/stereo.c
64a65,94
> 
> 
> /* Map mask to intensity stereo signalling */
> void
> map_mask(Info *info, byte *group, byte *mask, byte *cb_map)
> {
>     int sfb, b, nband;
> 
>     /* mask goes by group */
>     for (b = 0; b < info->nsbk; ) {
>       nband = info->sfb_per_sbk[b];
> 
>       for (sfb = 0; sfb<nband; sfb++){
>         if (mask[sfb]) {
>           if (cb_map[sfb] == INTENSITY_HCB)  {
>             cb_map[sfb] = INTENSITY_HCB2;
>             mask[sfb] = 0;
>           } else if (cb_map[sfb] == INTENSITY_HCB2)  {
>             cb_map[sfb] = INTENSITY_HCB;
>             mask[sfb] = 0;
>           }
>         }
>       }
> 
>       mask += info->sfb_per_sbk[b];
>       cb_map += info->sfb_per_sbk[b];
>       b = *group++;		/* b = index of last sbk in group */
>     }
> 
> }

HRR CHANGES 8-28-97
< is dec970824
> is dec970828

diff -b dec970824/config.c dec970828/config.c
153c153
< 	PRINT(SE, "%s %d\n", "p->bitrate", p->bitrate);
---
> 	PRINT(SE, "%s %ld\n", "p->bitrate", p->bitrate);

diff -b dec970824/gc_mdct_common.c dec970828/gc_mdct_common.c
120c120
< 	bp0 = 1 << n-1;
---
> 	bp0 = 1 << (n-1);

diff -b dec970824/huffdec1.c dec970828/huffdec1.c
99c99
< 	    nsect, sect[i], coef[i], &global_gain, factors[i], tns[i]
---
> 	    &nsect[i], sect[i], coef[i], &global_gain, factors[i], tns[i]

diff -b dec970824/huffdec2.c dec970828/huffdec2.c
487c487
< 	    if (debug['f'] && (fac_trans[i] != 0))
---
> 	    if (debug['f'])

diff -b dec970824/intensity.c dec970828/intensity.c
77,78c77,78
< 		PRINT(SE,"applying IS coding of %f on ch %d at sfb %3d %d %d\n",
< 		    scale, ch, sfb, sign_sfb, factors[sfb]);
---
> 		PRINT(SE,"applying IS coding of %f on ch %d at sfb %3d\n",
> 		    scale, ch, sfb);


MC CHANGES 8-24-97

Added 'configure' script. Renamed original makefile to makefile.srq and
created makefile.in

Added INSTALL file


SRQ CHANGES 8-21-97
< indicates dec970725 release from NEC FTP site
> indicates my AACdec082197 release

Summary given above each "====" line

Change the structures for saving intensity stereo information
Add pred_max_bands_tbl[]
===================================================================
RCS file: RCS/all.h,v
retrieving revision 1.1
diff -b -r1.1 all.h
48,50d47
< #define	nil			((void*)0)
< #define	Tnleaf			0x8000
< 
142,151d138
<     int is_present;   /* right channel uses intensiy stereo */
<     int n_is_sect;
<     int sign[2*(MAXBANDS+1)];
<     int fac[2*(MAXBANDS+1)];
<     int bot[2*(MAXBANDS+1)];
<     int top[2*(MAXBANDS+1)];
< } IS_Info;
< 
< typedef struct
< {
159c146
<     IS_Info is_info;  /* IS information */
---
>     int is_present;   /* intensity stereo is used */
250a238
> extern        int             pred_max_bands_tbl[(1<<LEN_SAMP_IDX)];
253d240
< extern        byte            *sect;


Add pred_max_bands(void)
Cleanup code
===================================================================
RCS file: RCS/config.c,v
retrieving revision 1.1
diff -b -r1.1 config.c
26a27,29
> /*
>  * profile dependent parameters
>  */
58a62,67
> pred_max_bands(void)
> {
>     return pred_max_bands_tbl[mc_info.sampling_rate_idx];
> }
> 
> int
239c248
<     int i, j, cpe, tag, cidx, cw;
---
>     int i, j, cpe, tag, cw;
274c283
< 	if ((cidx = enter_chn(cpe, tag, 'f', cw, mip)) < 0)
---
> 	if (enter_chn(cpe, tag, 'f', cw, mip) < 0)
283c292
< 	if ((cidx = enter_chn(cpe, tag, 's', cw, mip)) < 0)
---
> 	if (enter_chn(cpe, tag, 's', cw, mip) < 0)
292c301
< 	if ((cidx = enter_chn(cpe, tag, 'b', cw, mip)) < 0)
---
> 	if (enter_chn(cpe, tag, 'b', cw, mip) < 0)
301c310
< 	if ((cidx = enter_chn(cpe, tag, 'l', cw, mip)) < 0)
---
> 	if (enter_chn(cpe, tag, 'l', cw, mip) < 0)
583c592
< 	    p->is_info.is_present = 0;
---
> 	    p->is_present = 0;

Fix bug: ind_sw_cce flag was being read at wrong point
(Alberto Duenas)
===================================================================
RCS file: RCS/coupling.c,v
retrieving revision 1.1
diff -b -r1.1 coupling.c
69c69
<     int cc_l, cc_r, cc_dom, cc_gain_ele_sign, ind_sw_cc, scl_idx,
---
>     int cc_l, cc_r, cc_dom, cc_gain_ele_sign, ind_sw_cc, cgep, scl_idx,
98a99,101
>     /*  get ind_sw_cce flag */
>     ind_sw_cc = mip->getbits(LEN_IND_SW_CCE);
>     
175c178,180
< 	if (getbits(LEN_CCH_CGP)) {
---
> 	/* if needed, get common gain elment present */
> 	cgep = ind_sw_cc ? 1 : getbits(LEN_CCH_CGP);
> 	if (cgep) {

Add pred_max_bands_tbl[]
===================================================================
RCS file: RCS/decdata.c,v
retrieving revision 1.1
diff -b -r1.1 decdata.c
233a234,253
> 
> int
> pred_max_bands_tbl[(1<<LEN_SAMP_IDX)] = {
>   33,     /* 96000 */
>   33,     /* 88200 */
>   38,     /* 64000 */
>   40,     /* 48000 */
>   40,     /* 44100 */
>   40,     /* 32000 */
>   41,     /* 24000 */
>   41,     /* 22050 */
>   37,     /* 16000 */
>   37,     /* 12000 */
>   37,     /* 11025 */
>   34,     /* 8000  */
>   0,
>   0,
>   0,
>   0
> };


Code clean up
Enable new intensity stereo structure
	(factors[][], sect[][], nsect[] are now perminant data strucures)
Fix TNS bug
===================================================================
RCS file: RCS/decoder.c,v
retrieving revision 1.1
diff -b -r1.1 decoder.c
55d54
<     huffdecinit();
120c119,120
<         wnd[Chans], max_sfb[Chans];
---
>         wnd[Chans], max_sfb[Chans], nsect[Chans], 
> 	*sect[Chans], d_bytes[Avjframe];
122c122
<     byte d_bytes[Avjframe];
---
>     short *factors[Chans];
141d140
<     int max_band;
149a149,150
> 	factors[i] = (short *)mal1(MAXBANDS*sizeof(*factors[0]));
> 	sect[i] = (byte *)mal1(2*(MAXBANDS+1)*sizeof(*sect[0]));
154d154
< 
157d156
< 
202,204c201,204
< 		if (huffdecode(ele_id, mip, wnd, wnd_shape, group, 
< 		    hasmask, mask, max_sfb, lpflag, prstflag, tns,
< 		    coef) < 0)
---
> 		if (huffdecode(ele_id, mip, wnd, wnd_shape,
> 		    nsect, sect, factors, 
> 		    group, hasmask, mask, max_sfb,
> 		    lpflag, prstflag, tns, coef) < 0)
258c258,260
< 	    intensity(mip, info, wn, lpflag[wn], ch, coef);
---
> 	    intensity(mip, info, wn, ch, 
> 		nsect[ch], sect[ch], factors[ch], 
> 		hasmask[wn], mask[wn], lpflag[wn], coef);
275,276c277
< 	    predict_reset(info, prstflag[wn], sp_status,
< 	        left, right);
---
> 	    predict_reset(info, prstflag[wn], sp_status, left, right);
290a292,294
> #if 1		    /* According to IS: Stop at max_sfb */
> 		    max_sfb[wn],
> #else
291a296
> #endif


Compiler does not want trailing ','
===================================================================
RCS file: RCS/gc.h,v
retrieving revision 1.1
diff -b -r1.1 gc.h
88c88
< 	LONG_STOP_SEQUENCE,
---
> 	LONG_STOP_SEQUENCE


compiler wants a return value (go figure!)
===================================================================
RCS file: RCS/gc_common.c,v
retrieving revision 1.1
diff -b -r1.1 gc_common.c
73a74,75
> 
> 	return 0;

New data structures for intensity stereo (lots of code went away)
Fix MAX_PRED_SFB bug
===================================================================
RCS file: RCS/huffdec1.c,v
retrieving revision 1.1
diff -b -r1.1 huffdec1.c
33a34
>     byte *nsect, byte **sect, short **factors, 
37c38
<     int i, tag, common_window, ch, widx, first=0, last=0, nsect;
---
>     int i, tag, common_window, ch, widx, first=0, last=0;
41d41
<     extern short *factors[2];
98,99c98,99
< 	    group[widx], max_sfb[widx], lpflag[widx], prstflag[widx], 
< 	    &nsect, sect, coef[i], &global_gain, factors[i-first], tns[i]
---
> 	    group[widx], &max_sfb[widx], lpflag[widx], prstflag[widx], 
> 	    nsect, sect[i], coef[i], &global_gain, factors[i], tns[i]
106,151d105
< 
<     /* identify intensity sections */
<     if ((id == ID_CPE) && common_window) {
< 	/* sectioning info is now that of right channel */
< 	int i, j, k, bot, top, table, is_cb, is_sfb, is_sect;
< 	IS_Info *iip = &mip->ch_info[last].is_info;
< 
< 	bot=0;
< 	is_sfb=0;
< 	is_sect=0;
< 	for (i=0, j=0; i<nsect; i++) {
< 	    table=sect[j];
< 	    top=sect[j+1];
< 	    /* is IS used?
< 	     * (but no IS if factor[left] is zero!)
< 	     */
< 	    is_cb = ((table == INTENSITY_HCB) ||
< 	        (table == INTENSITY_HCB2)) ? 1 : 0;
< 	    if (is_cb) {
< 		if (debug['i'])
< 		    PRINT(SE,"\nintensity cb %d from %d to %d\n",
< 			table, bot, top);
< 		iip->is_present = 1;
< 		iip->bot[is_sect] = bot;
< 		iip->top[is_sect] = top;
< 		iip->sign[is_sect] = 
< 		    (table == INTENSITY_HCB) ? 1 : -1;
< 		is_sect++;
< 	    }
< 
< 	    for (k=bot; k<top; k++) {
< 		if (is_cb) {
< 		    /* [0] is left, [1] is right */
< 		    iip->fac[is_sfb] = factors[1][is_sfb];
< 		    if (debug['i'])
< 			PRINT(SE,"IS factor %4d at sfb %3d\n",
< 			    iip->fac[is_sfb], is_sfb);
< 		}
< 		is_sfb++;
< 	    }
< 	    bot = top;
< 	    j+=2;
< 	}
< 	iip->n_is_sect = is_sect;
<     }
< 
159a114
>     int max_pred_sfb = pred_max_bands();
180,181c135,136
< 	    j = ( (*max_sfb < MAX_PRED_SFB) ? 
< 	        *max_sfb : MAX_PRED_SFB ) + 1;
---
> 	    j = ( (*max_sfb < max_pred_sfb) ? 
> 	        *max_sfb : max_pred_sfb ) + 1;
184c139
< 	    for ( ; i < MAX_PRED_SFB+1; i++)
---
> 	    for ( ; i < max_pred_sfb+1; i++)
202c157
< 	    for (i=1; i<MAX_PRED_SFB+1; i++)
---
> 	    for (i=1; i<max_pred_sfb+1; i++)

New data structures for intensity stereo 
===================================================================
RCS file: RCS/huffdec2.c,v
retrieving revision 1.1
diff -b -r1.1 huffdec2.c
29,40d28
< short*	factors[2];
< byte*	sect;
< 
< void
< huffdecinit(void)
< {
<     factors[0] = (short *)mal1(MAXBANDS*sizeof(*factors[0]));
<     factors[1] = (short *)mal1(MAXBANDS*sizeof(*factors[0]));
<     sect = (byte *)mal1(2*(MAXBANDS+1)*sizeof(*sect));
< }
< 
< /*********************************************************************/
294,295c282,283
<     byte *group, byte max_sfb, int *lpflag, int *prstflag, 
<     int *pns, byte *sect, Float *coef, short *global_gain, 
---
>     byte *group, byte *max_sfb, int *lpflag, int *prstflag, 
>     byte *pns, byte *sect, Float *coef, short *global_gain, 
312c300
< 	get_ics_info(win, wshape, group, &max_sfb, lpflag, prstflag);
---
> 	get_ics_info(win, wshape, group, max_sfb, lpflag, prstflag);
316c304
<     if (max_sfb == 0) {
---
>     if (*max_sfb == 0) {
332c320
<     nsect = huffcb(sect, info->sectbits, tot_sfb, info->sfb_per_sbk[0], max_sfb);
---
>     nsect = huffcb(sect, info->sectbits, tot_sfb, info->sfb_per_sbk[0], *max_sfb);
334c322
<     if(nsect==0 && max_sfb>0)
---
>     if(nsect==0 && *max_sfb>0)
375d362
< 
449,450c436
<     for (i=0; i<MAXBANDS; i++)
< 	factors[i] = 0;
---
>     shortclr(factors, MAXBANDS);
479,492c465,468
< 	    if(fac_trans[i]){
< 		/* decode intensity positions */
< 		if ( (info->nsbk==1) &&	    /* No short blocks yet! */
< 		( (fac_trans[i] == INTENSITY_HCB) || 
< 		    (fac_trans[i] == INTENSITY_HCB2) ) ) {
< 
< 		    /* decode intensity position */
< 		    t = decode_huff_cw(hcw);
< 		    is_pos += t - MIDFAC;
< 		    if (debug['f'])
< 			PRINT(SE,"%3d %3d (is_pos)\n", i, is_pos);
< 		    factors[i] = is_pos;
< 		    continue;
< 		}
---
> 	    switch (fac_trans[i]) {
> 	    case ZERO_HCB:	    /* zero book */
> 		break;
> 	    default:		    /* spectral books */
496,498d471
< 
< 		if (debug['f'])
< 		   PRINT(SE,"%3d:%3d", i, fac);
501d473
< 
502a475,485
> 		break;
> 	    case BOOKSCL:	    /* invalid books */
> 	    case RESERVED_HCB:
> 		return 0;
> 	    case INTENSITY_HCB:	    /* intensity books */
> 	    case INTENSITY_HCB2:
> 		/* decode intensity position */
> 		t = decode_huff_cw(hcw);
> 		is_pos += t - MIDFAC;
> 		factors[i] = is_pos;
> 		break;
503a487,488
> 	    if (debug['f'])
> 	       PRINT(SE,"%3d: %3d %3d\n", i, fac_trans[i], factors[i]);

Use the new data structures
Bug fix: mask[] now used to flip sign
===================================================================
RCS file: RCS/intensity.c,v
retrieving revision 1.1
diff -b -r1.1 intensity.c
35c35,37
< intensity(MC_Info *mip, Info *info, int widx, int *lpflag, int ch, Float *coef[Chans])
---
> intensity(MC_Info *mip, Info *info, int widx, int ch,
>     byte nsect, byte *sect, short *factors, 
>     byte hasmask, byte *mask, int *lpflag, Float *coef[Chans])
37c39
<     int left, right, i, k, nsect, sign, bot, top, sfb, ktop;
---
>    int left, right, i, k, cb, sign_sect, sign_sfb, bot, top, sfb, ktop;
40d41
<     IS_Info *iip = &mip->ch_info[ch].is_info;
42c43
<     if (!(cip->cpe && iip->is_present && !cip->ch_is_left))
---
>     if (!(cip->cpe && !cip->ch_is_left))
48c49
<     nsect = iip->n_is_sect;
---
>     bot=0;
50,52c51,61
< 	sign = iip->sign[i];
< 	top = iip->top[i];
< 	bot = iip->bot[i];
---
> 	cb = sect[2*i];
> 	top = sect[2*i + 1];
> 	if ( (cb != INTENSITY_HCB) && (cb != INTENSITY_HCB) ) {
> 	    bot = top;
> 	    continue;
> 	}
> 	
> 	/* found intensity code book */     
> 	if (debug['i'])
> 	    PRINT(SE,"\nintensity cb %d from %d to %d\n", cb, bot, top);
> 	sign_sect = (cb == INTENSITY_HCB) ? 1 : -1;
57c66,73
< 	    scale = sign * pow( 0.5,  0.25*(iip->fac[sfb]) );
---
> 	    /* if mask present, mask is used to flip sign per sfb */
> 	    if (hasmask) {
> 		sign_sfb = sign_sect * (mask[sfb]==0) ? 1 : -1;
> 	    }
> 	    else {
> 		sign_sfb = sign_sect;
> 	    }
> 	    scale = sign_sfb * pow( 0.5,  0.25*(factors[sfb]) );
68a85
> 	bot = top;

Some new enums to help intensity stereo 
===================================================================
RCS file: RCS/interface.h,v
retrieving revision 1.1
diff -b -r1.1 interface.h
88a89
>     ZERO_HCB		= 0,
94c95
<     INTENSITY_HCB	= 15,
---
>     RESERVED_HCB	= 13,
95a97
>     INTENSITY_HCB	= 15,
146a149
>     LEN_IND_CCE_FLG	= 1,  
165,166c168,172
<     /* sfb 40, coef 672, pred bw of 15.75 kHz */
<     MAX_PRED_SFB	= 40,
---
>     /* sfb 40, coef 672, pred bw of 15.75 kHz at 48 kHz
>      * this is also the highest number of bins used
>      * by predictor for any sampling rate
>      */
>      MAX_PRED_SFB	= 40,	/* 48 kHz only, now obsolete */

A new function
===================================================================
RCS file: RCS/intrins.c,v
retrieving revision 1.1
diff -b -r1.1 intrins.c
100a101,106
> shortclr(short *ip1, int cnt)
> {
>     memset(ip1, 0, cnt*sizeof(*ip1));
> }
> 
> void

Fix bug: MAX_PRED_SFB
===================================================================
RCS file: RCS/monopred.c,v
retrieving revision 1.1
diff -b -r1.1 monopred.c
167c167
<     int i, j, k;
---
>     int i, j;
176a177
> 	int k;
405c406
< 	for (j = 0; j < MAX_PRED_SFB; j++) {
---
> 	for (j = 0; j < pred_max_bands(); j++) {

Correct ftn prototypes
===================================================================
RCS file: RCS/port.h,v
retrieving revision 1.1
diff -b -r1.1 port.h
62c62
< int		getics(Info *info, int common_window, byte *win, byte *wshape, byte *group, byte max_sfb, int *lpflag, int *prstflag,     int *pns, byte *sect, Float *coef, short *global_gain     , short *factors    , TNS_frame_info *tns    
---
> int		getics(Info *info, int common_window, byte *win, byte *wshape, byte *group, byte *max_sfb, int *lpflag, int *prstflag, byte *pns, byte *sect, Float *coef, short *global_gain     , short *factors    , TNS_frame_info *tns    
71,72c71
< void		huffdecinit(void);
< int		huffdecode(int id, MC_Info *mip, byte *win, Wnd_Shape *wshape, byte **group, byte *hasmask, byte **mask, byte *max_sfb,     int **lpflag, int **prstflag,    TNS_frame_info **tns,    Float **coef);
---
> int		huffdecode(int id, MC_Info *mip, byte *win, Wnd_Shape *wshape, byte *nsect, byte **sect, short **factors,  byte **group, byte *hasmask, byte **mask, byte *max_sfb, int **lpflag, int **prstflag, TNS_frame_info **tns, Float **coef);
84c83
< void		intensity(MC_Info *mip, Info *info, int widx, int *lpflag, int ch, Float *coef[Chans]);
---
> void		intensity(MC_Info *mip, Info *info, int widx, int ch, byte nsect, byte *sect, short *factors, byte hasmask, byte *mask, int *lpflag, Float *coef[Chans]);
92a92
> int		pred_max_bands(void);
99a100
> void		shortclr(short *ip1, int cnt);

Pretty up user interface
===================================================================
RCS file: RCS/portio.c,v
retrieving revision 1.1
diff -b -r1.1 portio.c
63a64
>     PRINT(SE, "	-b Band For SSR Profile (1 to 4, 4 is default)\n");
67,69d67
< #ifdef  SSR
< 	PRINT(SE, "	-b Band For SSR Profile (1 to 4, 4 is default)\n");
< #endif
120c118
<     if (!strncmp(s, "SSR", 3)) {
---
> 	if ((!strncmp(s, "SSR", 3)) || (!strncmp(s, "ssr", 3))) {


Fix bug in TNS (Added this TWO places, per IS)
===================================================================
RCS file: RCS/tns.c,v
retrieving revision 1.1
diff -b -r1.1 tns.c
128a129
>         start = min(start, nbands);
129a131
> 	
130a133
>         stop = min(stop, nbands);
===================================================================
