static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)

{

    MPCContext *c = s->priv_data;

    int ret, size, size2, curbits, cur = c->curframe;

    int64_t tmp, pos;



    if (c->curframe >= c->fcount)

        return -1;



    if(c->curframe != c->lastframe + 1){

        url_fseek(s->pb, c->frames[c->curframe].pos, SEEK_SET);

        c->curbits = c->frames[c->curframe].skip;

    }

    c->lastframe = c->curframe;

    c->curframe++;

    curbits = c->curbits;

    pos = url_ftell(s->pb);

    tmp = get_le32(s->pb);

    if(curbits <= 12){

        size2 = (tmp >> (12 - curbits)) & 0xFFFFF;

    }else{

        tmp = (tmp << 32) | get_le32(s->pb);

        size2 = (tmp >> (44 - curbits)) & 0xFFFFF;

    }

    curbits += 20;

    url_fseek(s->pb, pos, SEEK_SET);



    size = ((size2 + curbits + 31) & ~31) >> 3;

    if(cur == c->frames_noted){

        c->frames[cur].pos = pos;

        c->frames[cur].size = size;

        c->frames[cur].skip = curbits - 20;

        av_add_index_entry(s->streams[0], cur, cur, size, 0, AVINDEX_KEYFRAME);

        c->frames_noted++;

    }

    c->curbits = (curbits + size2) & 0x1F;



    if (av_new_packet(pkt, size) < 0)

        return AVERROR(EIO);



    pkt->data[0] = curbits;

    pkt->data[1] = (c->curframe > c->fcount);





    pkt->stream_index = 0;

    pkt->pts = cur;

    ret = get_buffer(s->pb, pkt->data + 4, size);

    if(c->curbits)

        url_fseek(s->pb, -4, SEEK_CUR);

    if(ret < size){

        av_free_packet(pkt);

        return AVERROR(EIO);

    }

    pkt->size = ret + 4;



    return 0;

}
static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)

{

    MPCContext *c = s->priv_data;

    int ret, size, size2, curbits, cur = c->curframe;

    int64_t tmp, pos;



    if (c->curframe >= c->fcount)

        return -1;



    if(c->curframe != c->lastframe + 1){

        url_fseek(s->pb, c->frames[c->curframe].pos, SEEK_SET);

        c->curbits = c->frames[c->curframe].skip;

    }

    c->lastframe = c->curframe;

    c->curframe++;

    curbits = c->curbits;

    pos = url_ftell(s->pb);

    tmp = get_le32(s->pb);

    if(curbits <= 12){

        size2 = (tmp >> (12 - curbits)) & 0xFFFFF;

    }else{

        tmp = (tmp << 32) | get_le32(s->pb);

        size2 = (tmp >> (44 - curbits)) & 0xFFFFF;

    }

    curbits += 20;

    url_fseek(s->pb, pos, SEEK_SET);



    size = ((size2 + curbits + 31) & ~31) >> 3;

    if(cur == c->frames_noted){

        c->frames[cur].pos = pos;

        c->frames[cur].size = size;

        c->frames[cur].skip = curbits - 20;

        av_add_index_entry(s->streams[0], cur, cur, size, 0, AVINDEX_KEYFRAME);

        c->frames_noted++;

    }

    c->curbits = (curbits + size2) & 0x1F;



    if (av_new_packet(pkt, size) < 0)

        return AVERROR(EIO);



    pkt->data[0] = curbits;

    pkt->data[1] = (c->curframe > c->fcount);





    pkt->stream_index = 0;

    pkt->pts = cur;

    ret = get_buffer(s->pb, pkt->data + 4, size);

    if(c->curbits)

        url_fseek(s->pb, -4, SEEK_CUR);

    if(ret < size){

        av_free_packet(pkt);

        return AVERROR(EIO);

    }

    pkt->size = ret + 4;



    return 0;

}
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)

