int flags;
int flags, res;
static int rm_read_packet(AVFormatContext *s, AVPacket *pkt){    RMContext *rm = s->priv_data;    ByteIOContext *pb = &s->pb;    AVStream *st;    int len, num, timestamp, i, tmp, j;    uint8_t *ptr;    int flags;    if (rm->old_format) {        /* just read raw bytes */        len = RAW_PACKET_SIZE;        av_new_packet(pkt, len);        pkt->stream_index = 0;        len = get_buffer(pb, pkt->data, len);        if (len <= 0) {            av_free_packet(pkt);            return AVERROR_IO;        }        pkt->size = len;        st = s->streams[0];    } else {    redo:        if (rm->nb_packets == 0)            return AVERROR_IO;        get_be16(pb);        len = get_be16(pb);        if (len < 12)            return AVERROR_IO;        num = get_be16(pb);        timestamp = get_be32(pb);        get_byte(pb); /* reserved */        flags = get_byte(pb); /* flags */        rm->nb_packets--;        len -= 12;                st = NULL;        for(i=0;i<s->nb_streams;i++) {            st = s->streams[i];            if (num == st->id)                break;        }        if (i == s->nb_streams) {            /* skip packet if unknown number */            url_fskip(pb, len);            goto redo;        }                if (st->codec.codec_type == CODEC_TYPE_VIDEO) {            int full_frame, h, pic_num;                        h= get_byte(pb);            if ((h & 0xc0) == 0xc0) {                int len2, pos;                full_frame = 1;                len2= get_num(pb, &len);                pos = get_num(pb, &len);                //printf("pos:%d\n",len);                len -= 2;            } else {                int seq, frame_size, pos;                full_frame = 0;                seq = get_byte(pb);                frame_size = get_num(pb, &len);                pos = get_num(pb, &len);                //printf("seq:%d, size:%d, pos:%d\n",seq,frame_size,pos);                len -= 3;            }            /* picture number */            pic_num= get_byte(pb);                        //XXX/FIXME/HACK, demuxer should be fixed to send complete frames ...            if(st->codec.slice_offset==NULL)                 st->codec.slice_offset= (int*)av_malloc(sizeof(int));            st->codec.slice_count= full_frame;             st->codec.slice_offset[0]= 0;        }                av_new_packet(pkt, len);        pkt->stream_index = i;        get_buffer(pb, pkt->data, len);    }    /* for AC3, needs to swap bytes */    if (st->codec.codec_id == CODEC_ID_AC3) {        ptr = pkt->data;        for(j=0;j<len;j+=2) {            tmp = ptr[0];            ptr[0] = ptr[1];            ptr[1] = tmp;                ptr += 2;        }    }    return 0;}