Mercurial > libavformat.hg
comparison wc3movie.c @ 1673:a782462e2497 libavformat
rename BE/LE_8/16/32 to AV_RL/B_8/16/32
author | alex |
---|---|
date | Fri, 19 Jan 2007 22:12:59 +0000 |
parents | 0899bfe4105c |
children | 2f0154760e5f |
comparison
equal
deleted
inserted
replaced
1672:818eafa8fc95 | 1673:a782462e2497 |
---|---|
113 static int wc3_probe(AVProbeData *p) | 113 static int wc3_probe(AVProbeData *p) |
114 { | 114 { |
115 if (p->buf_size < 12) | 115 if (p->buf_size < 12) |
116 return 0; | 116 return 0; |
117 | 117 |
118 if ((LE_32(&p->buf[0]) != FORM_TAG) || | 118 if ((AV_RL32(&p->buf[0]) != FORM_TAG) || |
119 (LE_32(&p->buf[8]) != MOVE_TAG)) | 119 (AV_RL32(&p->buf[8]) != MOVE_TAG)) |
120 return 0; | 120 return 0; |
121 | 121 |
122 return AVPROBE_SCORE_MAX; | 122 return AVPROBE_SCORE_MAX; |
123 } | 123 } |
124 | 124 |
151 /* traverse through the chunks and load the header information before | 151 /* traverse through the chunks and load the header information before |
152 * the first BRCH tag */ | 152 * the first BRCH tag */ |
153 if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) != | 153 if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) != |
154 WC3_PREAMBLE_SIZE) | 154 WC3_PREAMBLE_SIZE) |
155 return AVERROR_IO; | 155 return AVERROR_IO; |
156 fourcc_tag = LE_32(&preamble[0]); | 156 fourcc_tag = AV_RL32(&preamble[0]); |
157 size = (BE_32(&preamble[4]) + 1) & (~1); | 157 size = (AV_RB32(&preamble[4]) + 1) & (~1); |
158 | 158 |
159 do { | 159 do { |
160 switch (fourcc_tag) { | 160 switch (fourcc_tag) { |
161 | 161 |
162 case SOND_TAG: | 162 case SOND_TAG: |
168 case _PC__TAG: | 168 case _PC__TAG: |
169 /* need the number of palettes */ | 169 /* need the number of palettes */ |
170 url_fseek(pb, 8, SEEK_CUR); | 170 url_fseek(pb, 8, SEEK_CUR); |
171 if ((ret = get_buffer(pb, preamble, 4)) != 4) | 171 if ((ret = get_buffer(pb, preamble, 4)) != 4) |
172 return AVERROR_IO; | 172 return AVERROR_IO; |
173 wc3->palette_count = LE_32(&preamble[0]); | 173 wc3->palette_count = AV_RL32(&preamble[0]); |
174 if((unsigned)wc3->palette_count >= UINT_MAX / PALETTE_SIZE){ | 174 if((unsigned)wc3->palette_count >= UINT_MAX / PALETTE_SIZE){ |
175 wc3->palette_count= 0; | 175 wc3->palette_count= 0; |
176 return -1; | 176 return -1; |
177 } | 177 } |
178 wc3->palettes = av_malloc(wc3->palette_count * PALETTE_SIZE); | 178 wc3->palettes = av_malloc(wc3->palette_count * PALETTE_SIZE); |
191 case SIZE_TAG: | 191 case SIZE_TAG: |
192 /* video resolution override */ | 192 /* video resolution override */ |
193 if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) != | 193 if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) != |
194 WC3_PREAMBLE_SIZE) | 194 WC3_PREAMBLE_SIZE) |
195 return AVERROR_IO; | 195 return AVERROR_IO; |
196 wc3->width = LE_32(&preamble[0]); | 196 wc3->width = AV_RL32(&preamble[0]); |
197 wc3->height = LE_32(&preamble[4]); | 197 wc3->height = AV_RL32(&preamble[4]); |
198 break; | 198 break; |
199 | 199 |
200 case PALT_TAG: | 200 case PALT_TAG: |
201 /* one of several palettes */ | 201 /* one of several palettes */ |
202 if ((unsigned)current_palette >= wc3->palette_count) | 202 if ((unsigned)current_palette >= wc3->palette_count) |
227 } | 227 } |
228 | 228 |
229 if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) != | 229 if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) != |
230 WC3_PREAMBLE_SIZE) | 230 WC3_PREAMBLE_SIZE) |
231 return AVERROR_IO; | 231 return AVERROR_IO; |
232 fourcc_tag = LE_32(&preamble[0]); | 232 fourcc_tag = AV_RL32(&preamble[0]); |
233 /* chunk sizes are 16-bit aligned */ | 233 /* chunk sizes are 16-bit aligned */ |
234 size = (BE_32(&preamble[4]) + 1) & (~1); | 234 size = (AV_RB32(&preamble[4]) + 1) & (~1); |
235 | 235 |
236 } while (fourcc_tag != BRCH_TAG); | 236 } while (fourcc_tag != BRCH_TAG); |
237 | 237 |
238 /* initialize the decoder streams */ | 238 /* initialize the decoder streams */ |
239 st = av_new_stream(s, 0); | 239 st = av_new_stream(s, 0); |
289 /* get the next chunk preamble */ | 289 /* get the next chunk preamble */ |
290 if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) != | 290 if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) != |
291 WC3_PREAMBLE_SIZE) | 291 WC3_PREAMBLE_SIZE) |
292 ret = AVERROR_IO; | 292 ret = AVERROR_IO; |
293 | 293 |
294 fourcc_tag = LE_32(&preamble[0]); | 294 fourcc_tag = AV_RL32(&preamble[0]); |
295 /* chunk sizes are 16-bit aligned */ | 295 /* chunk sizes are 16-bit aligned */ |
296 size = (BE_32(&preamble[4]) + 1) & (~1); | 296 size = (AV_RB32(&preamble[4]) + 1) & (~1); |
297 | 297 |
298 switch (fourcc_tag) { | 298 switch (fourcc_tag) { |
299 | 299 |
300 case BRCH_TAG: | 300 case BRCH_TAG: |
301 /* no-op */ | 301 /* no-op */ |
303 | 303 |
304 case SHOT_TAG: | 304 case SHOT_TAG: |
305 /* load up new palette */ | 305 /* load up new palette */ |
306 if ((ret = get_buffer(pb, preamble, 4)) != 4) | 306 if ((ret = get_buffer(pb, preamble, 4)) != 4) |
307 return AVERROR_IO; | 307 return AVERROR_IO; |
308 palette_number = LE_32(&preamble[0]); | 308 palette_number = AV_RL32(&preamble[0]); |
309 if (palette_number >= wc3->palette_count) | 309 if (palette_number >= wc3->palette_count) |
310 return AVERROR_INVALIDDATA; | 310 return AVERROR_INVALIDDATA; |
311 base_palette_index = palette_number * PALETTE_COUNT * 3; | 311 base_palette_index = palette_number * PALETTE_COUNT * 3; |
312 for (i = 0; i < PALETTE_COUNT; i++) { | 312 for (i = 0; i < PALETTE_COUNT; i++) { |
313 r = wc3->palettes[base_palette_index + i * 3 + 0]; | 313 r = wc3->palettes[base_palette_index + i * 3 + 0]; |