Mercurial > libavformat.hg
comparison electronicarts.c @ 2673:a9e2afed4aa7 libavformat
add parsing of 1SNh header in the EA demuxer
author | aurel |
---|---|
date | Thu, 25 Oct 2007 20:38:49 +0000 |
parents | 7f320fb9f1c9 |
children | feb0352f07e5 |
comparison
equal
deleted
inserted
replaced
2672:8345d33e23b3 | 2673:a9e2afed4aa7 |
---|---|
25 */ | 25 */ |
26 | 26 |
27 #include "avformat.h" | 27 #include "avformat.h" |
28 | 28 |
29 #define SCHl_TAG MKTAG('S', 'C', 'H', 'l') | 29 #define SCHl_TAG MKTAG('S', 'C', 'H', 'l') |
30 #define _SNh_TAG MKTAG('1', 'S', 'N', 'h') /* 1SNx header */ | |
31 #define EACS_TAG MKTAG('E', 'A', 'C', 'S') | |
32 #define _SNd_TAG MKTAG('1', 'S', 'N', 'd') /* 1SNx data */ | |
33 #define _SNe_TAG MKTAG('1', 'S', 'N', 'e') /* 1SNx end */ | |
30 #define PT00_TAG MKTAG('P', 'T', 0x0, 0x0) | 34 #define PT00_TAG MKTAG('P', 'T', 0x0, 0x0) |
31 #define GSTR_TAG MKTAG('G', 'S', 'T', 'R') | 35 #define GSTR_TAG MKTAG('G', 'S', 'T', 'R') |
32 #define SCDl_TAG MKTAG('S', 'C', 'D', 'l') | 36 #define SCDl_TAG MKTAG('S', 'C', 'D', 'l') |
33 #define SCEl_TAG MKTAG('S', 'C', 'E', 'l') | 37 #define SCEl_TAG MKTAG('S', 'C', 'E', 'l') |
34 #define MVhd_TAG MKTAG('M', 'V', 'h', 'd') | 38 #define MVhd_TAG MKTAG('M', 'V', 'h', 'd') |
168 ea->sample_rate = revision==3 ? 48000 : 22050; | 172 ea->sample_rate = revision==3 ? 48000 : 22050; |
169 | 173 |
170 return 1; | 174 return 1; |
171 } | 175 } |
172 | 176 |
177 /* | |
178 * Process EACS sound header | |
179 * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx | |
180 */ | |
181 static int process_audio_header_eacs(AVFormatContext *s) | |
182 { | |
183 EaDemuxContext *ea = s->priv_data; | |
184 ByteIOContext *pb = &s->pb; | |
185 int compression_type; | |
186 | |
187 ea->sample_rate = ea->big_endian ? get_be32(pb) : get_le32(pb); | |
188 ea->bytes = get_byte(pb); /* 1=8-bit, 2=16-bit */ | |
189 ea->num_channels = get_byte(pb); | |
190 compression_type = get_byte(pb); | |
191 url_fskip(pb, 13); | |
192 | |
193 switch (compression_type) { | |
194 case 0: | |
195 switch (ea->bytes) { | |
196 case 1: ea->audio_codec = CODEC_ID_PCM_S8; break; | |
197 case 2: ea->audio_codec = CODEC_ID_PCM_S16LE; break; | |
198 } | |
199 break; | |
200 case 1: ea->audio_codec = CODEC_ID_PCM_MULAW; ea->bytes = 1; break; | |
201 default: | |
202 av_log (s, AV_LOG_ERROR, "unsupported stream type; audio compression_type=%i\n", compression_type); | |
203 } | |
204 | |
205 return 1; | |
206 } | |
207 | |
173 static int process_video_header_vp6(AVFormatContext *s) | 208 static int process_video_header_vp6(AVFormatContext *s) |
174 { | 209 { |
175 EaDemuxContext *ea = s->priv_data; | 210 EaDemuxContext *ea = s->priv_data; |
176 ByteIOContext *pb = &s->pb; | 211 ByteIOContext *pb = &s->pb; |
177 | 212 |
203 ea->big_endian = size > 0x000FFFFF; | 238 ea->big_endian = size > 0x000FFFFF; |
204 if (ea->big_endian) | 239 if (ea->big_endian) |
205 size = bswap_32(size); | 240 size = bswap_32(size); |
206 | 241 |
207 switch (blockid) { | 242 switch (blockid) { |
243 case _SNh_TAG: | |
244 if (get_le32(pb) != EACS_TAG) { | |
245 av_log (s, AV_LOG_ERROR, "unknown 1SNh headerid\n"); | |
246 return 0; | |
247 } | |
248 err = process_audio_header_eacs(s); | |
249 break; | |
250 | |
208 case SCHl_TAG : | 251 case SCHl_TAG : |
209 blockid = get_le32(pb); | 252 blockid = get_le32(pb); |
210 if (blockid == GSTR_TAG) { | 253 if (blockid == GSTR_TAG) { |
211 url_fskip(pb, 4); | 254 url_fskip(pb, 4); |
212 } else if (blockid != PT00_TAG) { | 255 } else if (blockid != PT00_TAG) { |
302 chunk_type = get_le32(pb); | 345 chunk_type = get_le32(pb); |
303 chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8; | 346 chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8; |
304 | 347 |
305 switch (chunk_type) { | 348 switch (chunk_type) { |
306 /* audio data */ | 349 /* audio data */ |
350 case _SNh_TAG: | |
351 /* header chunk also contains data; skip over the header portion*/ | |
352 url_fskip(pb, 32); | |
353 chunk_size -= 32; | |
354 case _SNd_TAG: | |
307 case SCDl_TAG: | 355 case SCDl_TAG: |
308 if (!ea->audio_codec) { | 356 if (!ea->audio_codec) { |
309 url_fskip(pb, chunk_size); | 357 url_fskip(pb, chunk_size); |
310 break; | 358 break; |
311 } | 359 } |
334 packet_read = 1; | 382 packet_read = 1; |
335 break; | 383 break; |
336 | 384 |
337 /* ending tag */ | 385 /* ending tag */ |
338 case 0: | 386 case 0: |
387 case _SNe_TAG: | |
339 case SCEl_TAG: | 388 case SCEl_TAG: |
340 ret = AVERROR(EIO); | 389 ret = AVERROR(EIO); |
341 packet_read = 1; | 390 packet_read = 1; |
342 break; | 391 break; |
343 | 392 |