int size, frame_code=0; int frame_type= 0;
int size, i, frame_code=0;
static int nut_read_packet(AVFormatContext *s, AVPacket *pkt){    NUTContext *nut = s->priv_data;    ByteIOContext *bc = &s->pb;    int size, frame_code=0;    int frame_type= 0;    int64_t pos;    for(;;){        uint64_t tmp= nut->next_startcode;        nut->next_startcode=0;        if (url_feof(bc))            return -1;        if(!tmp){            frame_code = get_byte(bc);            if(frame_code == 'N'){                tmp= frame_code;                tmp<<=8 ; tmp |= get_byte(bc);                tmp<<=16; tmp |= get_be16(bc);                tmp<<=32; tmp |= get_be32(bc);            }        }        switch(tmp){        case KEYFRAME_STARTCODE:            frame_type = 2;            break;        case MAIN_STARTCODE:        case STREAM_STARTCODE:        case INDEX_STARTCODE:            get_packetheader(nut, bc, 8, 0);            url_fseek(bc, nut->written_packet_size + nut->packet_start, SEEK_SET);            break;        case INFO_STARTCODE:            if(decode_info_header(nut)<0)                goto resync;            break;        case 0:            if(decode_frame(nut, pkt, frame_code, frame_type)>=0)                return 0;        default:resync:            frame_type = 0;av_log(s, AV_LOG_DEBUG, "syncing from %lld\n", nut->packet_start+1);            tmp= find_any_startcode(bc, nut->packet_start+1);            if(tmp==0)                return -1;av_log(s, AV_LOG_DEBUG, "sync\n");            if(url_is_streamed(bc)){                nut->next_startcode= tmp;                break;            }            pos= url_ftell(bc) - 8;av_log(s, AV_LOG_DEBUG, "at %lld code=%llX\n", pos, tmp);            if(tmp==KEYFRAME_STARTCODE){                get_byte(bc);            }            get_v(bc);            size= get_v(bc);                        while(size > 2 && size < 100000 && nut->packet_start < pos - size){                url_fseek(bc, pos - size, SEEK_SET);                frame_code= get_byte(bc);                if(!(nut->frame_code[ frame_code ].flags & FLAG_FRAME_TYPE))                    break;                if(get_v(bc) != size)                    break;                pos -= size;                size= get_v(bc);av_log(s, AV_LOG_DEBUG, "steping back to %lld next %d\n", pos, size);            }            url_fseek(bc, pos, SEEK_SET);                        nut->written_packet_size= size;            nut->packet_start= pos - size;        }    }}