next_frame:
next_frame:;
static int asf_read_packet(AVFormatContext *s, AVPacket *pkt){    ASFContext *asf = s->priv_data;    AVStream *st;    ASFStream *asf_st;    ByteIOContext *pb = &s->pb;    int ret, num, seq, frag_offset, payload_size, frag_len;    int timestamp, i;    for(;;) {        if (asf->packet_size_left < FRAME_HEADER_SIZE ||            asf->packet_size_left <= asf->packet_padsize) {            /* fail safe */            if (asf->packet_size_left)                url_fskip(pb, asf->packet_size_left);            ret = asf_get_packet(s);            if (ret < 0)                return -EIO;        }        /* read frame header */        num = get_byte(pb) & 0x7f;        seq = get_byte(pb);        frag_offset = get_le32(pb);        get_byte(pb); /* flags */        payload_size = get_le32(pb);        timestamp = get_le32(pb);        frag_len = get_le16(pb);#ifdef DEBUG        printf("num=%d seq=%d totsize=%d frag_off=%d frag_size=%d\n",               num, seq, payload_size, frag_offset, frag_len);#endif        st = NULL;        for(i=0;i<s->nb_streams;i++) {            st = s->streams[i];            if (st->id == num)                break;        }        asf->packet_size_left -= FRAME_HEADER_SIZE + frag_len;        if (i == s->nb_streams) {            /* unhandled packet (should not happen) */            url_fskip(pb, frag_len);        } else {            asf_st = st->priv_data;            if (asf_st->frag_offset == 0) {                /* new packet */                av_new_packet(&asf_st->pkt, payload_size);                asf_st->seq = seq;            } else {                if (seq == asf_st->seq &&                     frag_offset == asf_st->frag_offset) {                    /* continuing packet */                } else {                    /* cannot continue current packet: free it */                    av_free_packet(&asf_st->pkt);                    asf_st->frag_offset = 0;                    if (frag_offset != 0) {                        /* cannot create new packet */                        url_fskip(pb, frag_len);                        goto next_frame;                    } else {                        /* create new packet */                        av_new_packet(&asf_st->pkt, payload_size);                        asf_st->seq = seq;                    }                }            }            /* read data */            get_buffer(pb, asf_st->pkt.data + frag_offset, frag_len);            asf_st->frag_offset += frag_len;            /* test if whole packet read */            if (asf_st->frag_offset == asf_st->pkt.size) {                /* return packet */                asf_st->pkt.stream_index = i;                asf_st->frag_offset = 0;                memcpy(pkt, &asf_st->pkt, sizeof(AVPacket));                 break;            }        }    next_frame:    }    return 0;}