static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos){

    RMDemuxContext *rm = s->priv_data;

    ByteIOContext *pb = s->pb;

    int len, num, res, i;

    AVStream *st;

    uint32_t state=0xFFFFFFFF;



    while(!url_feof(pb)){

        *pos= url_ftell(pb) - 3;

        if(rm->remaining_len > 0){

            num= rm->current_stream;

            len= rm->remaining_len;

            *timestamp = AV_NOPTS_VALUE;

            *flags= 0;

        }else{

            state= (state<<8) + get_byte(pb);



            if(state == MKBETAG('I', 'N', 'D', 'X')){

                len = get_be16(pb) - 6;

                if(len<0)

                    continue;

                goto skip;

            }



            if(state > (unsigned)0xFFFF || state < 12)

                continue;

            len=state;

            state= 0xFFFFFFFF;



            num = get_be16(pb);

            *timestamp = get_be32(pb);

            res= get_byte(pb); /* reserved */

            *flags = get_byte(pb); /* flags */





            len -= 12;

        }

        for(i=0;i<s->nb_streams;i++) {

            st = s->streams[i];

            if (num == st->id)

                break;

        }

        if (i == s->nb_streams) {

skip:

            /* skip packet if unknown number */

            url_fskip(pb, len);

            rm->remaining_len -= len;

            continue;

        }

        *stream_index= i;



        return len;

    }

    return -1;

}

static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos){

    RMDemuxContext *rm = s->priv_data;

    ByteIOContext *pb = s->pb;

    int len, num, res, i;

    AVStream *st;

    uint32_t state=0xFFFFFFFF;



    while(!url_feof(pb)){

        *pos= url_ftell(pb) - 3;

        if(rm->remaining_len > 0){

            num= rm->current_stream;

            len= rm->remaining_len;

            *timestamp = AV_NOPTS_VALUE;

            *flags= 0;

        }else{

            state= (state<<8) + get_byte(pb);



            if(state == MKBETAG('I', 'N', 'D', 'X')){

                len = get_be16(pb) - 6;

                if(len<0)

                    continue;

                goto skip;

            }



            if(state > (unsigned)0xFFFF || state < 12)

                continue;

            len=state;

            state= 0xFFFFFFFF;



            num = get_be16(pb);

            *timestamp = get_be32(pb);

            res= get_byte(pb); 

            *flags = get_byte(pb); 





            len -= 12;

        }

        for(i=0;i<s->nb_streams;i++) {

            st = s->streams[i];

            if (num == st->id)

                break;

        }

        if (i == s->nb_streams) {

skip:

            

            url_fskip(pb, len);

            rm->remaining_len -= len;

            continue;

        }

        *stream_index= i;



        return len;

    }

    return -1;

}

            rm->remaining_len -= len;
static int FUNC_0(AVFormatContext *VAR_0, int64_t *VAR_1, int *VAR_2, int *VAR_3, int64_t *VAR_4){

    RMDemuxContext *rm = VAR_0->priv_data;

    ByteIOContext *pb = VAR_0->pb;

    int VAR_5, VAR_6, VAR_7, VAR_8;

    AVStream *st;

    uint32_t state=0xFFFFFFFF;



    while(!url_feof(pb)){

        *VAR_4= url_ftell(pb) - 3;

        if(rm->remaining_len > 0){

            VAR_6= rm->current_stream;

            VAR_5= rm->remaining_len;

            *VAR_1 = AV_NOPTS_VALUE;

            *VAR_2= 0;

        }else{

            state= (state<<8) + get_byte(pb);



            if(state == MKBETAG('I', 'N', 'D', 'X')){

                VAR_5 = get_be16(pb) - 6;

                if(VAR_5<0)

                    continue;

                goto skip;

            }



            if(state > (unsigned)0xFFFF || state < 12)

                continue;

            VAR_5=state;

            state= 0xFFFFFFFF;



            VAR_6 = get_be16(pb);

            *VAR_1 = get_be32(pb);

            VAR_7= get_byte(pb); 

            *VAR_2 = get_byte(pb); 





            VAR_5 -= 12;

        }

        for(VAR_8=0;VAR_8<VAR_0->nb_streams;VAR_8++) {

            st = VAR_0->streams[VAR_8];

            if (VAR_6 == st->id)

                break;

        }

        if (VAR_8 == VAR_0->nb_streams) {

skip:

            

            url_fskip(pb, VAR_5);

            rm->remaining_len -= VAR_5;

            continue;

        }

        *VAR_3= VAR_8;



        return VAR_5;

    }

    return -1;

}

static int FUNC_0(AVFormatContext *VAR_0, int64_t *VAR_1, int *VAR_2, int *VAR_3, int64_t *VAR_4){ RMDemuxContext *rm = VAR_0->priv_data; ByteIOContext *pb = VAR_0->pb; int VAR_5, VAR_6, VAR_7, VAR_8; AVStream *st; uint32_t state=0xFFFFFFFF; while(!url_feof(pb)){ *VAR_4= url_ftell(pb) - 3; if(rm->remaining_len > 0){ VAR_6= rm->current_stream; VAR_5= rm->remaining_len; *VAR_1 = AV_NOPTS_VALUE; *VAR_2= 0; }else{ state= (state<<8) + get_byte(pb); if(state == MKBETAG('I', 'N', 'D', 'X')){ VAR_5 = get_be16(pb) - 6; if(VAR_5<0)
continue; goto skip; } if(state > (unsigned)0xFFFF || state < 12)
continue; VAR_5=state; state= 0xFFFFFFFF; VAR_6 = get_be16(pb); *VAR_1 = get_be32(pb); VAR_7= get_byte(pb); *VAR_2 = get_byte(pb); VAR_5 -= 12; } for(VAR_8=0;VAR_8<VAR_0->nb_streams;VAR_8++) { st = VAR_0->streams[VAR_8]; if (VAR_6 == st->id)
break; } if (VAR_8 == VAR_0->nb_streams) { skip:
url_fskip(pb, VAR_5); rm->remaining_len -= VAR_5; continue; } *VAR_3= VAR_8; return VAR_5; } return -1; }