static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,

                          int buf_size, int *coded_samples, int *approx_nb_samples)

{

    ADPCMDecodeContext *s = avctx->priv_data;

    int nb_samples        = 0;

    int ch                = avctx->channels;

    int has_coded_samples = 0;

    int header_size;



    *coded_samples = 0;

    *approx_nb_samples = 0;



    if(ch <= 0)

        return 0;



    switch (avctx->codec->id) {

    /* constant, only check buf_size */

    case AV_CODEC_ID_ADPCM_EA_XAS:

        if (buf_size < 76 * ch)

            return 0;

        nb_samples = 128;

        break;

    case AV_CODEC_ID_ADPCM_IMA_QT:

        if (buf_size < 34 * ch)

            return 0;

        nb_samples = 64;

        break;

    /* simple 4-bit adpcm */

    case AV_CODEC_ID_ADPCM_CT:

    case AV_CODEC_ID_ADPCM_IMA_APC:

    case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:

    case AV_CODEC_ID_ADPCM_IMA_OKI:

    case AV_CODEC_ID_ADPCM_IMA_WS:

    case AV_CODEC_ID_ADPCM_YAMAHA:

        nb_samples = buf_size * 2 / ch;

        break;

    }

    if (nb_samples)

        return nb_samples;



    /* simple 4-bit adpcm, with header */

    header_size = 0;

    switch (avctx->codec->id) {

        case AV_CODEC_ID_ADPCM_4XM:

        case AV_CODEC_ID_ADPCM_IMA_ISS:     header_size = 4 * ch;      break;

        case AV_CODEC_ID_ADPCM_IMA_AMV:     header_size = 8;           break;

        case AV_CODEC_ID_ADPCM_IMA_SMJPEG:  header_size = 4 * ch;      break;

    }

    if (header_size > 0)

        return (buf_size - header_size) * 2 / ch;



    /* more complex formats */

    switch (avctx->codec->id) {

    case AV_CODEC_ID_ADPCM_EA:

        has_coded_samples = 1;

        *coded_samples  = bytestream2_get_le32(gb);

        *coded_samples -= *coded_samples % 28;

        nb_samples      = (buf_size - 12) / 30 * 28;

        break;

    case AV_CODEC_ID_ADPCM_IMA_EA_EACS:

        has_coded_samples = 1;

        *coded_samples = bytestream2_get_le32(gb);

        nb_samples     = (buf_size - (4 + 8 * ch)) * 2 / ch;

        break;

    case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:

        nb_samples = (buf_size - ch) / ch * 2;

        break;

    case AV_CODEC_ID_ADPCM_EA_R1:

    case AV_CODEC_ID_ADPCM_EA_R2:

    case AV_CODEC_ID_ADPCM_EA_R3:

        /* maximum number of samples */

        /* has internal offsets and a per-frame switch to signal raw 16-bit */

        has_coded_samples = 1;

        switch (avctx->codec->id) {

        case AV_CODEC_ID_ADPCM_EA_R1:

            header_size    = 4 + 9 * ch;

            *coded_samples = bytestream2_get_le32(gb);

            break;

        case AV_CODEC_ID_ADPCM_EA_R2:

            header_size    = 4 + 5 * ch;

            *coded_samples = bytestream2_get_le32(gb);

            break;

        case AV_CODEC_ID_ADPCM_EA_R3:

            header_size    = 4 + 5 * ch;

            *coded_samples = bytestream2_get_be32(gb);

            break;

        }

        *coded_samples -= *coded_samples % 28;

        nb_samples      = (buf_size - header_size) * 2 / ch;

        nb_samples     -= nb_samples % 28;

        *approx_nb_samples = 1;

        break;

    case AV_CODEC_ID_ADPCM_IMA_DK3:

        if (avctx->block_align > 0)

            buf_size = FFMIN(buf_size, avctx->block_align);

        nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;

        break;

    case AV_CODEC_ID_ADPCM_IMA_DK4:

        if (avctx->block_align > 0)

            buf_size = FFMIN(buf_size, avctx->block_align);

        nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;

        break;

    case AV_CODEC_ID_ADPCM_IMA_RAD:

        if (avctx->block_align > 0)

            buf_size = FFMIN(buf_size, avctx->block_align);

        nb_samples = (buf_size - 4 * ch) * 2 / ch;

        break;

    case AV_CODEC_ID_ADPCM_IMA_WAV:

    {

        int bsize = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2];

        int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];

        if (avctx->block_align > 0)

            buf_size = FFMIN(buf_size, avctx->block_align);

        nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;

        break;

    }

    case AV_CODEC_ID_ADPCM_MS:

        if (avctx->block_align > 0)

            buf_size = FFMIN(buf_size, avctx->block_align);

        nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;

        break;

    case AV_CODEC_ID_ADPCM_SBPRO_2:

    case AV_CODEC_ID_ADPCM_SBPRO_3:

    case AV_CODEC_ID_ADPCM_SBPRO_4:

    {

        int samples_per_byte;

        switch (avctx->codec->id) {

        case AV_CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break;

        case AV_CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break;

        case AV_CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;

        }

        if (!s->status[0].step_index) {

            nb_samples++;

            buf_size -= ch;

        }

        nb_samples += buf_size * samples_per_byte / ch;

        break;

    }

    case AV_CODEC_ID_ADPCM_SWF:

    {

        int buf_bits       = buf_size * 8 - 2;

        int nbits          = (bytestream2_get_byte(gb) >> 6) + 2;

        int block_hdr_size = 22 * ch;

        int block_size     = block_hdr_size + nbits * ch * 4095;

        int nblocks        = buf_bits / block_size;

        int bits_left      = buf_bits - nblocks * block_size;

        nb_samples         = nblocks * 4096;

        if (bits_left >= block_hdr_size)

            nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);

        break;

    }

    case AV_CODEC_ID_ADPCM_THP:

        if (avctx->extradata) {

            nb_samples = buf_size / (8 * ch) * 14;

            break;

        }

        has_coded_samples = 1;

        bytestream2_skip(gb, 4); // channel size

        *coded_samples  = bytestream2_get_be32(gb);

        *coded_samples -= *coded_samples % 14;

        nb_samples      = (buf_size - (8 + 36 * ch)) / (8 * ch) * 14;

        break;

    case AV_CODEC_ID_ADPCM_AFC:

        nb_samples = buf_size / (9 * ch) * 16;

        break;

    case AV_CODEC_ID_ADPCM_XA:

        nb_samples = (buf_size / 128) * 224 / ch;

        break;

    case AV_CODEC_ID_ADPCM_DTK:

        nb_samples = buf_size / (16 * ch) * 28;

        break;

    }



    /* validate coded sample count */

    if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))

        return AVERROR_INVALIDDATA;



    return nb_samples;

}