{

    MPCContext *c = VAR_0->priv_data;

    int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6 = c->curframe;

    int64_t tmp, pos;



    if (c->curframe >= c->fcount)

        return -1;



    if(c->curframe != c->lastframe + 1){

        url_fseek(VAR_0->pb, c->frames[c->curframe].pos, SEEK_SET);

        c->VAR_5 = c->frames[c->curframe].skip;

    }

    c->lastframe = c->curframe;

    c->curframe++;

    VAR_5 = c->VAR_5;

    pos = url_ftell(VAR_0->pb);

    tmp = get_le32(VAR_0->pb);

    if(VAR_5 <= 12){

        VAR_4 = (tmp >> (12 - VAR_5)) & 0xFFFFF;

    }else{

        tmp = (tmp << 32) | get_le32(VAR_0->pb);

        VAR_4 = (tmp >> (44 - VAR_5)) & 0xFFFFF;

    }

    VAR_5 += 20;

    url_fseek(VAR_0->pb, pos, SEEK_SET);



    VAR_3 = ((VAR_4 + VAR_5 + 31) & ~31) >> 3;

    if(VAR_6 == c->frames_noted){

        c->frames[VAR_6].pos = pos;

        c->frames[VAR_6].VAR_3 = VAR_3;

        c->frames[VAR_6].skip = VAR_5 - 20;

        av_add_index_entry(VAR_0->streams[0], VAR_6, VAR_6, VAR_3, 0, AVINDEX_KEYFRAME);

        c->frames_noted++;

    }

    c->VAR_5 = (VAR_5 + VAR_4) & 0x1F;



    if (av_new_packet(VAR_1, VAR_3) < 0)

        return AVERROR(EIO);



    VAR_1->data[0] = VAR_5;

    VAR_1->data[1] = (c->curframe > c->fcount);





    VAR_1->stream_index = 0;

    VAR_1->pts = VAR_6;

    VAR_2 = get_buffer(VAR_0->pb, VAR_1->data + 4, VAR_3);

    if(c->VAR_5)

        url_fseek(VAR_0->pb, -4, SEEK_CUR);

    if(VAR_2 < VAR_3){

        av_free_packet(VAR_1);

        return AVERROR(EIO);

    }

    VAR_1->VAR_3 = VAR_2 + 4;



    return 0;

}
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)
{ MPCContext *c = VAR_0->priv_data; int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6 = c->curframe; int64_t tmp, pos; if (c->curframe >= c->fcount)
return -1; if(c->curframe != c->lastframe + 1){ url_fseek(VAR_0->pb, c->frames[c->curframe].pos, SEEK_SET); c->VAR_5 = c->frames[c->curframe].skip; } c->lastframe = c->curframe; c->curframe++; VAR_5 = c->VAR_5; pos = url_ftell(VAR_0->pb); tmp = get_le32(VAR_0->pb); if(VAR_5 <= 12){ VAR_4 = (tmp >> (12 - VAR_5)) & 0xFFFFF; }else{ tmp = (tmp << 32) | get_le32(VAR_0->pb); VAR_4 = (tmp >> (44 - VAR_5)) & 0xFFFFF; } VAR_5 += 20; url_fseek(VAR_0->pb, pos, SEEK_SET); VAR_3 = ((VAR_4 + VAR_5 + 31) & ~31) >> 3; if(VAR_6 == c->frames_noted){ c->frames[VAR_6].pos = pos; c->frames[VAR_6].VAR_3 = VAR_3; c->frames[VAR_6].skip = VAR_5 - 20; av_add_index_entry(VAR_0->streams[0], VAR_6, VAR_6, VAR_3, 0, AVINDEX_KEYFRAME); c->frames_noted++; } c->VAR_5 = (VAR_5 + VAR_4) & 0x1F; if (av_new_packet(VAR_1, VAR_3) < 0)
return AVERROR(EIO); VAR_1->data[0] = VAR_5; VAR_1->data[1] = (c->curframe > c->fcount); VAR_1->stream_index = 0; VAR_1->pts = VAR_6; VAR_2 = get_buffer(VAR_0->pb, VAR_1->data + 4, VAR_3); if(c->VAR_5)
url_fseek(VAR_0->pb, -4, SEEK_CUR); if(VAR_2 < VAR_3){ av_free_packet(VAR_1); return AVERROR(EIO); } VAR_1->VAR_3 = VAR_2 + 4; return 0; }