Mercurial > libavformat.hg
annotate electronicarts.c @ 3974:a8383d02c686 libavformat
set sample rate for amr to allow stream copy since no decoder is present,
3gp does not store sample rate in stsd in fact. Fixes #674.
author | bcoudurier |
---|---|
date | Fri, 03 Oct 2008 19:37:41 +0000 |
parents | 1d3d17de20ba |
children | 0c2f650d31bb |
rev | line source |
---|---|
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
1 /* Electronic Arts Multimedia File Demuxer |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
2 * Copyright (c) 2004 The ffmpeg Project |
3551 | 3 * Copyright (c) 2006-2008 Peter Ross |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
4 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
5 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
6 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
11 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
16 * |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
885
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
20 */ |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
21 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
22 /** |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
23 * @file electronicarts.c |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
24 * Electronic Arts Multimedia file demuxer (WVE/UV2/etc.) |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
25 * by Robin Kay (komadori at gekkou.co.uk) |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
26 */ |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
27 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
28 #include "avformat.h" |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
29 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
30 #define SCHl_TAG MKTAG('S', 'C', 'H', 'l') |
2685 | 31 #define SEAD_TAG MKTAG('S', 'E', 'A', 'D') /* Sxxx header */ |
32 #define SNDC_TAG MKTAG('S', 'N', 'D', 'C') /* Sxxx data */ | |
33 #define SEND_TAG MKTAG('S', 'E', 'N', 'D') /* Sxxx end */ | |
3709
1c2e46d1f5c3
Electronic Arts demuxer: support SxEN audio tags found in 'Need for Speed: Pro Street' computer game.
pross
parents:
3708
diff
changeset
|
34 #define SHEN_TAG MKTAG('S', 'H', 'E', 'N') /* SxEN header */ |
1c2e46d1f5c3
Electronic Arts demuxer: support SxEN audio tags found in 'Need for Speed: Pro Street' computer game.
pross
parents:
3708
diff
changeset
|
35 #define SDEN_TAG MKTAG('S', 'D', 'E', 'N') /* SxEN data */ |
1c2e46d1f5c3
Electronic Arts demuxer: support SxEN audio tags found in 'Need for Speed: Pro Street' computer game.
pross
parents:
3708
diff
changeset
|
36 #define SEEN_TAG MKTAG('S', 'E', 'E', 'N') /* SxEN end */ |
2674 | 37 #define ISNh_TAG MKTAG('1', 'S', 'N', 'h') /* 1SNx header */ |
2673 | 38 #define EACS_TAG MKTAG('E', 'A', 'C', 'S') |
2674 | 39 #define ISNd_TAG MKTAG('1', 'S', 'N', 'd') /* 1SNx data */ |
40 #define ISNe_TAG MKTAG('1', 'S', 'N', 'e') /* 1SNx end */ | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
41 #define PT00_TAG MKTAG('P', 'T', 0x0, 0x0) |
2613 | 42 #define GSTR_TAG MKTAG('G', 'S', 'T', 'R') |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
43 #define SCDl_TAG MKTAG('S', 'C', 'D', 'l') |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
44 #define SCEl_TAG MKTAG('S', 'C', 'E', 'l') |
2717 | 45 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T') /* TGV i-frame */ |
3697 | 46 #define fVGT_TAG MKTAG('f', 'V', 'G', 'T') /* TGV p-frame */ |
3704 | 47 #define mTCD_TAG MKTAG('m', 'T', 'C', 'D') /* MDEC */ |
2717 | 48 #define MADk_TAG MKTAG('M', 'A', 'D', 'k') /* MAD i-frame */ |
49 #define MPCh_TAG MKTAG('M', 'P', 'C', 'h') /* MPEG2 */ | |
2613 | 50 #define MVhd_TAG MKTAG('M', 'V', 'h', 'd') |
51 #define MV0K_TAG MKTAG('M', 'V', '0', 'K') | |
52 #define MV0F_TAG MKTAG('M', 'V', '0', 'F') | |
2717 | 53 #define MVIh_TAG MKTAG('M', 'V', 'I', 'h') /* CMV header */ |
3551 | 54 #define MVIf_TAG MKTAG('M', 'V', 'I', 'f') /* CMV i-frame */ |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
55 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
56 typedef struct EaDemuxContext { |
2635 | 57 int big_endian; |
58 | |
3291
fb5f48e1956f
Fix icc warning #188: enumerated type mixed with another type
cehoyos
parents:
2780
diff
changeset
|
59 enum CodecID video_codec; |
2613 | 60 AVRational time_base; |
3704 | 61 int width, height; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
62 int video_stream_index; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
63 |
3291
fb5f48e1956f
Fix icc warning #188: enumerated type mixed with another type
cehoyos
parents:
2780
diff
changeset
|
64 enum CodecID audio_codec; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
65 int audio_stream_index; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
66 int audio_frame_counter; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
67 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
68 int64_t audio_pts; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
69 |
2642 | 70 int bytes; |
2639 | 71 int sample_rate; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
72 int num_channels; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
73 int num_samples; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
74 } EaDemuxContext; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
75 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
76 static uint32_t read_arbitary(ByteIOContext *pb) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
77 uint8_t size, byte; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
78 int i; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
79 uint32_t word; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
80 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
81 size = get_byte(pb); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
82 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
83 word = 0; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
84 for (i = 0; i < size; i++) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
85 byte = get_byte(pb); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
86 word <<= 8; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
87 word |= byte; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
88 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
89 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
90 return word; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
91 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
92 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
93 /* |
2626 | 94 * Process PT/GSTR sound header |
95 * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
96 */ |
2626 | 97 static int process_audio_header_elements(AVFormatContext *s) |
98 { | |
2611 | 99 int inHeader = 1; |
2006 | 100 EaDemuxContext *ea = s->priv_data; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
101 ByteIOContext *pb = s->pb; |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
102 int compression_type = -1, revision = -1, revision2 = -1; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
103 |
2642 | 104 ea->bytes = 2; |
2639 | 105 ea->sample_rate = -1; |
2627 | 106 ea->num_channels = 1; |
107 | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
108 while (inHeader) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
109 int inSubheader; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
110 uint8_t byte; |
2612 | 111 byte = get_byte(pb); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
112 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
113 switch (byte) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
114 case 0xFD: |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
115 av_log (s, AV_LOG_INFO, "entered audio subheader\n"); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
116 inSubheader = 1; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
117 while (inSubheader) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
118 uint8_t subbyte; |
2612 | 119 subbyte = get_byte(pb); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
120 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
121 switch (subbyte) { |
2639 | 122 case 0x80: |
123 revision = read_arbitary(pb); | |
124 av_log (s, AV_LOG_INFO, "revision (element 0x80) set to 0x%08x\n", revision); | |
125 break; | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
126 case 0x82: |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
127 ea->num_channels = read_arbitary(pb); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
128 av_log (s, AV_LOG_INFO, "num_channels (element 0x82) set to 0x%08x\n", ea->num_channels); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
129 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
130 case 0x83: |
2636
3b95556c8cd4
make compression_type a function local var instead of a context var
aurel
parents:
2635
diff
changeset
|
131 compression_type = read_arbitary(pb); |
3b95556c8cd4
make compression_type a function local var instead of a context var
aurel
parents:
2635
diff
changeset
|
132 av_log (s, AV_LOG_INFO, "compression_type (element 0x83) set to 0x%08x\n", compression_type); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
133 break; |
2639 | 134 case 0x84: |
135 ea->sample_rate = read_arbitary(pb); | |
136 av_log (s, AV_LOG_INFO, "sample_rate (element 0x84) set to %i\n", ea->sample_rate); | |
137 break; | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
138 case 0x85: |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
139 ea->num_samples = read_arbitary(pb); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
140 av_log (s, AV_LOG_INFO, "num_samples (element 0x85) set to 0x%08x\n", ea->num_samples); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
141 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
142 case 0x8A: |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
143 av_log (s, AV_LOG_INFO, "element 0x%02x set to 0x%08x\n", subbyte, read_arbitary(pb)); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
144 av_log (s, AV_LOG_INFO, "exited audio subheader\n"); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
145 inSubheader = 0; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
146 break; |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
147 case 0xA0: |
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
148 revision2 = read_arbitary(pb); |
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
149 av_log (s, AV_LOG_INFO, "revision2 (element 0xA0) set to 0x%08x\n", revision2); |
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
150 break; |
2613 | 151 case 0xFF: |
2625 | 152 av_log (s, AV_LOG_INFO, "end of header block reached (within audio subheader)\n"); |
2613 | 153 inSubheader = 0; |
154 inHeader = 0; | |
155 break; | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
156 default: |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
157 av_log (s, AV_LOG_INFO, "element 0x%02x set to 0x%08x\n", subbyte, read_arbitary(pb)); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
158 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
159 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
160 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
161 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
162 case 0xFF: |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
163 av_log (s, AV_LOG_INFO, "end of header block reached\n"); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
164 inHeader = 0; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
165 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
166 default: |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
167 av_log (s, AV_LOG_INFO, "header element 0x%02x set to 0x%08x\n", byte, read_arbitary(pb)); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
168 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
169 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
170 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
171 |
2637 | 172 switch (compression_type) { |
2638 | 173 case 0: ea->audio_codec = CODEC_ID_PCM_S16LE; break; |
2637 | 174 case 7: ea->audio_codec = CODEC_ID_ADPCM_EA; break; |
2670 | 175 case -1: |
176 switch (revision) { | |
177 case 1: ea->audio_codec = CODEC_ID_ADPCM_EA_R1; break; | |
178 case 2: ea->audio_codec = CODEC_ID_ADPCM_EA_R2; break; | |
179 case 3: ea->audio_codec = CODEC_ID_ADPCM_EA_R3; break; | |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
180 case -1: break; |
2670 | 181 default: |
182 av_log(s, AV_LOG_ERROR, "unsupported stream type; revision=%i\n", revision); | |
183 return 0; | |
184 } | |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
185 switch (revision2) { |
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
186 case 8: ea->audio_codec = CODEC_ID_PCM_S16LE_PLANAR; break; |
3708
ecaebc438438
Electronic Arts demuxer: perform identification of ADPCM EA R2 codec using revision2 flag.
pross
parents:
3707
diff
changeset
|
187 case 10: ea->audio_codec = CODEC_ID_ADPCM_EA_R2; break; |
3733 | 188 case 16: ea->audio_codec = CODEC_ID_MP3; break; |
3609 | 189 case -1: break; |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
190 default: |
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
191 av_log(s, AV_LOG_ERROR, "unsupported stream type; revision2=%i\n", revision2); |
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
192 return 0; |
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
193 } |
2670 | 194 break; |
2637 | 195 default: |
196 av_log(s, AV_LOG_ERROR, "unsupported stream type; compression_type=%i\n", compression_type); | |
197 return 0; | |
198 } | |
2631 | 199 |
2639 | 200 if (ea->sample_rate == -1) |
201 ea->sample_rate = revision==3 ? 48000 : 22050; | |
202 | |
2626 | 203 return 1; |
204 } | |
205 | |
2673 | 206 /* |
207 * Process EACS sound header | |
208 * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx | |
209 */ | |
210 static int process_audio_header_eacs(AVFormatContext *s) | |
211 { | |
212 EaDemuxContext *ea = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
213 ByteIOContext *pb = s->pb; |
2673 | 214 int compression_type; |
215 | |
216 ea->sample_rate = ea->big_endian ? get_be32(pb) : get_le32(pb); | |
217 ea->bytes = get_byte(pb); /* 1=8-bit, 2=16-bit */ | |
218 ea->num_channels = get_byte(pb); | |
219 compression_type = get_byte(pb); | |
220 url_fskip(pb, 13); | |
221 | |
222 switch (compression_type) { | |
223 case 0: | |
224 switch (ea->bytes) { | |
225 case 1: ea->audio_codec = CODEC_ID_PCM_S8; break; | |
226 case 2: ea->audio_codec = CODEC_ID_PCM_S16LE; break; | |
227 } | |
228 break; | |
229 case 1: ea->audio_codec = CODEC_ID_PCM_MULAW; ea->bytes = 1; break; | |
2686 | 230 case 2: ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_EACS; break; |
2673 | 231 default: |
232 av_log (s, AV_LOG_ERROR, "unsupported stream type; audio compression_type=%i\n", compression_type); | |
233 } | |
234 | |
235 return 1; | |
236 } | |
237 | |
2685 | 238 /* |
239 * Process SEAD sound header | |
240 * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx | |
241 */ | |
242 static int process_audio_header_sead(AVFormatContext *s) | |
243 { | |
244 EaDemuxContext *ea = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
245 ByteIOContext *pb = s->pb; |
2685 | 246 |
247 ea->sample_rate = get_le32(pb); | |
248 ea->bytes = get_le32(pb); /* 1=8-bit, 2=16-bit */ | |
249 ea->num_channels = get_le32(pb); | |
250 ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_SEAD; | |
251 | |
252 return 1; | |
253 } | |
254 | |
3704 | 255 static int process_video_header_mdec(AVFormatContext *s) |
256 { | |
257 EaDemuxContext *ea = s->priv_data; | |
258 ByteIOContext *pb = s->pb; | |
259 url_fskip(pb, 4); | |
260 ea->width = get_le16(pb); | |
261 ea->height = get_le16(pb); | |
262 ea->time_base = (AVRational){1,15}; | |
263 ea->video_codec = CODEC_ID_MDEC; | |
264 return 1; | |
265 } | |
266 | |
2629 | 267 static int process_video_header_vp6(AVFormatContext *s) |
268 { | |
269 EaDemuxContext *ea = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
270 ByteIOContext *pb = s->pb; |
2629 | 271 |
272 url_fskip(pb, 16); | |
273 ea->time_base.den = get_le32(pb); | |
274 ea->time_base.num = get_le32(pb); | |
2631 | 275 ea->video_codec = CODEC_ID_VP6; |
2629 | 276 |
277 return 1; | |
278 } | |
279 | |
2626 | 280 /* |
281 * Process EA file header | |
282 * Returns 1 if the EA file is valid and successfully opened, 0 otherwise | |
283 */ | |
284 static int process_ea_header(AVFormatContext *s) { | |
285 uint32_t blockid, size = 0; | |
286 EaDemuxContext *ea = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
287 ByteIOContext *pb = s->pb; |
2632
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
288 int i; |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
289 |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
290 for (i=0; i<5 && (!ea->audio_codec || !ea->video_codec); i++) { |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
291 unsigned int startpos = url_ftell(pb); |
2634 | 292 int err = 0; |
2626 | 293 |
2633 | 294 blockid = get_le32(pb); |
2626 | 295 size = get_le32(pb); |
2635 | 296 if (i == 0) |
297 ea->big_endian = size > 0x000FFFFF; | |
298 if (ea->big_endian) | |
299 size = bswap_32(size); | |
2632
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
300 |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
301 switch (blockid) { |
2674 | 302 case ISNh_TAG: |
2673 | 303 if (get_le32(pb) != EACS_TAG) { |
304 av_log (s, AV_LOG_ERROR, "unknown 1SNh headerid\n"); | |
305 return 0; | |
306 } | |
307 err = process_audio_header_eacs(s); | |
308 break; | |
309 | |
2632
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
310 case SCHl_TAG : |
3709
1c2e46d1f5c3
Electronic Arts demuxer: support SxEN audio tags found in 'Need for Speed: Pro Street' computer game.
pross
parents:
3708
diff
changeset
|
311 case SHEN_TAG : |
2633 | 312 blockid = get_le32(pb); |
313 if (blockid == GSTR_TAG) { | |
314 url_fskip(pb, 4); | |
3707
57d88d565add
Electronic Arts demuxer: ignore PTxx platform ID values.
pross
parents:
3706
diff
changeset
|
315 } else if ((blockid & 0xFFFF)!=PT00_TAG) { |
2633 | 316 av_log (s, AV_LOG_ERROR, "unknown SCHl headerid\n"); |
317 return 0; | |
318 } | |
2634 | 319 err = process_audio_header_elements(s); |
2632
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
320 break; |
2626 | 321 |
2685 | 322 case SEAD_TAG: |
323 err = process_audio_header_sead(s); | |
324 break; | |
325 | |
3551 | 326 case MVIh_TAG : |
327 ea->video_codec = CODEC_ID_CMV; | |
328 ea->time_base = (AVRational){0,0}; | |
329 break; | |
330 | |
3697 | 331 case kVGT_TAG: |
332 ea->video_codec = CODEC_ID_TGV; | |
333 ea->time_base = (AVRational){0,0}; | |
334 break; | |
335 | |
3704 | 336 case mTCD_TAG : |
337 err = process_video_header_mdec(s); | |
338 break; | |
339 | |
3706
590e8cbe6d77
Support Electronic Arts files containing MPEG2VIDEO.
pross
parents:
3704
diff
changeset
|
340 case MPCh_TAG: |
590e8cbe6d77
Support Electronic Arts files containing MPEG2VIDEO.
pross
parents:
3704
diff
changeset
|
341 ea->video_codec = CODEC_ID_MPEG2VIDEO; |
590e8cbe6d77
Support Electronic Arts files containing MPEG2VIDEO.
pross
parents:
3704
diff
changeset
|
342 break; |
590e8cbe6d77
Support Electronic Arts files containing MPEG2VIDEO.
pross
parents:
3704
diff
changeset
|
343 |
2632
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
344 case MVhd_TAG : |
2634 | 345 err = process_video_header_vp6(s); |
2632
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
346 break; |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
347 } |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
348 |
2634 | 349 if (err < 0) { |
350 av_log(s, AV_LOG_ERROR, "error parsing header: %i\n", err); | |
351 return err; | |
352 } | |
353 | |
2632
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
354 url_fseek(pb, startpos + size, SEEK_SET); |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
355 } |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
356 |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
357 url_fseek(pb, 0, SEEK_SET); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
358 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
359 return 1; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
360 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
361 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
362 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
363 static int ea_probe(AVProbeData *p) |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
364 { |
2661
bed166d88f63
convert a if() into a switch() to ease addition of new tags to probe
aurel
parents:
2647
diff
changeset
|
365 switch (AV_RL32(&p->buf[0])) { |
2675 | 366 case ISNh_TAG: |
2661
bed166d88f63
convert a if() into a switch() to ease addition of new tags to probe
aurel
parents:
2647
diff
changeset
|
367 case SCHl_TAG: |
2685 | 368 case SEAD_TAG: |
3709
1c2e46d1f5c3
Electronic Arts demuxer: support SxEN audio tags found in 'Need for Speed: Pro Street' computer game.
pross
parents:
3708
diff
changeset
|
369 case SHEN_TAG: |
2717 | 370 case kVGT_TAG: |
371 case MADk_TAG: | |
372 case MPCh_TAG: | |
2661
bed166d88f63
convert a if() into a switch() to ease addition of new tags to probe
aurel
parents:
2647
diff
changeset
|
373 case MVhd_TAG: |
2717 | 374 case MVIh_TAG: |
2613 | 375 return AVPROBE_SCORE_MAX; |
2661
bed166d88f63
convert a if() into a switch() to ease addition of new tags to probe
aurel
parents:
2647
diff
changeset
|
376 } |
2613 | 377 return 0; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
378 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
379 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
380 static int ea_read_header(AVFormatContext *s, |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
381 AVFormatParameters *ap) |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
382 { |
2006 | 383 EaDemuxContext *ea = s->priv_data; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
384 AVStream *st; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
385 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
386 if (!process_ea_header(s)) |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2273
diff
changeset
|
387 return AVERROR(EIO); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
388 |
2647 | 389 if (ea->video_codec) { |
2614 | 390 /* initialize the video decoder stream */ |
391 st = av_new_stream(s, 0); | |
392 if (!st) | |
393 return AVERROR(ENOMEM); | |
394 ea->video_stream_index = st->index; | |
395 st->codec->codec_type = CODEC_TYPE_VIDEO; | |
2631 | 396 st->codec->codec_id = ea->video_codec; |
2614 | 397 st->codec->codec_tag = 0; /* no fourcc */ |
398 st->codec->time_base = ea->time_base; | |
3704 | 399 st->codec->width = ea->width; |
400 st->codec->height = ea->height; | |
2613 | 401 } |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
402 |
2644
ad769d06b84c
check if we found an audio track before initializing the audio stream
aurel
parents:
2643
diff
changeset
|
403 if (ea->audio_codec) { |
2645 | 404 /* initialize the audio decoder stream */ |
405 st = av_new_stream(s, 0); | |
406 if (!st) | |
407 return AVERROR(ENOMEM); | |
408 av_set_pts_info(st, 33, 1, ea->sample_rate); | |
409 st->codec->codec_type = CODEC_TYPE_AUDIO; | |
410 st->codec->codec_id = ea->audio_codec; | |
411 st->codec->codec_tag = 0; /* no tag */ | |
412 st->codec->channels = ea->num_channels; | |
413 st->codec->sample_rate = ea->sample_rate; | |
3908
1d3d17de20ba
Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents:
3733
diff
changeset
|
414 st->codec->bits_per_coded_sample = ea->bytes * 8; |
2645 | 415 st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * |
3908
1d3d17de20ba
Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents:
3733
diff
changeset
|
416 st->codec->bits_per_coded_sample / 4; |
1d3d17de20ba
Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents:
3733
diff
changeset
|
417 st->codec->block_align = st->codec->channels*st->codec->bits_per_coded_sample; |
2645 | 418 ea->audio_stream_index = st->index; |
419 ea->audio_frame_counter = 0; | |
2644
ad769d06b84c
check if we found an audio track before initializing the audio stream
aurel
parents:
2643
diff
changeset
|
420 } |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
421 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
422 return 1; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
423 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
424 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
425 static int ea_read_packet(AVFormatContext *s, |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
426 AVPacket *pkt) |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
427 { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
428 EaDemuxContext *ea = s->priv_data; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
429 ByteIOContext *pb = s->pb; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
430 int ret = 0; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
431 int packet_read = 0; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
432 unsigned int chunk_type, chunk_size; |
2613 | 433 int key = 0; |
3733 | 434 int num_samples; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
435 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
436 while (!packet_read) { |
2640 | 437 chunk_type = get_le32(pb); |
2641 | 438 chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
439 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
440 switch (chunk_type) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
441 /* audio data */ |
2674 | 442 case ISNh_TAG: |
2673 | 443 /* header chunk also contains data; skip over the header portion*/ |
444 url_fskip(pb, 32); | |
445 chunk_size -= 32; | |
2674 | 446 case ISNd_TAG: |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
447 case SCDl_TAG: |
2685 | 448 case SNDC_TAG: |
3709
1c2e46d1f5c3
Electronic Arts demuxer: support SxEN audio tags found in 'Need for Speed: Pro Street' computer game.
pross
parents:
3708
diff
changeset
|
449 case SDEN_TAG: |
2646 | 450 if (!ea->audio_codec) { |
451 url_fskip(pb, chunk_size); | |
452 break; | |
3733 | 453 } else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR || |
454 ea->audio_codec == CODEC_ID_MP3) { | |
455 num_samples = get_le32(pb); | |
456 url_fskip(pb, 8); | |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
457 chunk_size -= 12; |
2646 | 458 } |
775 | 459 ret = av_get_packet(pb, pkt, chunk_size); |
460 if (ret != chunk_size) | |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2273
diff
changeset
|
461 ret = AVERROR(EIO); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
462 else { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
463 pkt->stream_index = ea->audio_stream_index; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
464 pkt->pts = 90000; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
465 pkt->pts *= ea->audio_frame_counter; |
2639 | 466 pkt->pts /= ea->sample_rate; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
467 |
2643 | 468 switch (ea->audio_codec) { |
469 case CODEC_ID_ADPCM_EA: | |
885 | 470 /* 2 samples/byte, 1 or 2 samples per frame depending |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
471 * on stereo; chunk also has 12-byte header */ |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
472 ea->audio_frame_counter += ((chunk_size - 12) * 2) / |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
473 ea->num_channels; |
2643 | 474 break; |
3733 | 475 case CODEC_ID_PCM_S16LE_PLANAR: |
476 case CODEC_ID_MP3: | |
477 ea->audio_frame_counter += num_samples; | |
478 break; | |
2643 | 479 default: |
480 ea->audio_frame_counter += chunk_size / | |
481 (ea->bytes * ea->num_channels); | |
482 } | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
483 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
484 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
485 packet_read = 1; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
486 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
487 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
488 /* ending tag */ |
2671
7f320fb9f1c9
avoid infinite loop at the end of files which are not properly terminated
aurel
parents:
2670
diff
changeset
|
489 case 0: |
2674 | 490 case ISNe_TAG: |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
491 case SCEl_TAG: |
2685 | 492 case SEND_TAG: |
3709
1c2e46d1f5c3
Electronic Arts demuxer: support SxEN audio tags found in 'Need for Speed: Pro Street' computer game.
pross
parents:
3708
diff
changeset
|
493 case SEEN_TAG: |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2273
diff
changeset
|
494 ret = AVERROR(EIO); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
495 packet_read = 1; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
496 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
497 |
3551 | 498 case MVIh_TAG: |
3697 | 499 case kVGT_TAG: |
3551 | 500 key = PKT_FLAG_KEY; |
501 case MVIf_TAG: | |
3697 | 502 case fVGT_TAG: |
3551 | 503 url_fseek(pb, -8, SEEK_CUR); // include chunk preamble |
504 chunk_size += 8; | |
505 goto get_video_packet; | |
506 | |
3704 | 507 case mTCD_TAG: |
508 url_fseek(pb, 8, SEEK_CUR); // skip ea dct header | |
509 chunk_size -= 8; | |
510 goto get_video_packet; | |
511 | |
2613 | 512 case MV0K_TAG: |
3706
590e8cbe6d77
Support Electronic Arts files containing MPEG2VIDEO.
pross
parents:
3704
diff
changeset
|
513 case MPCh_TAG: |
2613 | 514 key = PKT_FLAG_KEY; |
515 case MV0F_TAG: | |
3551 | 516 get_video_packet: |
2613 | 517 ret = av_get_packet(pb, pkt, chunk_size); |
518 if (ret != chunk_size) | |
519 ret = AVERROR_IO; | |
520 else { | |
521 pkt->stream_index = ea->video_stream_index; | |
522 pkt->flags |= key; | |
523 } | |
524 packet_read = 1; | |
525 break; | |
526 | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
527 default: |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
528 url_fseek(pb, chunk_size, SEEK_CUR); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
529 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
530 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
531 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
532 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
533 return ret; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
534 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
535 |
1169 | 536 AVInputFormat ea_demuxer = { |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
537 "ea", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3291
diff
changeset
|
538 NULL_IF_CONFIG_SMALL("Electronic Arts Multimedia Format"), |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
539 sizeof(EaDemuxContext), |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
540 ea_probe, |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
541 ea_read_header, |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
542 ea_read_packet, |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
543 }; |