static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,

                          int buf_size, int *coded_samples, int *approx_nb_samples)

{

    ADPCMDecodeContext *s = avctx->priv_data;

    int nb_samples        = 0;

    int ch                = avctx->channels;

    int has_coded_samples = 0;

    int header_size;



    *coded_samples = 0;

    *approx_nb_samples = 0;



    if(ch <= 0)

        return 0;



    switch (avctx->codec->id) {

    

    case AV_CODEC_ID_ADPCM_EA_XAS:

        if (buf_size < 76 * ch)

            return 0;

        nb_samples = 128;

        break;

    case AV_CODEC_ID_ADPCM_IMA_QT:

        if (buf_size < 34 * ch)

            return 0;

        nb_samples = 64;

        break;

    

    case AV_CODEC_ID_ADPCM_CT:

    case AV_CODEC_ID_ADPCM_IMA_APC:

    case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:

    case AV_CODEC_ID_ADPCM_IMA_OKI:

    case AV_CODEC_ID_ADPCM_IMA_WS:

    case AV_CODEC_ID_ADPCM_YAMAHA:

        nb_samples = buf_size * 2 / ch;

        break;

    }

    if (nb_samples)

        return nb_samples;



    

    header_size = 0;

    switch (avctx->codec->id) {

        case AV_CODEC_ID_ADPCM_4XM:

        case AV_CODEC_ID_ADPCM_IMA_ISS:     header_size = 4 * ch;      break;

        case AV_CODEC_ID_ADPCM_IMA_AMV:     header_size = 8;           break;

        case AV_CODEC_ID_ADPCM_IMA_SMJPEG:  header_size = 4 * ch;      break;

    }

    if (header_size > 0)

        return (buf_size - header_size) * 2 / ch;



    

    switch (avctx->codec->id) {

    case AV_CODEC_ID_ADPCM_EA:

        has_coded_samples = 1;

        *coded_samples  = bytestream2_get_le32(gb);

        *coded_samples -= *coded_samples % 28;

        nb_samples      = (buf_size - 12) / 30 * 28;

        break;

    case AV_CODEC_ID_ADPCM_IMA_EA_EACS:

        has_coded_samples = 1;

        *coded_samples = bytestream2_get_le32(gb);

        nb_samples     = (buf_size - (4 + 8 * ch)) * 2 / ch;

        break;

    case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:

        nb_samples = (buf_size - ch) / ch * 2;

        break;

    case AV_CODEC_ID_ADPCM_EA_R1:

    case AV_CODEC_ID_ADPCM_EA_R2:

    case AV_CODEC_ID_ADPCM_EA_R3:

        

        

        has_coded_samples = 1;

        switch (avctx->codec->id) {

        case AV_CODEC_ID_ADPCM_EA_R1:

            header_size    = 4 + 9 * ch;

            *coded_samples = bytestream2_get_le32(gb);

            break;

        case AV_CODEC_ID_ADPCM_EA_R2:

            header_size    = 4 + 5 * ch;

            *coded_samples = bytestream2_get_le32(gb);

            break;

        case AV_CODEC_ID_ADPCM_EA_R3:

            header_size    = 4 + 5 * ch;

            *coded_samples = bytestream2_get_be32(gb);

            break;

        }

        *coded_samples -= *coded_samples % 28;

        nb_samples      = (buf_size - header_size) * 2 / ch;

        nb_samples     -= nb_samples % 28;

        *approx_nb_samples = 1;

        break;

    case AV_CODEC_ID_ADPCM_IMA_DK3:

        if (avctx->block_align > 0)

            buf_size = FFMIN(buf_size, avctx->block_align);

        nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;

        break;

    case AV_CODEC_ID_ADPCM_IMA_DK4:

        if (avctx->block_align > 0)

            buf_size = FFMIN(buf_size, avctx->block_align);

        nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;

        break;

    case AV_CODEC_ID_ADPCM_IMA_RAD:

        if (avctx->block_align > 0)

            buf_size = FFMIN(buf_size, avctx->block_align);

        nb_samples = (buf_size - 4 * ch) * 2 / ch;

        break;

    case AV_CODEC_ID_ADPCM_IMA_WAV:

    {

        int bsize = ff_adpcm_ima_block_sizes[avctx->bits_per_coded_sample - 2];

        int bsamples = ff_adpcm_ima_block_samples[avctx->bits_per_coded_sample - 2];

        if (avctx->block_align > 0)

            buf_size = FFMIN(buf_size, avctx->block_align);

        nb_samples = 1 + (buf_size - 4 * ch) / (bsize * ch) * bsamples;

        break;

    }

    case AV_CODEC_ID_ADPCM_MS:

        if (avctx->block_align > 0)

            buf_size = FFMIN(buf_size, avctx->block_align);

        nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;

        break;

    case AV_CODEC_ID_ADPCM_SBPRO_2:

    case AV_CODEC_ID_ADPCM_SBPRO_3:

    case AV_CODEC_ID_ADPCM_SBPRO_4:

    {

        int samples_per_byte;

        switch (avctx->codec->id) {

        case AV_CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break;

        case AV_CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break;

        case AV_CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;

        }

        if (!s->status[0].step_index) {

            nb_samples++;

            buf_size -= ch;

        }

        nb_samples += buf_size * samples_per_byte / ch;

        break;

    }

    case AV_CODEC_ID_ADPCM_SWF:

    {

        int buf_bits       = buf_size * 8 - 2;

        int nbits          = (bytestream2_get_byte(gb) >> 6) + 2;

        int block_hdr_size = 22 * ch;

        int block_size     = block_hdr_size + nbits * ch * 4095;

        int nblocks        = buf_bits / block_size;

        int bits_left      = buf_bits - nblocks * block_size;

        nb_samples         = nblocks * 4096;

        if (bits_left >= block_hdr_size)

            nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);

        break;

    }

    case AV_CODEC_ID_ADPCM_THP:

        if (avctx->extradata) {

            nb_samples = buf_size / (8 * ch) * 14;

            break;

        }

        has_coded_samples = 1;

        bytestream2_skip(gb, 4); 

        *coded_samples  = bytestream2_get_be32(gb);

        *coded_samples -= *coded_samples % 14;

        nb_samples      = (buf_size - (8 + 36 * ch)) / (8 * ch) * 14;

        break;

    case AV_CODEC_ID_ADPCM_AFC:

        nb_samples = buf_size / (9 * ch) * 16;

        break;

    case AV_CODEC_ID_ADPCM_XA:

        nb_samples = (buf_size / 128) * 224 / ch;

        break;

    case AV_CODEC_ID_ADPCM_DTK:

        nb_samples = buf_size / (16 * ch) * 28;

        break;

    }



    

    if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))

        return AVERROR_INVALIDDATA;



    return nb_samples;

}

        nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;
