~ubuntu-branches/ubuntu/lucid/ffmpeg/lucid-security

« back to all changes in this revision

Viewing changes to libavformat/rmdec.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-03-13 09:18:28 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090313091828-n4ktby5eca487uhv
Tags: 3:0.svn20090303-1ubuntu1+unstripped1
merge from ubuntu.jaunty branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
    if (buf_size > 0) *q = '\0';
63
63
}
64
64
 
65
 
static void get_str16(ByteIOContext *pb, char *buf, int buf_size)
66
 
{
67
 
    get_strl(pb, buf, buf_size, get_be16(pb));
68
 
}
69
 
 
70
65
static void get_str8(ByteIOContext *pb, char *buf, int buf_size)
71
66
{
72
67
    get_strl(pb, buf, buf_size, get_byte(pb));
73
68
}
74
69
 
 
70
static void rm_read_metadata(AVFormatContext *s, int wide)
 
71
{
 
72
    char buf[1024];
 
73
    int i;
 
74
    for (i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) {
 
75
        int len = wide ? get_be16(s->pb) : get_byte(s->pb);
 
76
        get_strl(s->pb, buf, sizeof(buf), len);
 
77
        av_metadata_set(&s->metadata, ff_rm_metadata[i], buf);
 
78
    }
 
79
}
 
80
 
75
81
RMStream *ff_rm_alloc_rmstream (void)
76
82
{
77
83
    RMStream *rms = av_mallocz(sizeof(RMStream));
95
101
    if (((version >> 16) & 0xff) == 3) {
96
102
        int64_t startpos = url_ftell(pb);
97
103
        url_fskip(pb, 14);
98
 
        get_str8(pb, s->title, sizeof(s->title));
99
 
        get_str8(pb, s->author, sizeof(s->author));
100
 
        get_str8(pb, s->copyright, sizeof(s->copyright));
101
 
        get_str8(pb, s->comment, sizeof(s->comment));
 
104
        rm_read_metadata(s, 0);
102
105
        if ((startpos + (version & 0xffff)) >= url_ftell(pb) + 2) {
103
106
            // fourcc (should always be "lpcJ")
104
107
            get_byte(pb);
213
216
            get_byte(pb);
214
217
            get_byte(pb);
215
218
            get_byte(pb);
216
 
 
217
 
            get_str8(pb, s->title, sizeof(s->title));
218
 
            get_str8(pb, s->author, sizeof(s->author));
219
 
            get_str8(pb, s->copyright, sizeof(s->copyright));
220
 
            get_str8(pb, s->comment, sizeof(s->comment));
 
219
            rm_read_metadata(s, 0);
221
220
        }
222
221
    }
223
222
    return 0;
246
245
            goto skip;
247
246
        }
248
247
        st->codec->codec_tag = get_le32(pb);
249
 
//        av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));
 
248
//        av_log(s, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));
250
249
        if (   st->codec->codec_tag != MKTAG('R', 'V', '1', '0')
251
250
            && st->codec->codec_tag != MKTAG('R', 'V', '2', '0')
252
251
            && st->codec->codec_tag != MKTAG('R', 'V', '3', '0')
274
273
            return AVERROR(ENOMEM);
275
274
        get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
276
275
 
277
 
//        av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2);
 
276
//        av_log(s, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2);
278
277
        st->codec->time_base.den = fps * st->codec->time_base.num;
279
278
        switch(((uint8_t*)st->codec->extradata)[4]>>4){
280
279
        case 1: st->codec->codec_id = CODEC_ID_RV10; break;
364
363
            flags = get_be16(pb); /* flags */
365
364
            break;
366
365
        case MKTAG('C', 'O', 'N', 'T'):
367
 
            get_str16(pb, s->title, sizeof(s->title));
368
 
            get_str16(pb, s->author, sizeof(s->author));
369
 
            get_str16(pb, s->copyright, sizeof(s->copyright));
370
 
            get_str16(pb, s->comment, sizeof(s->comment));
 
366
            rm_read_metadata(s, 1);
371
367
            break;
372
368
        case MKTAG('M', 'D', 'P', 'R'):
373
369
            st = av_new_stream(s, 0);
659
655
    if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
660
656
        if(st->codec->codec_id == CODEC_ID_RV20){
661
657
            int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1);
662
 
            av_log(NULL, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *timestamp, *timestamp*512LL/25, seq);
 
658
            av_log(s, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *timestamp, *timestamp*512LL/25, seq);
663
659
 
664
660
            seq |= (*timestamp&~0x3FFF);
665
661
            if(seq - *timestamp >  0x2000) seq -= 0x4000;
828
824
 
829
825
AVInputFormat rm_demuxer = {
830
826
    "rm",
831
 
    NULL_IF_CONFIG_SMALL("RM format"),
 
827
    NULL_IF_CONFIG_SMALL("RealMedia format"),
832
828
    sizeof(RMDemuxContext),
833
829
    rm_probe,
834
830
    rm_read_header,