static int wavpack_decode_frame(AVCodecContext *avctx,

                            void *data, int *data_size,

                            AVPacket *avpkt)

{

    WavpackContext *s = avctx->priv_data;

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    int frame_size;

    int samplecount = 0;



    s->block = 0;

    s->samples_left = 0;

    s->ch_offset = 0;



    if(s->mkv_mode){

        s->samples = AV_RL32(buf); buf += 4;

    }

    while(buf_size > 0){

        if(!s->multichannel){

            frame_size = buf_size;

        }else{

            if(!s->mkv_mode){

                frame_size = AV_RL32(buf) - 12; buf += 4; buf_size -= 4;

            }else{

                if(buf_size < 12) //MKV files can have zero flags after last block

                    break;

                frame_size = AV_RL32(buf + 8) + 12;

            }

        }

        if(frame_size < 0 || frame_size > buf_size){

            av_log(avctx, AV_LOG_ERROR, "Block %d has invalid size (size %d vs. %d bytes left)\n",

                   s->block, frame_size, buf_size);

            return -1;

        }

        if((samplecount = wavpack_decode_block(avctx, s->block, data,

                                               data_size, buf, frame_size)) < 0)

            return -1;

        s->block++;

        buf += frame_size; buf_size -= frame_size;

    }

    *data_size = samplecount * avctx->channels;



    return s->samples_left > 0 ? 0 : avpkt->size;

}

static int wavpack_decode_frame(AVCodecContext *avctx,

                            void *data, int *data_size,

                            AVPacket *avpkt)

{

    WavpackContext *s = avctx->priv_data;

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    int frame_size;

    int samplecount = 0;



    s->block = 0;

    s->samples_left = 0;

    s->ch_offset = 0;



    if(s->mkv_mode){

        s->samples = AV_RL32(buf); buf += 4;

    }

    while(buf_size > 0){

        if(!s->multichannel){

            frame_size = buf_size;

        }else{

            if(!s->mkv_mode){

                frame_size = AV_RL32(buf) - 12; buf += 4; buf_size -= 4;

            }else{

                if(buf_size < 12) 

                    break;

                frame_size = AV_RL32(buf + 8) + 12;

            }

        }

        if(frame_size < 0 || frame_size > buf_size){

            av_log(avctx, AV_LOG_ERROR, "Block %d has invalid size (size %d vs. %d bytes left)\n",

                   s->block, frame_size, buf_size);

            return -1;

        }

        if((samplecount = wavpack_decode_block(avctx, s->block, data,

                                               data_size, buf, frame_size)) < 0)

            return -1;

        s->block++;

        buf += frame_size; buf_size -= frame_size;

    }

    *data_size = samplecount * avctx->channels;



    return s->samples_left > 0 ? 0 : avpkt->size;

}

                                               data_size, buf, frame_size)) < 0)     WavpackContext *s = avctx->priv_data;
static int FUNC_0(AVCodecContext *VAR_0,

                            void *VAR_1, int *VAR_2,

                            AVPacket *VAR_3)

{

    WavpackContext *s = VAR_0->priv_data;

    const uint8_t *VAR_4 = VAR_3->VAR_1;

    int VAR_5 = VAR_3->size;

    int VAR_6;

    int VAR_7 = 0;



    s->block = 0;

    s->samples_left = 0;

    s->ch_offset = 0;



    if(s->mkv_mode){

        s->samples = AV_RL32(VAR_4); VAR_4 += 4;

    }

    while(VAR_5 > 0){

        if(!s->multichannel){

            VAR_6 = VAR_5;

        }else{

            if(!s->mkv_mode){

                VAR_6 = AV_RL32(VAR_4) - 12; VAR_4 += 4; VAR_5 -= 4;

            }else{

                if(VAR_5 < 12) 

                    break;

                VAR_6 = AV_RL32(VAR_4 + 8) + 12;

            }

        }

        if(VAR_6 < 0 || VAR_6 > VAR_5){

            av_log(VAR_0, AV_LOG_ERROR, "Block %d has invalid size (size %d vs. %d bytes left)\n",

                   s->block, VAR_6, VAR_5);

            return -1;

        }

        if((VAR_7 = wavpack_decode_block(VAR_0, s->block, VAR_1,

                                               VAR_2, VAR_4, VAR_6)) < 0)

            return -1;

        s->block++;

        VAR_4 += VAR_6; VAR_5 -= VAR_6;

    }

    *VAR_2 = VAR_7 * VAR_0->channels;



    return s->samples_left > 0 ? 0 : VAR_3->size;

}

static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{ WavpackContext *s = VAR_0->priv_data; const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; int VAR_6; int VAR_7 = 0; s->block = 0; s->samples_left = 0; s->ch_offset = 0; if(s->mkv_mode){ s->samples = AV_RL32(VAR_4); VAR_4 += 4; } while(VAR_5 > 0){ if(!s->multichannel){ VAR_6 = VAR_5; }else{ if(!s->mkv_mode){ VAR_6 = AV_RL32(VAR_4) - 12; VAR_4 += 4; VAR_5 -= 4; }else{ if(VAR_5 < 12)
break; VAR_6 = AV_RL32(VAR_4 + 8) + 12; } } if(VAR_6 < 0 || VAR_6 > VAR_5){ av_log(VAR_0, AV_LOG_ERROR, "Block %d has invalid size (size %d vs. %d bytes left)\n",
s->block, VAR_6, VAR_5); return -1; } if((VAR_7 = wavpack_decode_block(VAR_0, s->block, VAR_1,
VAR_2, VAR_4, VAR_6)) < 0)
return -1; s->block++; VAR_4 += VAR_6; VAR_5 -= VAR_6; } *VAR_2 = VAR_7 * VAR_0->channels; return s->samples_left > 0 ? 0 : VAR_3->size; }