static int FUNC_0(AVCodecContext *VAR_0, GetByteContext *VAR_1,

                          int VAR_2, int *VAR_3, int *VAR_4)

{

    ADPCMDecodeContext *s = VAR_0->priv_data;

    int VAR_5        = 0;

    int VAR_6                = VAR_0->channels;

    int VAR_7 = 0;

    int VAR_8;



    *VAR_3 = 0;

    *VAR_4 = 0;



    if(VAR_6 <= 0)

        return 0;



    switch (VAR_0->codec->id) {

    

    case AV_CODEC_ID_ADPCM_EA_XAS:

        if (VAR_2 < 76 * VAR_6)

            return 0;

        VAR_5 = 128;

        break;

    case AV_CODEC_ID_ADPCM_IMA_QT:

        if (VAR_2 < 34 * VAR_6)

            return 0;

        VAR_5 = 64;

        break;

    

    case AV_CODEC_ID_ADPCM_CT:

    case AV_CODEC_ID_ADPCM_IMA_APC:

    case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:

    case AV_CODEC_ID_ADPCM_IMA_OKI:

    case AV_CODEC_ID_ADPCM_IMA_WS:

    case AV_CODEC_ID_ADPCM_YAMAHA:

        VAR_5 = VAR_2 * 2 / VAR_6;

        break;

    }

    if (VAR_5)

        return VAR_5;



    

    VAR_8 = 0;

    switch (VAR_0->codec->id) {

        case AV_CODEC_ID_ADPCM_4XM:

        case AV_CODEC_ID_ADPCM_IMA_ISS:     VAR_8 = 4 * VAR_6;      break;

        case AV_CODEC_ID_ADPCM_IMA_AMV:     VAR_8 = 8;           break;

        case AV_CODEC_ID_ADPCM_IMA_SMJPEG:  VAR_8 = 4 * VAR_6;      break;

    }

    if (VAR_8 > 0)

        return (VAR_2 - VAR_8) * 2 / VAR_6;



    

    switch (VAR_0->codec->id) {

    case AV_CODEC_ID_ADPCM_EA:

        VAR_7 = 1;

        *VAR_3  = bytestream2_get_le32(VAR_1);

        *VAR_3 -= *VAR_3 % 28;

        VAR_5      = (VAR_2 - 12) / 30 * 28;

        break;

    case AV_CODEC_ID_ADPCM_IMA_EA_EACS:

        VAR_7 = 1;

        *VAR_3 = bytestream2_get_le32(VAR_1);

        VAR_5     = (VAR_2 - (4 + 8 * VAR_6)) * 2 / VAR_6;

        break;

    case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:

        VAR_5 = (VAR_2 - VAR_6) / VAR_6 * 2;

        break;

    case AV_CODEC_ID_ADPCM_EA_R1:

    case AV_CODEC_ID_ADPCM_EA_R2:

    case AV_CODEC_ID_ADPCM_EA_R3:

        

        

        VAR_7 = 1;

        switch (VAR_0->codec->id) {

        case AV_CODEC_ID_ADPCM_EA_R1:

            VAR_8    = 4 + 9 * VAR_6;

            *VAR_3 = bytestream2_get_le32(VAR_1);

            break;

        case AV_CODEC_ID_ADPCM_EA_R2:

            VAR_8    = 4 + 5 * VAR_6;

            *VAR_3 = bytestream2_get_le32(VAR_1);

            break;

        case AV_CODEC_ID_ADPCM_EA_R3:

            VAR_8    = 4 + 5 * VAR_6;

            *VAR_3 = bytestream2_get_be32(VAR_1);

            break;

        }

        *VAR_3 -= *VAR_3 % 28;

        VAR_5      = (VAR_2 - VAR_8) * 2 / VAR_6;

        VAR_5     -= VAR_5 % 28;

        *VAR_4 = 1;

        break;

    case AV_CODEC_ID_ADPCM_IMA_DK3:

        if (VAR_0->block_align > 0)

            VAR_2 = FFMIN(VAR_2, VAR_0->block_align);

        VAR_5 = ((VAR_2 - 16) * 2 / 3 * 4) / VAR_6;

        break;

    case AV_CODEC_ID_ADPCM_IMA_DK4:

        if (VAR_0->block_align > 0)

            VAR_2 = FFMIN(VAR_2, VAR_0->block_align);

        VAR_5 = 1 + (VAR_2 - 4 * VAR_6) * 2 / VAR_6;

        break;

    case AV_CODEC_ID_ADPCM_IMA_RAD:

        if (VAR_0->block_align > 0)

            VAR_2 = FFMIN(VAR_2, VAR_0->block_align);

        VAR_5 = (VAR_2 - 4 * VAR_6) * 2 / VAR_6;

        break;

    case AV_CODEC_ID_ADPCM_IMA_WAV:

    {

        int VAR_9 = ff_adpcm_ima_block_sizes[VAR_0->bits_per_coded_sample - 2];

        int VAR_10 = ff_adpcm_ima_block_samples[VAR_0->bits_per_coded_sample - 2];

        if (VAR_0->block_align > 0)

            VAR_2 = FFMIN(VAR_2, VAR_0->block_align);

        VAR_5 = 1 + (VAR_2 - 4 * VAR_6) / (VAR_9 * VAR_6) * VAR_10;

        break;

    }

    case AV_CODEC_ID_ADPCM_MS:

        if (VAR_0->block_align > 0)

            VAR_2 = FFMIN(VAR_2, VAR_0->block_align);

        VAR_5 = 2 + (VAR_2 - 7 * VAR_6) * 2 / VAR_6;

        break;

    case AV_CODEC_ID_ADPCM_SBPRO_2:

    case AV_CODEC_ID_ADPCM_SBPRO_3:

    case AV_CODEC_ID_ADPCM_SBPRO_4:

    {

        int VAR_11;

        switch (VAR_0->codec->id) {

        case AV_CODEC_ID_ADPCM_SBPRO_2: VAR_11 = 4; break;

        case AV_CODEC_ID_ADPCM_SBPRO_3: VAR_11 = 3; break;

        case AV_CODEC_ID_ADPCM_SBPRO_4: VAR_11 = 2; break;

        }

        if (!s->status[0].step_index) {

            VAR_5++;

            VAR_2 -= VAR_6;

        }

        VAR_5 += VAR_2 * VAR_11 / VAR_6;

        break;

    }

    case AV_CODEC_ID_ADPCM_SWF:

    {

        int VAR_12       = VAR_2 * 8 - 2;

        int VAR_13          = (bytestream2_get_byte(VAR_1) >> 6) + 2;

        int VAR_14 = 22 * VAR_6;

        int VAR_15     = VAR_14 + VAR_13 * VAR_6 * 4095;

        int VAR_16        = VAR_12 / VAR_15;

        int VAR_17      = VAR_12 - VAR_16 * VAR_15;

        VAR_5         = VAR_16 * 4096;

        if (VAR_17 >= VAR_14)

            VAR_5 += 1 + (VAR_17 - VAR_14) / (VAR_13 * VAR_6);

        break;

    }

    case AV_CODEC_ID_ADPCM_THP:

        if (VAR_0->extradata) {

            VAR_5 = VAR_2 / (8 * VAR_6) * 14;

            break;

        }

        VAR_7 = 1;

        bytestream2_skip(VAR_1, 4); 

        *VAR_3  = bytestream2_get_be32(VAR_1);

        *VAR_3 -= *VAR_3 % 14;

        VAR_5      = (VAR_2 - (8 + 36 * VAR_6)) / (8 * VAR_6) * 14;

        break;

    case AV_CODEC_ID_ADPCM_AFC:

        VAR_5 = VAR_2 / (9 * VAR_6) * 16;

        break;

    case AV_CODEC_ID_ADPCM_XA:

        VAR_5 = (VAR_2 / 128) * 224 / VAR_6;

        break;

    case AV_CODEC_ID_ADPCM_DTK:

        VAR_5 = VAR_2 / (16 * VAR_6) * 28;

        break;

    }



    

    if (VAR_7 && (*VAR_3 <= 0 || *VAR_3 > VAR_5))

        return AVERROR_INVALIDDATA;



    return VAR_5;

}

