static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_unit *pSnd, float *pOut, int channelNum, int codingMode)

{

    int   band, result=0, numSubbands, lastTonal, numBands;



    if (codingMode == JOINT_STEREO && channelNum == 1) {

        if (get_bits(gb,2) != 3) {

            av_log(NULL,AV_LOG_ERROR,"JS mono Sound Unit id != 3.\n");

            return -1;

        }

    } else {

        if (get_bits(gb,6) != 0x28) {

            av_log(NULL,AV_LOG_ERROR,"Sound Unit id != 0x28.\n");

            return -1;

        }

    }



    /* number of coded QMF bands */

    pSnd->bandsCoded = get_bits(gb,2);



    result = decodeGainControl (gb, &(pSnd->gainBlock[pSnd->gcBlkSwitch]), pSnd->bandsCoded);

    if (result) return result;



    pSnd->numComponents = decodeTonalComponents (gb, pSnd->components, pSnd->bandsCoded);

    if (pSnd->numComponents == -1) return -1;



    numSubbands = decodeSpectrum (gb, pSnd->spectrum);



    /* Merge the decoded spectrum and tonal components. */

    lastTonal = addTonalComponents (pSnd->spectrum, pSnd->numComponents, pSnd->components);





    /* calculate number of used MLT/QMF bands according to the amount of coded spectral lines */

    numBands = (subbandTab[numSubbands] - 1) >> 8;

    if (lastTonal >= 0)

        numBands = FFMAX((lastTonal + 256) >> 8, numBands);





    /* Reconstruct time domain samples. */

    for (band=0; band<4; band++) {

        /* Perform the IMDCT step without overlapping. */

        if (band <= numBands) {

            IMLT(&(pSnd->spectrum[band*256]), pSnd->IMDCT_buf, band&1);

        } else

            memset(pSnd->IMDCT_buf, 0, 512 * sizeof(float));



        /* gain compensation and overlapping */

        gainCompensateAndOverlap (pSnd->IMDCT_buf, &(pSnd->prevFrame[band*256]), &(pOut[band*256]),

                                    &((pSnd->gainBlock[1 - (pSnd->gcBlkSwitch)]).gBlock[band]),

                                    &((pSnd->gainBlock[pSnd->gcBlkSwitch]).gBlock[band]));

    }



    /* Swap the gain control buffers for the next frame. */

    pSnd->gcBlkSwitch ^= 1;



    return 0;

}

static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_unit *pSnd, float *pOut, int channelNum, int codingMode)

{

    int   band, result=0, numSubbands, lastTonal, numBands;



    if (codingMode == JOINT_STEREO && channelNum == 1) {

        if (get_bits(gb,2) != 3) {

            av_log(NULL,AV_LOG_ERROR,"JS mono Sound Unit id != 3.\n");

            return -1;

        }

    } else {

        if (get_bits(gb,6) != 0x28) {

            av_log(NULL,AV_LOG_ERROR,"Sound Unit id != 0x28.\n");

            return -1;

        }

    }



    

    pSnd->bandsCoded = get_bits(gb,2);



    result = decodeGainControl (gb, &(pSnd->gainBlock[pSnd->gcBlkSwitch]), pSnd->bandsCoded);

    if (result) return result;



    pSnd->numComponents = decodeTonalComponents (gb, pSnd->components, pSnd->bandsCoded);

    if (pSnd->numComponents == -1) return -1;



    numSubbands = decodeSpectrum (gb, pSnd->spectrum);



    

    lastTonal = addTonalComponents (pSnd->spectrum, pSnd->numComponents, pSnd->components);





    

    numBands = (subbandTab[numSubbands] - 1) >> 8;

    if (lastTonal >= 0)

        numBands = FFMAX((lastTonal + 256) >> 8, numBands);





    

    for (band=0; band<4; band++) {

        

        if (band <= numBands) {

            IMLT(&(pSnd->spectrum[band*256]), pSnd->IMDCT_buf, band&1);

        } else

            memset(pSnd->IMDCT_buf, 0, 512 * sizeof(float));



        

        gainCompensateAndOverlap (pSnd->IMDCT_buf, &(pSnd->prevFrame[band*256]), &(pOut[band*256]),

                                    &((pSnd->gainBlock[1 - (pSnd->gcBlkSwitch)]).gBlock[band]),

                                    &((pSnd->gainBlock[pSnd->gcBlkSwitch]).gBlock[band]));

    }



    

    pSnd->gcBlkSwitch ^= 1;



    return 0;

}

            IMLT(&(pSnd->spectrum[band*256]), pSnd->IMDCT_buf, band&1);
