Mercurial > libavformat.hg
comparison oggparseogm.c @ 2226:c2ad35fbbd30 libavformat
use bytestream_get_* and AV_RLxx
author | mru |
---|---|
date | Sat, 07 Jul 2007 20:50:31 +0000 |
parents | 6a5e58d2114b |
children | 4db0808c3f91 |
comparison
equal
deleted
inserted
replaced
2225:7e5e26f8052a | 2226:c2ad35fbbd30 |
---|---|
23 **/ | 23 **/ |
24 | 24 |
25 #include <stdlib.h> | 25 #include <stdlib.h> |
26 #include "avformat.h" | 26 #include "avformat.h" |
27 #include "bitstream.h" | 27 #include "bitstream.h" |
28 #include "bswap.h" | 28 #include "bytestream.h" |
29 #include "intreadwrite.h" | |
29 #include "ogg2.h" | 30 #include "ogg2.h" |
30 #include "riff.h" | 31 #include "riff.h" |
31 | 32 |
32 static int | 33 static int |
33 ogm_header(AVFormatContext *s, int idx) | 34 ogm_header(AVFormatContext *s, int idx) |
49 | 50 |
50 if(*p == 'v'){ | 51 if(*p == 'v'){ |
51 int tag; | 52 int tag; |
52 st->codec->codec_type = CODEC_TYPE_VIDEO; | 53 st->codec->codec_type = CODEC_TYPE_VIDEO; |
53 p += 8; | 54 p += 8; |
54 tag = le2me_32(unaligned32(p)); | 55 tag = bytestream_get_le32(&p); |
55 st->codec->codec_id = codec_get_bmp_id(tag); | 56 st->codec->codec_id = codec_get_bmp_id(tag); |
56 st->codec->codec_tag = tag; | 57 st->codec->codec_tag = tag; |
57 } else { | 58 } else { |
59 uint8_t acid[5]; | |
58 int cid; | 60 int cid; |
59 st->codec->codec_type = CODEC_TYPE_AUDIO; | 61 st->codec->codec_type = CODEC_TYPE_AUDIO; |
60 p += 8; | 62 p += 8; |
61 p[4] = 0; | 63 bytestream_get_buffer(&p, acid, 4); |
62 cid = strtol(p, NULL, 16); | 64 acid[4] = 0; |
65 cid = strtol(acid, NULL, 16); | |
63 st->codec->codec_id = codec_get_wav_id(cid); | 66 st->codec->codec_id = codec_get_wav_id(cid); |
64 } | 67 } |
65 | 68 |
66 p += 4; | |
67 p += 4; /* useless size field */ | 69 p += 4; /* useless size field */ |
68 | 70 |
69 time_unit = le2me_64(unaligned64(p)); | 71 time_unit = bytestream_get_le64(&p); |
70 p += 8; | 72 spu = bytestream_get_le64(&p); |
71 spu = le2me_64(unaligned64(p)); | 73 default_len = bytestream_get_le32(&p); |
72 p += 8; | |
73 default_len = le2me_32(unaligned32(p)); | |
74 p += 4; | |
75 | 74 |
76 p += 8; /* buffersize + bits_per_sample */ | 75 p += 8; /* buffersize + bits_per_sample */ |
77 | 76 |
78 if(st->codec->codec_type == CODEC_TYPE_VIDEO){ | 77 if(st->codec->codec_type == CODEC_TYPE_VIDEO){ |
79 st->codec->width = le2me_32(unaligned32(p)); | 78 st->codec->width = bytestream_get_le32(&p); |
80 p += 4; | 79 st->codec->height = bytestream_get_le32(&p); |
81 st->codec->height = le2me_32(unaligned32(p)); | |
82 st->codec->time_base.den = spu * 10000000; | 80 st->codec->time_base.den = spu * 10000000; |
83 st->codec->time_base.num = time_unit; | 81 st->codec->time_base.num = time_unit; |
84 st->time_base = st->codec->time_base; | 82 st->time_base = st->codec->time_base; |
85 } else { | 83 } else { |
86 st->codec->channels = le2me_16(unaligned16(p)); | 84 st->codec->channels = bytestream_get_le16(&p); |
87 p += 2; | |
88 p += 2; /* block_align */ | 85 p += 2; /* block_align */ |
89 st->codec->bit_rate = le2me_32(unaligned32(p)) * 8; | 86 st->codec->bit_rate = bytestream_get_le32(&p) * 8; |
90 st->codec->sample_rate = spu * 10000000 / time_unit; | 87 st->codec->sample_rate = spu * 10000000 / time_unit; |
91 st->time_base.num = 1; | 88 st->time_base.num = 1; |
92 st->time_base.den = st->codec->sample_rate; | 89 st->time_base.den = st->codec->sample_rate; |
93 } | 90 } |
94 | 91 |
107 if(!(*p & 1)) | 104 if(!(*p & 1)) |
108 return 0; | 105 return 0; |
109 if(*p != 1) | 106 if(*p != 1) |
110 return 1; | 107 return 1; |
111 | 108 |
112 t = le2me_32(unaligned32(p + 96)); | 109 t = AV_RL32(p + 96); |
113 | 110 |
114 if(t == 0x05589f80){ | 111 if(t == 0x05589f80){ |
115 st->codec->codec_type = CODEC_TYPE_VIDEO; | 112 st->codec->codec_type = CODEC_TYPE_VIDEO; |
116 st->codec->codec_id = codec_get_bmp_id(le2me_32(unaligned32(p + 68))); | 113 st->codec->codec_id = codec_get_bmp_id(AV_RL32(p + 68)); |
117 st->codec->time_base.den = 10000000; | 114 st->codec->time_base.den = 10000000; |
118 st->codec->time_base.num = le2me_64(unaligned64(p + 164)); | 115 st->codec->time_base.num = AV_RL64(p + 164); |
119 st->codec->width = le2me_32(unaligned32(p + 176)); | 116 st->codec->width = AV_RL32(p + 176); |
120 st->codec->height = le2me_32(unaligned32(p + 180)); | 117 st->codec->height = AV_RL32(p + 180); |
121 } else if(t == 0x05589f81){ | 118 } else if(t == 0x05589f81){ |
122 st->codec->codec_type = CODEC_TYPE_AUDIO; | 119 st->codec->codec_type = CODEC_TYPE_AUDIO; |
123 st->codec->codec_id = codec_get_wav_id(le2me_16(unaligned16(p+124))); | 120 st->codec->codec_id = codec_get_wav_id(AV_RL16(p + 124)); |
124 st->codec->channels = le2me_16(unaligned16(p + 126)); | 121 st->codec->channels = AV_RL16(p + 126); |
125 st->codec->sample_rate = le2me_32(unaligned32(p + 128)); | 122 st->codec->sample_rate = AV_RL32(p + 128); |
126 st->codec->bit_rate = le2me_32(unaligned32(p + 132)) * 8; | 123 st->codec->bit_rate = AV_RL32(p + 132) * 8; |
127 } | 124 } |
128 | 125 |
129 return 1; | 126 return 1; |
130 } | 127 } |
131 | 128 |