comparison oggparsetheora.c @ 758:7bbe565d50db libavformat

check theora version
author mru
date Thu, 12 May 2005 22:33:05 +0000
parents 27449ee55201
children feca73904e67
comparison
equal deleted inserted replaced
757:7177bd7f1f47 758:7bbe565d50db
41 AVStream *st = s->streams[idx]; 41 AVStream *st = s->streams[idx];
42 theora_params_t *thp = os->private; 42 theora_params_t *thp = os->private;
43 int cds = st->codec.extradata_size + os->psize + 2; 43 int cds = st->codec.extradata_size + os->psize + 2;
44 uint8_t *cdp; 44 uint8_t *cdp;
45 45
46 if (os->seq > 2) 46 if(!(os->buf[os->pstart] & 0x80))
47 return 0; 47 return 0;
48 48
49 if(!thp){ 49 if(!thp){
50 thp = av_mallocz(sizeof(*thp)); 50 thp = av_mallocz(sizeof(*thp));
51 os->private = thp; 51 os->private = thp;
54 if (os->buf[os->pstart] == 0x80) { 54 if (os->buf[os->pstart] == 0x80) {
55 GetBitContext gb; 55 GetBitContext gb;
56 init_get_bits(&gb, os->buf + os->pstart, os->psize*8); 56 init_get_bits(&gb, os->buf + os->pstart, os->psize*8);
57 57
58 skip_bits(&gb, 7*8); /* 0x80"theora" */ 58 skip_bits(&gb, 7*8); /* 0x80"theora" */
59 skip_bits(&gb, 3*8); 59 if(get_bits(&gb, 8) != 3) /* major version */
60 60 return -1;
61 if(get_bits(&gb, 8) != 2) /* minor version */
62 return -1;
63 skip_bits(&gb, 8); /* revision */
64
61 st->codec.width = get_bits(&gb, 16) << 4; 65 st->codec.width = get_bits(&gb, 16) << 4;
62 st->codec.height = get_bits(&gb, 16) << 4; 66 st->codec.height = get_bits(&gb, 16) << 4;
63 67
64 skip_bits(&gb, 64); 68 skip_bits(&gb, 64);
65 st->codec.time_base.den = get_bits(&gb, 32); 69 st->codec.time_base.den = get_bits(&gb, 32);
84 *cdp++ = os->psize >> 8; 88 *cdp++ = os->psize >> 8;
85 *cdp++ = os->psize & 0xff; 89 *cdp++ = os->psize & 0xff;
86 memcpy (cdp, os->buf + os->pstart, os->psize); 90 memcpy (cdp, os->buf + os->pstart, os->psize);
87 st->codec.extradata_size = cds; 91 st->codec.extradata_size = cds;
88 92
89 93 return 1;
90 return os->seq < 3;
91 } 94 }
92 95
93 static uint64_t 96 static uint64_t
94 theora_gptopts(AVFormatContext *ctx, int idx, uint64_t gp) 97 theora_gptopts(AVFormatContext *ctx, int idx, uint64_t gp)
95 { 98 {