static void adjust_frame_information(ChannelElement *cpe, int chans)

{

    int i, w, w2, g, ch;

    int start, maxsfb, cmaxsfb;



    for (ch = 0; ch < chans; ch++) {

        IndividualChannelStream *ics = &cpe->ch[ch].ics;

        start = 0;

        maxsfb = 0;

        cpe->ch[ch].pulse.num_pulse = 0;

        for (w = 0; w < ics->num_windows*16; w += 16) {

            for (g = 0; g < ics->num_swb; g++) {

                //apply M/S

                if (cpe->common_window && !ch && cpe->ms_mask[w + g]) {

                    for (i = 0; i < ics->swb_sizes[g]; i++) {

                        cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0;

                        cpe->ch[1].coeffs[start+i] =  cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i];

                    }

                }

                start += ics->swb_sizes[g];

            }

            for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--)

                ;

            maxsfb = FFMAX(maxsfb, cmaxsfb);

        }

        ics->max_sfb = maxsfb;



        //adjust zero bands for window groups

        for (w = 0; w < ics->num_windows; w += ics->group_len[w]) {

            for (g = 0; g < ics->max_sfb; g++) {

                i = 1;

                for (w2 = w; w2 < w + ics->group_len[w]; w2++) {

                    if (!cpe->ch[ch].zeroes[w2*16 + g]) {

                        i = 0;

                        break;

                    }

                }

                cpe->ch[ch].zeroes[w*16 + g] = i;

            }

        }

    }



    if (chans > 1 && cpe->common_window) {

        IndividualChannelStream *ics0 = &cpe->ch[0].ics;

        IndividualChannelStream *ics1 = &cpe->ch[1].ics;

        int msc = 0;

        ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb);

        ics1->max_sfb = ics0->max_sfb;

        for (w = 0; w < ics0->num_windows*16; w += 16)

            for (i = 0; i < ics0->max_sfb; i++)

                if (cpe->ms_mask[w+i])

                    msc++;

        if (msc == 0 || ics0->max_sfb == 0)

            cpe->ms_mode = 0;

        else

            cpe->ms_mode = msc < ics0->max_sfb * ics0->num_windows ? 1 : 2;

    }

}

static void adjust_frame_information(ChannelElement *cpe, int chans)

{

    int i, w, w2, g, ch;

    int start, maxsfb, cmaxsfb;



    for (ch = 0; ch < chans; ch++) {

        IndividualChannelStream *ics = &cpe->ch[ch].ics;

        start = 0;

        maxsfb = 0;

        cpe->ch[ch].pulse.num_pulse = 0;

        for (w = 0; w < ics->num_windows*16; w += 16) {

            for (g = 0; g < ics->num_swb; g++) {

                

                if (cpe->common_window && !ch && cpe->ms_mask[w + g]) {

                    for (i = 0; i < ics->swb_sizes[g]; i++) {

                        cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0;

                        cpe->ch[1].coeffs[start+i] =  cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i];

                    }

                }

                start += ics->swb_sizes[g];

            }

            for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--)

                ;

            maxsfb = FFMAX(maxsfb, cmaxsfb);

        }

        ics->max_sfb = maxsfb;



        

        for (w = 0; w < ics->num_windows; w += ics->group_len[w]) {

            for (g = 0; g < ics->max_sfb; g++) {

                i = 1;

                for (w2 = w; w2 < w + ics->group_len[w]; w2++) {

                    if (!cpe->ch[ch].zeroes[w2*16 + g]) {

                        i = 0;

                        break;

                    }

                }

                cpe->ch[ch].zeroes[w*16 + g] = i;

            }

        }

    }



    if (chans > 1 && cpe->common_window) {

        IndividualChannelStream *ics0 = &cpe->ch[0].ics;

        IndividualChannelStream *ics1 = &cpe->ch[1].ics;

        int msc = 0;

        ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb);

        ics1->max_sfb = ics0->max_sfb;

        for (w = 0; w < ics0->num_windows*16; w += 16)

            for (i = 0; i < ics0->max_sfb; i++)

                if (cpe->ms_mask[w+i])

                    msc++;

        if (msc == 0 || ics0->max_sfb == 0)

            cpe->ms_mode = 0;

        else

            cpe->ms_mode = msc < ics0->max_sfb * ics0->num_windows ? 1 : 2;

    }

}

        for (w = 0; w < ics->num_windows*16; w += 16) {             for (g = 0; g < ics->num_swb; g++) {                 if (cpe->common_window && !ch && cpe->ms_mask[w + g]) {                     for (i = 0; i < ics->swb_sizes[g]; i++) {                         cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0;                         cpe->ch[1].coeffs[start+i] =  cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i];                 start += ics->swb_sizes[g];             for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--)             maxsfb = FFMAX(maxsfb, cmaxsfb);
static void FUNC_0(ChannelElement *VAR_0, int VAR_1)

{

    int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;

    int VAR_7, VAR_8, VAR_9;



    for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++) {

        IndividualChannelStream *ics = &VAR_0->VAR_6[VAR_6].ics;

        VAR_7 = 0;

        VAR_8 = 0;

        VAR_0->VAR_6[VAR_6].pulse.num_pulse = 0;

        for (VAR_3 = 0; VAR_3 < ics->num_windows*16; VAR_3 += 16) {

            for (VAR_5 = 0; VAR_5 < ics->num_swb; VAR_5++) {

                

                if (VAR_0->common_window && !VAR_6 && VAR_0->ms_mask[VAR_3 + VAR_5]) {

                    for (VAR_2 = 0; VAR_2 < ics->swb_sizes[VAR_5]; VAR_2++) {

                        VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] = (VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] + VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2]) / 2.0;

                        VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2] =  VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] - VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2];

                    }

                }

                VAR_7 += ics->swb_sizes[VAR_5];

            }

            for (VAR_9 = ics->num_swb; VAR_9 > 0 && VAR_0->VAR_6[VAR_6].zeroes[VAR_3+VAR_9-1]; VAR_9--)

                ;

            VAR_8 = FFMAX(VAR_8, VAR_9);

        }

        ics->max_sfb = VAR_8;



        

        for (VAR_3 = 0; VAR_3 < ics->num_windows; VAR_3 += ics->group_len[VAR_3]) {

            for (VAR_5 = 0; VAR_5 < ics->max_sfb; VAR_5++) {

                VAR_2 = 1;

                for (VAR_4 = VAR_3; VAR_4 < VAR_3 + ics->group_len[VAR_3]; VAR_4++) {

                    if (!VAR_0->VAR_6[VAR_6].zeroes[VAR_4*16 + VAR_5]) {

                        VAR_2 = 0;

                        break;

                    }

                }

                VAR_0->VAR_6[VAR_6].zeroes[VAR_3*16 + VAR_5] = VAR_2;

            }

        }

    }



    if (VAR_1 > 1 && VAR_0->common_window) {

        IndividualChannelStream *ics0 = &VAR_0->VAR_6[0].ics;

        IndividualChannelStream *ics1 = &VAR_0->VAR_6[1].ics;

        int VAR_10 = 0;

        ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb);

        ics1->max_sfb = ics0->max_sfb;

        for (VAR_3 = 0; VAR_3 < ics0->num_windows*16; VAR_3 += 16)

            for (VAR_2 = 0; VAR_2 < ics0->max_sfb; VAR_2++)

                if (VAR_0->ms_mask[VAR_3+VAR_2])

                    VAR_10++;

        if (VAR_10 == 0 || ics0->max_sfb == 0)

            VAR_0->ms_mode = 0;

        else

            VAR_0->ms_mode = VAR_10 < ics0->max_sfb * ics0->num_windows ? 1 : 2;

    }

}

