static int vmdaudio_decode_frame(AVCodecContext *avctx,

                                 void *data, int *data_size,

                                 AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    VmdAudioContext *s = avctx->priv_data;

    int block_type, silent_chunks;

    unsigned char *output_samples = (unsigned char *)data;



    if (buf_size < 16) {

        av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");

        *data_size = 0;

        return buf_size;

    }



    block_type = buf[6];

    if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {

        av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);

        return AVERROR(EINVAL);

    }

    buf      += 16;

    buf_size -= 16;



    silent_chunks = 0;

    if (block_type == BLOCK_TYPE_INITIAL) {

        uint32_t flags = AV_RB32(buf);

        silent_chunks  = av_popcount(flags);

        buf      += 4;

        buf_size -= 4;

    } else if (block_type == BLOCK_TYPE_SILENCE) {

        silent_chunks = 1;

        buf_size = 0; // should already be zero but set it just to be sure

    }



    /* ensure output buffer is large enough */

    if (*data_size < (avctx->block_align*silent_chunks + buf_size) * s->out_bps)

        return -1;



    *data_size = vmdaudio_loadsound(s, output_samples, buf, silent_chunks, buf_size);



    return avpkt->size;

}

static int vmdaudio_decode_frame(AVCodecContext *avctx,

                                 void *data, int *data_size,

                                 AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    VmdAudioContext *s = avctx->priv_data;

    int block_type, silent_chunks;

    unsigned char *output_samples = (unsigned char *)data;



    if (buf_size < 16) {

        av_log(avctx, AV_LOG_WARNING, "skipping small junk packet\n");

        *data_size = 0;

        return buf_size;

    }



    block_type = buf[6];

    if (block_type < BLOCK_TYPE_AUDIO || block_type > BLOCK_TYPE_SILENCE) {

        av_log(avctx, AV_LOG_ERROR, "unknown block type: %d\n", block_type);

        return AVERROR(EINVAL);

    }

    buf      += 16;

    buf_size -= 16;



    silent_chunks = 0;

    if (block_type == BLOCK_TYPE_INITIAL) {

        uint32_t flags = AV_RB32(buf);

        silent_chunks  = av_popcount(flags);

        buf      += 4;

        buf_size -= 4;

    } else if (block_type == BLOCK_TYPE_SILENCE) {

        silent_chunks = 1;

        buf_size = 0; 

    }



    

    if (*data_size < (avctx->block_align*silent_chunks + buf_size) * s->out_bps)

        return -1;



    *data_size = vmdaudio_loadsound(s, output_samples, buf, silent_chunks, buf_size);



    return avpkt->size;

}

        uint32_t flags = AV_RB32(buf);
static int FUNC_0(AVCodecContext *VAR_0,

                                 void *VAR_1, int *VAR_2,

                                 AVPacket *VAR_3)

{

    const uint8_t *VAR_4 = VAR_3->VAR_1;

    int VAR_5 = VAR_3->size;

    VmdAudioContext *s = VAR_0->priv_data;

    int VAR_6, VAR_7;

    unsigned char *VAR_8 = (unsigned char *)VAR_1;



    if (VAR_5 < 16) {

        av_log(VAR_0, AV_LOG_WARNING, "skipping small junk packet\n");

        *VAR_2 = 0;

        return VAR_5;

    }



    VAR_6 = VAR_4[6];

    if (VAR_6 < BLOCK_TYPE_AUDIO || VAR_6 > BLOCK_TYPE_SILENCE) {

        av_log(VAR_0, AV_LOG_ERROR, "unknown block type: %d\n", VAR_6);

        return AVERROR(EINVAL);

    }

    VAR_4      += 16;

    VAR_5 -= 16;



    VAR_7 = 0;

    if (VAR_6 == BLOCK_TYPE_INITIAL) {

        uint32_t flags = AV_RB32(VAR_4);

        VAR_7  = av_popcount(flags);

        VAR_4      += 4;

        VAR_5 -= 4;

    } else if (VAR_6 == BLOCK_TYPE_SILENCE) {

        VAR_7 = 1;

        VAR_5 = 0; 

    }



    

    if (*VAR_2 < (VAR_0->block_align*VAR_7 + VAR_5) * s->out_bps)

        return -1;



    *VAR_2 = vmdaudio_loadsound(s, VAR_8, VAR_4, VAR_7, VAR_5);



    return VAR_3->size;

}

static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{ const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; VmdAudioContext *s = VAR_0->priv_data; int VAR_6, VAR_7; unsigned char *VAR_8 = (unsigned char *)VAR_1; if (VAR_5 < 16) { av_log(VAR_0, AV_LOG_WARNING, "skipping small junk packet\n"); *VAR_2 = 0; return VAR_5; } VAR_6 = VAR_4[6]; if (VAR_6 < BLOCK_TYPE_AUDIO || VAR_6 > BLOCK_TYPE_SILENCE) { av_log(VAR_0, AV_LOG_ERROR, "unknown block type: %d\n", VAR_6); return AVERROR(EINVAL); } VAR_4      += 16; VAR_5 -= 16; VAR_7 = 0; if (VAR_6 == BLOCK_TYPE_INITIAL) { uint32_t flags = AV_RB32(VAR_4); VAR_7  = av_popcount(flags); VAR_4      += 4; VAR_5 -= 4; } else if (VAR_6 == BLOCK_TYPE_SILENCE) { VAR_7 = 1; VAR_5 = 0; } if (*VAR_2 < (VAR_0->block_align*VAR_7 + VAR_5) * s->out_bps)
return -1; *VAR_2 = vmdaudio_loadsound(s, VAR_8, VAR_4, VAR_7, VAR_5); return VAR_3->size; }