st->codec.frame_rate = get_be16(pb) * FRAME_RATE_BASE;
st->codec.frame_rate_base= 1; st->codec.frame_rate = get_be16(pb) * st->codec.frame_rate_base;
static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap){    RMContext *rm = s->priv_data;    AVStream *st;    ByteIOContext *pb = &s->pb;    unsigned int tag, v;    int tag_size, size, codec_data_size, i;    int64_t codec_pos;    unsigned int h263_hack_version;    char buf[128];    int flags = 0;    if (get_le32(pb) != MKTAG('.', 'R', 'M', 'F'))        return -EIO;    get_be32(pb); /* header size */    get_be16(pb);    get_be32(pb);    get_be32(pb); /* number of headers */        for(;;) {        if (url_feof(pb))            goto fail;        tag = get_le32(pb);        tag_size = get_be32(pb);        get_be16(pb);#if 0        printf("tag=%c%c%c%c (%08x) size=%d\n",                (tag) & 0xff,               (tag >> 8) & 0xff,               (tag >> 16) & 0xff,               (tag >> 24) & 0xff,               tag,               tag_size);#endif        if (tag_size < 10)            goto fail;        switch(tag) {        case MKTAG('P', 'R', 'O', 'P'):            /* file header */            get_be32(pb); /* max bit rate */            get_be32(pb); /* avg bit rate */            get_be32(pb); /* max packet size */            get_be32(pb); /* avg packet size */            get_be32(pb); /* nb packets */            get_be32(pb); /* duration */            get_be32(pb); /* preroll */            get_be32(pb); /* index offset */            get_be32(pb); /* data offset */            get_be16(pb); /* nb streams */            flags = get_be16(pb); /* flags */            break;        case MKTAG('C', 'O', 'N', 'T'):            get_str(pb, s->title, sizeof(s->title));            get_str(pb, s->author, sizeof(s->author));            get_str(pb, s->copyright, sizeof(s->copyright));            get_str(pb, s->comment, sizeof(s->comment));            break;        case MKTAG('M', 'D', 'P', 'R'):            st = av_mallocz(sizeof(AVStream));            if (!st)                goto fail;            avcodec_get_context_defaults(&st->codec);            s->streams[s->nb_streams++] = st;            st->id = get_be16(pb);            get_be32(pb); /* max bit rate */            st->codec.bit_rate = get_be32(pb); /* bit rate */            get_be32(pb); /* max packet size */            get_be32(pb); /* avg packet size */            get_be32(pb); /* start time */            get_be32(pb); /* preroll */            get_be32(pb); /* duration */            get_str8(pb, buf, sizeof(buf)); /* desc */            get_str8(pb, buf, sizeof(buf)); /* mimetype */            codec_data_size = get_be32(pb);            codec_pos = url_ftell(pb);            v = get_be32(pb);            if (v == MKTAG(0xfd, 'a', 'r', '.')) {                /* ra type header */                get_be32(pb); /* version */                get_be32(pb); /* .ra4 */                get_be32(pb);                get_be16(pb);                get_be32(pb); /* header size */                get_be16(pb); /* add codec info */                get_be32(pb); /* coded frame size */                get_be32(pb); /* ??? */                get_be32(pb); /* ??? */                get_be32(pb); /* ??? */                get_be16(pb); /* 1 */                 get_be16(pb); /* coded frame size */                get_be32(pb);                st->codec.sample_rate = get_be16(pb);                get_be32(pb);                st->codec.channels = get_be16(pb);                get_str8(pb, buf, sizeof(buf)); /* desc */                get_str8(pb, buf, sizeof(buf)); /* desc */                st->codec.codec_type = CODEC_TYPE_AUDIO;                if (!strcmp(buf, "dnet")) {                    st->codec.codec_id = CODEC_ID_AC3;                } else {                    st->codec.codec_id = CODEC_ID_NONE;                    pstrcpy(st->codec.codec_name, sizeof(st->codec.codec_name),                            buf);                }            } else {                if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {                fail1:                    fprintf(stderr, "Unsupported video codec\n");                    goto fail;                }                st->codec.codec_tag = get_le32(pb);                if (st->codec.codec_tag != MKTAG('R', 'V', '1', '0'))                    goto fail1;                st->codec.width = get_be16(pb);                st->codec.height = get_be16(pb);                st->codec.frame_rate = get_be16(pb) * FRAME_RATE_BASE;                st->codec.codec_type = CODEC_TYPE_VIDEO;                get_be32(pb);                get_be16(pb);                get_be32(pb);                get_be16(pb);                /* modification of h263 codec version (!) */                h263_hack_version = get_be32(pb);                switch(h263_hack_version) {                case 0x10000000:                case 0x10003000:                case 0x10003001:                    st->codec.sub_id = h263_hack_version;                    st->codec.codec_id = CODEC_ID_RV10;                    break;                default:                    /* not handled */                    st->codec.codec_id = CODEC_ID_NONE;                    break;                }            }            /* skip codec info */            size = url_ftell(pb) - codec_pos;            url_fskip(pb, codec_data_size - size);            break;        case MKTAG('D', 'A', 'T', 'A'):            goto header_end;        default:            /* unknown tag: skip it */            url_fskip(pb, tag_size - 10);            break;        }    } header_end:    rm->nb_packets = get_be32(pb); /* number of packets */    if (!rm->nb_packets && (flags & 4))        rm->nb_packets = 3600 * 25;    get_be32(pb); /* next data header */    return 0; fail:    for(i=0;i<s->nb_streams;i++) {        av_free(s->streams[i]);    }    return -EIO;}