static void FUNC_0(ChannelElement *VAR_0, int VAR_1)
{ int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6; int VAR_7, VAR_8, VAR_9; for (VAR_6 = 0; VAR_6 < VAR_1; VAR_6++) { IndividualChannelStream *ics = &VAR_0->VAR_6[VAR_6].ics; VAR_7 = 0; VAR_8 = 0; VAR_0->VAR_6[VAR_6].pulse.num_pulse = 0; for (VAR_3 = 0; VAR_3 < ics->num_windows*16; VAR_3 += 16) { for (VAR_5 = 0; VAR_5 < ics->num_swb; VAR_5++) { if (VAR_0->common_window && !VAR_6 && VAR_0->ms_mask[VAR_3 + VAR_5]) { for (VAR_2 = 0; VAR_2 < ics->swb_sizes[VAR_5]; VAR_2++) { VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] = (VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] + VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2]) / 2.0; VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2] =  VAR_0->VAR_6[0].coeffs[VAR_7+VAR_2] - VAR_0->VAR_6[1].coeffs[VAR_7+VAR_2]; } } VAR_7 += ics->swb_sizes[VAR_5]; } for (VAR_9 = ics->num_swb; VAR_9 > 0 && VAR_0->VAR_6[VAR_6].zeroes[VAR_3+VAR_9-1]; VAR_9--) ; VAR_8 = FFMAX(VAR_8, VAR_9); } ics->max_sfb = VAR_8; for (VAR_3 = 0; VAR_3 < ics->num_windows; VAR_3 += ics->group_len[VAR_3]) { for (VAR_5 = 0; VAR_5 < ics->max_sfb; VAR_5++) { VAR_2 = 1; for (VAR_4 = VAR_3; VAR_4 < VAR_3 + ics->group_len[VAR_3]; VAR_4++) { if (!VAR_0->VAR_6[VAR_6].zeroes[VAR_4*16 + VAR_5]) { VAR_2 = 0; break; } } VAR_0->VAR_6[VAR_6].zeroes[VAR_3*16 + VAR_5] = VAR_2; } } } if (VAR_1 > 1 && VAR_0->common_window) { IndividualChannelStream *ics0 = &VAR_0->VAR_6[0].ics; IndividualChannelStream *ics1 = &VAR_0->VAR_6[1].ics; int VAR_10 = 0; ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb); ics1->max_sfb = ics0->max_sfb; for (VAR_3 = 0; VAR_3 < ics0->num_windows*16; VAR_3 += 16) for (VAR_2 = 0; VAR_2 < ics0->max_sfb; VAR_2++) if (VAR_0->ms_mask[VAR_3+VAR_2])
VAR_10++; if (VAR_10 == 0 || ics0->max_sfb == 0)
VAR_0->ms_mode = 0; else
VAR_0->ms_mode = VAR_10 < ics0->max_sfb * ics0->num_windows ? 1 : 2; } }