static int FUNC_0(AVCodecContext *VAR_0, GetByteContext *VAR_1,
int VAR_2, int *VAR_3, int *VAR_4)
{ ADPCMDecodeContext *s = VAR_0->priv_data; int VAR_5        = 0; int VAR_6                = VAR_0->channels; int VAR_7 = 0; int VAR_8; *VAR_3 = 0; *VAR_4 = 0; if(VAR_6 <= 0)
return 0; switch (VAR_0->codec->id) { case AV_CODEC_ID_ADPCM_EA_XAS:
if (VAR_2 < 76 * VAR_6)
return 0; VAR_5 = 128; break; case AV_CODEC_ID_ADPCM_IMA_QT:
if (VAR_2 < 34 * VAR_6)
return 0; VAR_5 = 64; break; case AV_CODEC_ID_ADPCM_CT:
case AV_CODEC_ID_ADPCM_IMA_APC:
case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
case AV_CODEC_ID_ADPCM_IMA_OKI:
case AV_CODEC_ID_ADPCM_IMA_WS:
case AV_CODEC_ID_ADPCM_YAMAHA:
VAR_5 = VAR_2 * 2 / VAR_6; break; } if (VAR_5)
return VAR_5; VAR_8 = 0; switch (VAR_0->codec->id) { case AV_CODEC_ID_ADPCM_4XM:
case AV_CODEC_ID_ADPCM_IMA_ISS:     VAR_8 = 4 * VAR_6;      break; case AV_CODEC_ID_ADPCM_IMA_AMV:     VAR_8 = 8;           break; case AV_CODEC_ID_ADPCM_IMA_SMJPEG:  VAR_8 = 4 * VAR_6;      break; } if (VAR_8 > 0)
return (VAR_2 - VAR_8) * 2 / VAR_6; switch (VAR_0->codec->id) { case AV_CODEC_ID_ADPCM_EA:
VAR_7 = 1; *VAR_3  = bytestream2_get_le32(VAR_1); *VAR_3 -= *VAR_3 % 28; VAR_5      = (VAR_2 - 12) / 30 * 28; break; case AV_CODEC_ID_ADPCM_IMA_EA_EACS:
VAR_7 = 1; *VAR_3 = bytestream2_get_le32(VAR_1); VAR_5     = (VAR_2 - (4 + 8 * VAR_6)) * 2 / VAR_6; break; case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:
VAR_5 = (VAR_2 - VAR_6) / VAR_6 * 2; break; case AV_CODEC_ID_ADPCM_EA_R1:
case AV_CODEC_ID_ADPCM_EA_R2:
case AV_CODEC_ID_ADPCM_EA_R3:
VAR_7 = 1; switch (VAR_0->codec->id) { case AV_CODEC_ID_ADPCM_EA_R1:
VAR_8    = 4 + 9 * VAR_6; *VAR_3 = bytestream2_get_le32(VAR_1); break; case AV_CODEC_ID_ADPCM_EA_R2:
VAR_8    = 4 + 5 * VAR_6; *VAR_3 = bytestream2_get_le32(VAR_1); break; case AV_CODEC_ID_ADPCM_EA_R3:
VAR_8    = 4 + 5 * VAR_6; *VAR_3 = bytestream2_get_be32(VAR_1); break; } *VAR_3 -= *VAR_3 % 28; VAR_5      = (VAR_2 - VAR_8) * 2 / VAR_6; VAR_5     -= VAR_5 % 28; *VAR_4 = 1; break; case AV_CODEC_ID_ADPCM_IMA_DK3:
if (VAR_0->block_align > 0)
VAR_2 = FFMIN(VAR_2, VAR_0->block_align); VAR_5 = ((VAR_2 - 16) * 2 / 3 * 4) / VAR_6; break; case AV_CODEC_ID_ADPCM_IMA_DK4:
if (VAR_0->block_align > 0)
VAR_2 = FFMIN(VAR_2, VAR_0->block_align); VAR_5 = 1 + (VAR_2 - 4 * VAR_6) * 2 / VAR_6; break; case AV_CODEC_ID_ADPCM_IMA_RAD:
if (VAR_0->block_align > 0)
VAR_2 = FFMIN(VAR_2, VAR_0->block_align); VAR_5 = (VAR_2 - 4 * VAR_6) * 2 / VAR_6; break; case AV_CODEC_ID_ADPCM_IMA_WAV:
{ int VAR_9 = ff_adpcm_ima_block_sizes[VAR_0->bits_per_coded_sample - 2]; int VAR_10 = ff_adpcm_ima_block_samples[VAR_0->bits_per_coded_sample - 2]; if (VAR_0->block_align > 0)
VAR_2 = FFMIN(VAR_2, VAR_0->block_align); VAR_5 = 1 + (VAR_2 - 4 * VAR_6) / (VAR_9 * VAR_6) * VAR_10; break; } case AV_CODEC_ID_ADPCM_MS:
if (VAR_0->block_align > 0)
VAR_2 = FFMIN(VAR_2, VAR_0->block_align); VAR_5 = 2 + (VAR_2 - 7 * VAR_6) * 2 / VAR_6; break; case AV_CODEC_ID_ADPCM_SBPRO_2:
case AV_CODEC_ID_ADPCM_SBPRO_3:
case AV_CODEC_ID_ADPCM_SBPRO_4:
{ int VAR_11; switch (VAR_0->codec->id) { case AV_CODEC_ID_ADPCM_SBPRO_2: VAR_11 = 4; break; case AV_CODEC_ID_ADPCM_SBPRO_3: VAR_11 = 3; break; case AV_CODEC_ID_ADPCM_SBPRO_4: VAR_11 = 2; break; } if (!s->status[0].step_index) { VAR_5++; VAR_2 -= VAR_6; } VAR_5 += VAR_2 * VAR_11 / VAR_6; break; } case AV_CODEC_ID_ADPCM_SWF:
{ int VAR_12       = VAR_2 * 8 - 2; int VAR_13          = (bytestream2_get_byte(VAR_1) >> 6) + 2; int VAR_14 = 22 * VAR_6; int VAR_15     = VAR_14 + VAR_13 * VAR_6 * 4095; int VAR_16        = VAR_12 / VAR_15; int VAR_17      = VAR_12 - VAR_16 * VAR_15; VAR_5         = VAR_16 * 4096; if (VAR_17 >= VAR_14)
VAR_5 += 1 + (VAR_17 - VAR_14) / (VAR_13 * VAR_6); break; } case AV_CODEC_ID_ADPCM_THP:
if (VAR_0->extradata) { VAR_5 = VAR_2 / (8 * VAR_6) * 14; break; } VAR_7 = 1; bytestream2_skip(VAR_1, 4); *VAR_3  = bytestream2_get_be32(VAR_1); *VAR_3 -= *VAR_3 % 14; VAR_5      = (VAR_2 - (8 + 36 * VAR_6)) / (8 * VAR_6) * 14; break; case AV_CODEC_ID_ADPCM_AFC:
VAR_5 = VAR_2 / (9 * VAR_6) * 16; break; case AV_CODEC_ID_ADPCM_XA:
VAR_5 = (VAR_2 / 128) * 224 / VAR_6; break; case AV_CODEC_ID_ADPCM_DTK:
VAR_5 = VAR_2 / (16 * VAR_6) * 28; break; } if (VAR_7 && (*VAR_3 <= 0 || *VAR_3 > VAR_5))
return AVERROR_INVALIDDATA; return VAR_5; }