static int wv_read_packet(AVFormatContext *s,

                          AVPacket *pkt)

{

    WVContext *wc = s->priv_data;

    int ret, samples;



    if (url_feof(&s->pb))

        return -EIO;

    if(wc->block_parsed){

        if(wv_read_block_header(s, &s->pb) < 0)

            return -1;

    }



    samples = LE_32(wc->extra);

    /* should not happen but who knows */

    if(samples * 2 * wc->chan > AVCODEC_MAX_AUDIO_FRAME_SIZE){

        av_log(s, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n");

        return -EIO;

    }

    if(av_new_packet(pkt, wc->blksize + WV_EXTRA_SIZE) < 0)

        return AVERROR_NOMEM;

    memcpy(pkt->data, wc->extra, WV_EXTRA_SIZE);

    ret = get_buffer(&s->pb, pkt->data + WV_EXTRA_SIZE, wc->blksize);

    if(ret != wc->blksize){

        av_free_packet(pkt);

        return AVERROR_IO;

    }

    pkt->stream_index = 0;

    wc->block_parsed = 1;

    pkt->size = ret + WV_EXTRA_SIZE;



    return 0;

}

static int wv_read_packet(AVFormatContext *s,

                          AVPacket *pkt)

{

    WVContext *wc = s->priv_data;

    int ret, samples;



    if (url_feof(&s->pb))

        return -EIO;

    if(wc->block_parsed){

        if(wv_read_block_header(s, &s->pb) < 0)

            return -1;

    }



    samples = LE_32(wc->extra);

    

    if(samples * 2 * wc->chan > AVCODEC_MAX_AUDIO_FRAME_SIZE){

        av_log(s, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n");

        return -EIO;

    }

    if(av_new_packet(pkt, wc->blksize + WV_EXTRA_SIZE) < 0)

        return AVERROR_NOMEM;

    memcpy(pkt->data, wc->extra, WV_EXTRA_SIZE);

    ret = get_buffer(&s->pb, pkt->data + WV_EXTRA_SIZE, wc->blksize);

    if(ret != wc->blksize){

        av_free_packet(pkt);

        return AVERROR_IO;

    }

    pkt->stream_index = 0;

    wc->block_parsed = 1;

    pkt->size = ret + WV_EXTRA_SIZE;



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0,

                          AVPacket *VAR_1)

{

    WVContext *wc = VAR_0->priv_data;

    int VAR_2, VAR_3;



    if (url_feof(&VAR_0->pb))

        return -EIO;

    if(wc->block_parsed){

        if(wv_read_block_header(VAR_0, &VAR_0->pb) < 0)

            return -1;

    }



    VAR_3 = LE_32(wc->extra);

    

    if(VAR_3 * 2 * wc->chan > AVCODEC_MAX_AUDIO_FRAME_SIZE){

        av_log(VAR_0, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n");

        return -EIO;

    }

    if(av_new_packet(VAR_1, wc->blksize + WV_EXTRA_SIZE) < 0)

        return AVERROR_NOMEM;

    memcpy(VAR_1->data, wc->extra, WV_EXTRA_SIZE);

    VAR_2 = get_buffer(&VAR_0->pb, VAR_1->data + WV_EXTRA_SIZE, wc->blksize);

    if(VAR_2 != wc->blksize){

        av_free_packet(VAR_1);

        return AVERROR_IO;

    }

    VAR_1->stream_index = 0;

    wc->block_parsed = 1;

    VAR_1->size = VAR_2 + WV_EXTRA_SIZE;



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{ WVContext *wc = VAR_0->priv_data; int VAR_2, VAR_3; if (url_feof(&VAR_0->pb))
return -EIO; if(wc->block_parsed){ if(wv_read_block_header(VAR_0, &VAR_0->pb) < 0)
return -1; } VAR_3 = LE_32(wc->extra); if(VAR_3 * 2 * wc->chan > AVCODEC_MAX_AUDIO_FRAME_SIZE){ av_log(VAR_0, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n"); return -EIO; } if(av_new_packet(VAR_1, wc->blksize + WV_EXTRA_SIZE) < 0)
return AVERROR_NOMEM; memcpy(VAR_1->data, wc->extra, WV_EXTRA_SIZE); VAR_2 = get_buffer(&VAR_0->pb, VAR_1->data + WV_EXTRA_SIZE, wc->blksize); if(VAR_2 != wc->blksize){ av_free_packet(VAR_1); return AVERROR_IO; } VAR_1->stream_index = 0; wc->block_parsed = 1; VAR_1->size = VAR_2 + WV_EXTRA_SIZE; return 0; }