static int FUNC_0 (ATRAC3Context *VAR_0, GetBitContext *VAR_1, channel_unit *VAR_2, float *VAR_3, int VAR_4, int VAR_5)

{

    int   VAR_6, VAR_7=0, VAR_8, VAR_9, VAR_10;



    if (VAR_5 == JOINT_STEREO && VAR_4 == 1) {

        if (get_bits(VAR_1,2) != 3) {

            av_log(NULL,AV_LOG_ERROR,"JS mono Sound Unit id != 3.\n");

            return -1;

        }

    } else {

        if (get_bits(VAR_1,6) != 0x28) {

            av_log(NULL,AV_LOG_ERROR,"Sound Unit id != 0x28.\n");

            return -1;

        }

    }



    

    VAR_2->bandsCoded = get_bits(VAR_1,2);



    VAR_7 = decodeGainControl (VAR_1, &(VAR_2->gainBlock[VAR_2->gcBlkSwitch]), VAR_2->bandsCoded);

    if (VAR_7) return VAR_7;



    VAR_2->numComponents = decodeTonalComponents (VAR_1, VAR_2->components, VAR_2->bandsCoded);

    if (VAR_2->numComponents == -1) return -1;



    VAR_8 = decodeSpectrum (VAR_1, VAR_2->spectrum);



    

    VAR_9 = addTonalComponents (VAR_2->spectrum, VAR_2->numComponents, VAR_2->components);





    

    VAR_10 = (subbandTab[VAR_8] - 1) >> 8;

    if (VAR_9 >= 0)

        VAR_10 = FFMAX((VAR_9 + 256) >> 8, VAR_10);





    

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

        

        if (VAR_6 <= VAR_10) {

            IMLT(&(VAR_2->spectrum[VAR_6*256]), VAR_2->IMDCT_buf, VAR_6&1);

        } else

            memset(VAR_2->IMDCT_buf, 0, 512 * sizeof(float));



        

        gainCompensateAndOverlap (VAR_2->IMDCT_buf, &(VAR_2->prevFrame[VAR_6*256]), &(VAR_3[VAR_6*256]),

                                    &((VAR_2->gainBlock[1 - (VAR_2->gcBlkSwitch)]).gBlock[VAR_6]),

                                    &((VAR_2->gainBlock[VAR_2->gcBlkSwitch]).gBlock[VAR_6]));

    }



    

    VAR_2->gcBlkSwitch ^= 1;



    return 0;

}

static int FUNC_0 (ATRAC3Context *VAR_0, GetBitContext *VAR_1, channel_unit *VAR_2, float *VAR_3, int VAR_4, int VAR_5)
{ int   VAR_6, VAR_7=0, VAR_8, VAR_9, VAR_10; if (VAR_5 == JOINT_STEREO && VAR_4 == 1) { if (get_bits(VAR_1,2) != 3) { av_log(NULL,AV_LOG_ERROR,"JS mono Sound Unit id != 3.\n"); return -1; } } else { if (get_bits(VAR_1,6) != 0x28) { av_log(NULL,AV_LOG_ERROR,"Sound Unit id != 0x28.\n"); return -1; } } VAR_2->bandsCoded = get_bits(VAR_1,2); VAR_7 = decodeGainControl (VAR_1, &(VAR_2->gainBlock[VAR_2->gcBlkSwitch]), VAR_2->bandsCoded); if (VAR_7) return VAR_7; VAR_2->numComponents = decodeTonalComponents (VAR_1, VAR_2->components, VAR_2->bandsCoded); if (VAR_2->numComponents == -1) return -1; VAR_8 = decodeSpectrum (VAR_1, VAR_2->spectrum); VAR_9 = addTonalComponents (VAR_2->spectrum, VAR_2->numComponents, VAR_2->components); VAR_10 = (subbandTab[VAR_8] - 1) >> 8; if (VAR_9 >= 0)
VAR_10 = FFMAX((VAR_9 + 256) >> 8, VAR_10); for (VAR_6=0; VAR_6<4; VAR_6++) { if (VAR_6 <= VAR_10) { IMLT(&(VAR_2->spectrum[VAR_6*256]), VAR_2->IMDCT_buf, VAR_6&1); } else memset(VAR_2->IMDCT_buf, 0, 512 * sizeof(float)); gainCompensateAndOverlap (VAR_2->IMDCT_buf, &(VAR_2->prevFrame[VAR_6*256]), &(VAR_3[VAR_6*256]),
&((VAR_2->gainBlock[1 - (VAR_2->gcBlkSwitch)]).gBlock[VAR_6]),
&((VAR_2->gainBlock[VAR_2->gcBlkSwitch]).gBlock[VAR_6])); } VAR_2->gcBlkSwitch ^= 1; return 0; }