static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos){
    RMContext *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);
        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;
}
["static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos){\n    RMContext *rm = s->priv_data;\n    ByteIOContext *pb = s->pb;\n    int len, num, res, i;\n    AVStream *st;\n    uint32_t state=0xFFFFFFFF;\n    while(!url_feof(pb)){\n        *pos= url_ftell(pb);\n        if(rm->remaining_len > 0){\n            num= rm->current_stream;\n            len= rm->remaining_len;\n            *timestamp = AV_NOPTS_VALUE;\n            *flags= 0;\n        }else{\n            state= (state<<8) + get_byte(pb);\n            if(state == MKBETAG('I', 'N', 'D', 'X')){\n                len = get_be16(pb) - 6;\n                if(len<0)\n                    continue;\n                goto skip;\n            }\n            if(state > (unsigned)0xFFFF || state < 12)\n                continue;\n            len=state;\n            state= 0xFFFFFFFF;\n            num = get_be16(pb);\n            *timestamp = get_be32(pb);\n            res= get_byte(pb);\n            *flags = get_byte(pb);\n            len -= 12;\n        }\n        for(i=0;i<s->nb_streams;i++) {\n            st = s->streams[i];\n            if (num == st->id)\n                break;\n        }\n        if (i == s->nb_streams) {\nskip:\n            url_fskip(pb, len);\n            rm->remaining_len -= len;\n            continue;\n        }\n        *stream_index= i;\n        return len;\n    }\n    return -1;\n}", 'int get_byte(ByteIOContext *s)\n{\n    if (s->buf_ptr < s->buf_end) {\n        return *s->buf_ptr++;\n    } else {\n        fill_buffer(s);\n        if (s->buf_ptr < s->buf_end)\n            return *s->buf_ptr++;\n        else\n            return 0;\n    }\n}']