Mercurial > libavformat.hg
annotate electronicarts.c @ 5206:08c92d88d980 libavformat
Core Audio Format demuxer
author | pross |
---|---|
date | Wed, 16 Sep 2009 12:26:59 +0000 |
parents | 4ba7fd2077bd |
children | 6fc9f9d8aaa1 |
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 /** |
4331
49c1d3b27727
Use full internal pathname in doxygen @file directives.
diego
parents:
4201
diff
changeset
|
23 * @file libavformat/electronicarts.c |
565
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 |
4201
7d2f3f1b68d8
Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents:
4018
diff
changeset
|
28 #include "libavutil/intreadwrite.h" |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
29 #include "avformat.h" |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
30 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
31 #define SCHl_TAG MKTAG('S', 'C', 'H', 'l') |
2685 | 32 #define SEAD_TAG MKTAG('S', 'E', 'A', 'D') /* Sxxx header */ |
33 #define SNDC_TAG MKTAG('S', 'N', 'D', 'C') /* Sxxx data */ | |
34 #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
|
35 #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
|
36 #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
|
37 #define SEEN_TAG MKTAG('S', 'E', 'E', 'N') /* SxEN end */ |
2674 | 38 #define ISNh_TAG MKTAG('1', 'S', 'N', 'h') /* 1SNx header */ |
2673 | 39 #define EACS_TAG MKTAG('E', 'A', 'C', 'S') |
2674 | 40 #define ISNd_TAG MKTAG('1', 'S', 'N', 'd') /* 1SNx data */ |
41 #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
|
42 #define PT00_TAG MKTAG('P', 'T', 0x0, 0x0) |
2613 | 43 #define GSTR_TAG MKTAG('G', 'S', 'T', 'R') |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
44 #define SCDl_TAG MKTAG('S', 'C', 'D', 'l') |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
45 #define SCEl_TAG MKTAG('S', 'C', 'E', 'l') |
2717 | 46 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T') /* TGV i-frame */ |
3697 | 47 #define fVGT_TAG MKTAG('f', 'V', 'G', 'T') /* TGV p-frame */ |
3704 | 48 #define mTCD_TAG MKTAG('m', 'T', 'C', 'D') /* MDEC */ |
2717 | 49 #define MADk_TAG MKTAG('M', 'A', 'D', 'k') /* MAD i-frame */ |
5028 | 50 #define MADm_TAG MKTAG('M', 'A', 'D', 'm') /* MAD p-frame */ |
51 #define MADe_TAG MKTAG('M', 'A', 'D', 'e') /* MAD lqp-frame */ | |
2717 | 52 #define MPCh_TAG MKTAG('M', 'P', 'C', 'h') /* MPEG2 */ |
4018 | 53 #define TGQs_TAG MKTAG('T', 'G', 'Q', 's') /* TGQ i-frame (appears in .TGQ files) */ |
54 #define pQGT_TAG MKTAG('p', 'Q', 'G', 'T') /* TGQ i-frame (appears in .UV files) */ | |
4379 | 55 #define pIQT_TAG MKTAG('p', 'I', 'Q', 'T') /* TQI/UV2 i-frame (.UV2/.WVE) */ |
2613 | 56 #define MVhd_TAG MKTAG('M', 'V', 'h', 'd') |
57 #define MV0K_TAG MKTAG('M', 'V', '0', 'K') | |
58 #define MV0F_TAG MKTAG('M', 'V', '0', 'F') | |
2717 | 59 #define MVIh_TAG MKTAG('M', 'V', 'I', 'h') /* CMV header */ |
3551 | 60 #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
|
61 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
62 typedef struct EaDemuxContext { |
2635 | 63 int big_endian; |
64 | |
3291
fb5f48e1956f
Fix icc warning #188: enumerated type mixed with another type
cehoyos
parents:
2780
diff
changeset
|
65 enum CodecID video_codec; |
2613 | 66 AVRational time_base; |
3704 | 67 int width, height; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
68 int video_stream_index; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
69 |
3291
fb5f48e1956f
Fix icc warning #188: enumerated type mixed with another type
cehoyos
parents:
2780
diff
changeset
|
70 enum CodecID audio_codec; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
71 int audio_stream_index; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
72 int audio_frame_counter; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
73 |
2642 | 74 int bytes; |
2639 | 75 int sample_rate; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
76 int num_channels; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
77 int num_samples; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
78 } EaDemuxContext; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
79 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
80 static uint32_t read_arbitary(ByteIOContext *pb) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
81 uint8_t size, byte; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
82 int i; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
83 uint32_t word; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
84 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
85 size = get_byte(pb); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
86 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
87 word = 0; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
88 for (i = 0; i < size; i++) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
89 byte = get_byte(pb); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
90 word <<= 8; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
91 word |= byte; |
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 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
94 return word; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
95 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
96 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
97 /* |
2626 | 98 * Process PT/GSTR sound header |
99 * 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
|
100 */ |
2626 | 101 static int process_audio_header_elements(AVFormatContext *s) |
102 { | |
2611 | 103 int inHeader = 1; |
2006 | 104 EaDemuxContext *ea = s->priv_data; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
105 ByteIOContext *pb = s->pb; |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
106 int compression_type = -1, revision = -1, revision2 = -1; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
107 |
2642 | 108 ea->bytes = 2; |
2639 | 109 ea->sample_rate = -1; |
2627 | 110 ea->num_channels = 1; |
111 | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
112 while (inHeader) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
113 int inSubheader; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
114 uint8_t byte; |
2612 | 115 byte = get_byte(pb); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
116 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
117 switch (byte) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
118 case 0xFD: |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
119 av_log (s, AV_LOG_DEBUG, "entered audio subheader\n"); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
120 inSubheader = 1; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
121 while (inSubheader) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
122 uint8_t subbyte; |
2612 | 123 subbyte = get_byte(pb); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
124 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
125 switch (subbyte) { |
2639 | 126 case 0x80: |
127 revision = read_arbitary(pb); | |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
128 av_log (s, AV_LOG_DEBUG, "revision (element 0x80) set to 0x%08x\n", revision); |
2639 | 129 break; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
130 case 0x82: |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
131 ea->num_channels = read_arbitary(pb); |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
132 av_log (s, AV_LOG_DEBUG, "num_channels (element 0x82) set to 0x%08x\n", ea->num_channels); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
133 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
134 case 0x83: |
2636
3b95556c8cd4
make compression_type a function local var instead of a context var
aurel
parents:
2635
diff
changeset
|
135 compression_type = read_arbitary(pb); |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
136 av_log (s, AV_LOG_DEBUG, "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
|
137 break; |
2639 | 138 case 0x84: |
139 ea->sample_rate = read_arbitary(pb); | |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
140 av_log (s, AV_LOG_DEBUG, "sample_rate (element 0x84) set to %i\n", ea->sample_rate); |
2639 | 141 break; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
142 case 0x85: |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
143 ea->num_samples = read_arbitary(pb); |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
144 av_log (s, AV_LOG_DEBUG, "num_samples (element 0x85) set to 0x%08x\n", ea->num_samples); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
145 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
146 case 0x8A: |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
147 av_log (s, AV_LOG_DEBUG, "element 0x%02x set to 0x%08x\n", subbyte, read_arbitary(pb)); |
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
148 av_log (s, AV_LOG_DEBUG, "exited audio subheader\n"); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
149 inSubheader = 0; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
150 break; |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
151 case 0xA0: |
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
152 revision2 = read_arbitary(pb); |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
153 av_log (s, AV_LOG_DEBUG, "revision2 (element 0xA0) set to 0x%08x\n", revision2); |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
154 break; |
2613 | 155 case 0xFF: |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
156 av_log (s, AV_LOG_DEBUG, "end of header block reached (within audio subheader)\n"); |
2613 | 157 inSubheader = 0; |
158 inHeader = 0; | |
159 break; | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
160 default: |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
161 av_log (s, AV_LOG_DEBUG, "element 0x%02x set to 0x%08x\n", subbyte, read_arbitary(pb)); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
162 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
163 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
164 } |
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 case 0xFF: |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
167 av_log (s, AV_LOG_DEBUG, "end of header block reached\n"); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
168 inHeader = 0; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
169 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
170 default: |
4867
9ff7c0af5971
Move ea demuxer messages that are irrelevant to ordinary users from
reimar
parents:
4850
diff
changeset
|
171 av_log (s, AV_LOG_DEBUG, "header element 0x%02x set to 0x%08x\n", byte, read_arbitary(pb)); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
172 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
173 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
174 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
175 |
2637 | 176 switch (compression_type) { |
2638 | 177 case 0: ea->audio_codec = CODEC_ID_PCM_S16LE; break; |
2637 | 178 case 7: ea->audio_codec = CODEC_ID_ADPCM_EA; break; |
2670 | 179 case -1: |
180 switch (revision) { | |
181 case 1: ea->audio_codec = CODEC_ID_ADPCM_EA_R1; break; | |
182 case 2: ea->audio_codec = CODEC_ID_ADPCM_EA_R2; break; | |
183 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
|
184 case -1: break; |
2670 | 185 default: |
186 av_log(s, AV_LOG_ERROR, "unsupported stream type; revision=%i\n", revision); | |
187 return 0; | |
188 } | |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
189 switch (revision2) { |
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
190 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
|
191 case 10: ea->audio_codec = CODEC_ID_ADPCM_EA_R2; break; |
3733 | 192 case 16: ea->audio_codec = CODEC_ID_MP3; break; |
3609 | 193 case -1: break; |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
194 default: |
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
195 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
|
196 return 0; |
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
197 } |
2670 | 198 break; |
2637 | 199 default: |
200 av_log(s, AV_LOG_ERROR, "unsupported stream type; compression_type=%i\n", compression_type); | |
201 return 0; | |
202 } | |
2631 | 203 |
2639 | 204 if (ea->sample_rate == -1) |
205 ea->sample_rate = revision==3 ? 48000 : 22050; | |
206 | |
2626 | 207 return 1; |
208 } | |
209 | |
2673 | 210 /* |
211 * Process EACS sound header | |
212 * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx | |
213 */ | |
214 static int process_audio_header_eacs(AVFormatContext *s) | |
215 { | |
216 EaDemuxContext *ea = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
217 ByteIOContext *pb = s->pb; |
2673 | 218 int compression_type; |
219 | |
220 ea->sample_rate = ea->big_endian ? get_be32(pb) : get_le32(pb); | |
221 ea->bytes = get_byte(pb); /* 1=8-bit, 2=16-bit */ | |
222 ea->num_channels = get_byte(pb); | |
223 compression_type = get_byte(pb); | |
224 url_fskip(pb, 13); | |
225 | |
226 switch (compression_type) { | |
227 case 0: | |
228 switch (ea->bytes) { | |
229 case 1: ea->audio_codec = CODEC_ID_PCM_S8; break; | |
230 case 2: ea->audio_codec = CODEC_ID_PCM_S16LE; break; | |
231 } | |
232 break; | |
233 case 1: ea->audio_codec = CODEC_ID_PCM_MULAW; ea->bytes = 1; break; | |
2686 | 234 case 2: ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_EACS; break; |
2673 | 235 default: |
236 av_log (s, AV_LOG_ERROR, "unsupported stream type; audio compression_type=%i\n", compression_type); | |
237 } | |
238 | |
239 return 1; | |
240 } | |
241 | |
2685 | 242 /* |
243 * Process SEAD sound header | |
244 * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx | |
245 */ | |
246 static int process_audio_header_sead(AVFormatContext *s) | |
247 { | |
248 EaDemuxContext *ea = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
249 ByteIOContext *pb = s->pb; |
2685 | 250 |
251 ea->sample_rate = get_le32(pb); | |
252 ea->bytes = get_le32(pb); /* 1=8-bit, 2=16-bit */ | |
253 ea->num_channels = get_le32(pb); | |
254 ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_SEAD; | |
255 | |
256 return 1; | |
257 } | |
258 | |
3704 | 259 static int process_video_header_mdec(AVFormatContext *s) |
260 { | |
261 EaDemuxContext *ea = s->priv_data; | |
262 ByteIOContext *pb = s->pb; | |
263 url_fskip(pb, 4); | |
264 ea->width = get_le16(pb); | |
265 ea->height = get_le16(pb); | |
266 ea->time_base = (AVRational){1,15}; | |
267 ea->video_codec = CODEC_ID_MDEC; | |
268 return 1; | |
269 } | |
270 | |
2629 | 271 static int process_video_header_vp6(AVFormatContext *s) |
272 { | |
273 EaDemuxContext *ea = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
274 ByteIOContext *pb = s->pb; |
2629 | 275 |
276 url_fskip(pb, 16); | |
277 ea->time_base.den = get_le32(pb); | |
278 ea->time_base.num = get_le32(pb); | |
2631 | 279 ea->video_codec = CODEC_ID_VP6; |
2629 | 280 |
281 return 1; | |
282 } | |
283 | |
2626 | 284 /* |
285 * Process EA file header | |
286 * Returns 1 if the EA file is valid and successfully opened, 0 otherwise | |
287 */ | |
288 static int process_ea_header(AVFormatContext *s) { | |
289 uint32_t blockid, size = 0; | |
290 EaDemuxContext *ea = s->priv_data; | |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
291 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
|
292 int i; |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
293 |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
294 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
|
295 unsigned int startpos = url_ftell(pb); |
2634 | 296 int err = 0; |
2626 | 297 |
2633 | 298 blockid = get_le32(pb); |
2626 | 299 size = get_le32(pb); |
2635 | 300 if (i == 0) |
301 ea->big_endian = size > 0x000FFFFF; | |
302 if (ea->big_endian) | |
303 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
|
304 |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
305 switch (blockid) { |
2674 | 306 case ISNh_TAG: |
2673 | 307 if (get_le32(pb) != EACS_TAG) { |
308 av_log (s, AV_LOG_ERROR, "unknown 1SNh headerid\n"); | |
309 return 0; | |
310 } | |
311 err = process_audio_header_eacs(s); | |
312 break; | |
313 | |
2632
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
314 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
|
315 case SHEN_TAG : |
2633 | 316 blockid = get_le32(pb); |
317 if (blockid == GSTR_TAG) { | |
318 url_fskip(pb, 4); | |
3707
57d88d565add
Electronic Arts demuxer: ignore PTxx platform ID values.
pross
parents:
3706
diff
changeset
|
319 } else if ((blockid & 0xFFFF)!=PT00_TAG) { |
2633 | 320 av_log (s, AV_LOG_ERROR, "unknown SCHl headerid\n"); |
321 return 0; | |
322 } | |
2634 | 323 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
|
324 break; |
2626 | 325 |
2685 | 326 case SEAD_TAG: |
327 err = process_audio_header_sead(s); | |
328 break; | |
329 | |
3551 | 330 case MVIh_TAG : |
331 ea->video_codec = CODEC_ID_CMV; | |
332 ea->time_base = (AVRational){0,0}; | |
333 break; | |
334 | |
3697 | 335 case kVGT_TAG: |
336 ea->video_codec = CODEC_ID_TGV; | |
337 ea->time_base = (AVRational){0,0}; | |
338 break; | |
339 | |
3704 | 340 case mTCD_TAG : |
341 err = process_video_header_mdec(s); | |
342 break; | |
343 | |
3706
590e8cbe6d77
Support Electronic Arts files containing MPEG2VIDEO.
pross
parents:
3704
diff
changeset
|
344 case MPCh_TAG: |
590e8cbe6d77
Support Electronic Arts files containing MPEG2VIDEO.
pross
parents:
3704
diff
changeset
|
345 ea->video_codec = CODEC_ID_MPEG2VIDEO; |
590e8cbe6d77
Support Electronic Arts files containing MPEG2VIDEO.
pross
parents:
3704
diff
changeset
|
346 break; |
590e8cbe6d77
Support Electronic Arts files containing MPEG2VIDEO.
pross
parents:
3704
diff
changeset
|
347 |
4018 | 348 case pQGT_TAG: |
349 case TGQs_TAG: | |
350 ea->video_codec = CODEC_ID_TGQ; | |
351 break; | |
352 | |
4379 | 353 case pIQT_TAG: |
354 ea->video_codec = CODEC_ID_TQI; | |
355 break; | |
356 | |
5028 | 357 case MADk_TAG : |
358 ea->video_codec = CODEC_ID_MAD; | |
359 break; | |
360 | |
2632
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
361 case MVhd_TAG : |
2634 | 362 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
|
363 break; |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
364 } |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
365 |
2634 | 366 if (err < 0) { |
367 av_log(s, AV_LOG_ERROR, "error parsing header: %i\n", err); | |
368 return err; | |
369 } | |
370 | |
2632
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
371 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
|
372 } |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
373 |
c5118e086450
parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents:
2631
diff
changeset
|
374 url_fseek(pb, 0, SEEK_SET); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
375 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
376 return 1; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
377 } |
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_probe(AVProbeData *p) |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
381 { |
2661
bed166d88f63
convert a if() into a switch() to ease addition of new tags to probe
aurel
parents:
2647
diff
changeset
|
382 switch (AV_RL32(&p->buf[0])) { |
2675 | 383 case ISNh_TAG: |
2661
bed166d88f63
convert a if() into a switch() to ease addition of new tags to probe
aurel
parents:
2647
diff
changeset
|
384 case SCHl_TAG: |
2685 | 385 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
|
386 case SHEN_TAG: |
2717 | 387 case kVGT_TAG: |
388 case MADk_TAG: | |
389 case MPCh_TAG: | |
2661
bed166d88f63
convert a if() into a switch() to ease addition of new tags to probe
aurel
parents:
2647
diff
changeset
|
390 case MVhd_TAG: |
2717 | 391 case MVIh_TAG: |
2613 | 392 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
|
393 } |
2613 | 394 return 0; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
395 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
396 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
397 static int ea_read_header(AVFormatContext *s, |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
398 AVFormatParameters *ap) |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
399 { |
2006 | 400 EaDemuxContext *ea = s->priv_data; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
401 AVStream *st; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
402 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
403 if (!process_ea_header(s)) |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2273
diff
changeset
|
404 return AVERROR(EIO); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
405 |
2647 | 406 if (ea->video_codec) { |
2614 | 407 /* initialize the video decoder stream */ |
408 st = av_new_stream(s, 0); | |
409 if (!st) | |
410 return AVERROR(ENOMEM); | |
411 ea->video_stream_index = st->index; | |
412 st->codec->codec_type = CODEC_TYPE_VIDEO; | |
2631 | 413 st->codec->codec_id = ea->video_codec; |
2614 | 414 st->codec->codec_tag = 0; /* no fourcc */ |
415 st->codec->time_base = ea->time_base; | |
3704 | 416 st->codec->width = ea->width; |
417 st->codec->height = ea->height; | |
2613 | 418 } |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
419 |
2644
ad769d06b84c
check if we found an audio track before initializing the audio stream
aurel
parents:
2643
diff
changeset
|
420 if (ea->audio_codec) { |
2645 | 421 /* initialize the audio decoder stream */ |
422 st = av_new_stream(s, 0); | |
423 if (!st) | |
424 return AVERROR(ENOMEM); | |
425 av_set_pts_info(st, 33, 1, ea->sample_rate); | |
426 st->codec->codec_type = CODEC_TYPE_AUDIO; | |
427 st->codec->codec_id = ea->audio_codec; | |
428 st->codec->codec_tag = 0; /* no tag */ | |
429 st->codec->channels = ea->num_channels; | |
430 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
|
431 st->codec->bits_per_coded_sample = ea->bytes * 8; |
2645 | 432 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
|
433 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
|
434 st->codec->block_align = st->codec->channels*st->codec->bits_per_coded_sample; |
2645 | 435 ea->audio_stream_index = st->index; |
436 ea->audio_frame_counter = 0; | |
2644
ad769d06b84c
check if we found an audio track before initializing the audio stream
aurel
parents:
2643
diff
changeset
|
437 } |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
438 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
439 return 1; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
440 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
441 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
442 static int ea_read_packet(AVFormatContext *s, |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
443 AVPacket *pkt) |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
444 { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
445 EaDemuxContext *ea = s->priv_data; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2717
diff
changeset
|
446 ByteIOContext *pb = s->pb; |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
447 int ret = 0; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
448 int packet_read = 0; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
449 unsigned int chunk_type, chunk_size; |
2613 | 450 int key = 0; |
4451
4b44e8f4853e
Add av_uninit macro to variable to avoid false positive warning:
diego
parents:
4379
diff
changeset
|
451 int av_uninit(num_samples); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
452 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
453 while (!packet_read) { |
2640 | 454 chunk_type = get_le32(pb); |
2641 | 455 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
|
456 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
457 switch (chunk_type) { |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
458 /* audio data */ |
2674 | 459 case ISNh_TAG: |
2673 | 460 /* header chunk also contains data; skip over the header portion*/ |
461 url_fskip(pb, 32); | |
462 chunk_size -= 32; | |
2674 | 463 case ISNd_TAG: |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
464 case SCDl_TAG: |
2685 | 465 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
|
466 case SDEN_TAG: |
2646 | 467 if (!ea->audio_codec) { |
468 url_fskip(pb, chunk_size); | |
469 break; | |
3733 | 470 } else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR || |
471 ea->audio_codec == CODEC_ID_MP3) { | |
472 num_samples = get_le32(pb); | |
473 url_fskip(pb, 8); | |
2780
0b9d29522781
add pcm_s16le_planar support for electronicarts files
aurel
parents:
2771
diff
changeset
|
474 chunk_size -= 12; |
2646 | 475 } |
775 | 476 ret = av_get_packet(pb, pkt, chunk_size); |
4849
92468cd5b594
Make electronicarts demuxer return partial frames, this is the default
reimar
parents:
4451
diff
changeset
|
477 if (ret < 0) |
92468cd5b594
Make electronicarts demuxer return partial frames, this is the default
reimar
parents:
4451
diff
changeset
|
478 return ret; |
4850 | 479 pkt->stream_index = ea->audio_stream_index; |
480 pkt->pts = 90000; | |
481 pkt->pts *= ea->audio_frame_counter; | |
482 pkt->pts /= ea->sample_rate; | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
483 |
4850 | 484 switch (ea->audio_codec) { |
485 case CODEC_ID_ADPCM_EA: | |
486 /* 2 samples/byte, 1 or 2 samples per frame depending | |
487 * on stereo; chunk also has 12-byte header */ | |
488 ea->audio_frame_counter += ((chunk_size - 12) * 2) / | |
489 ea->num_channels; | |
490 break; | |
491 case CODEC_ID_PCM_S16LE_PLANAR: | |
492 case CODEC_ID_MP3: | |
493 ea->audio_frame_counter += num_samples; | |
494 break; | |
495 default: | |
496 ea->audio_frame_counter += chunk_size / | |
497 (ea->bytes * ea->num_channels); | |
498 } | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
499 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
500 packet_read = 1; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
501 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
502 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
503 /* ending tag */ |
2671
7f320fb9f1c9
avoid infinite loop at the end of files which are not properly terminated
aurel
parents:
2670
diff
changeset
|
504 case 0: |
2674 | 505 case ISNe_TAG: |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
506 case SCEl_TAG: |
2685 | 507 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
|
508 case SEEN_TAG: |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2273
diff
changeset
|
509 ret = AVERROR(EIO); |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
510 packet_read = 1; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
511 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
512 |
3551 | 513 case MVIh_TAG: |
3697 | 514 case kVGT_TAG: |
4018 | 515 case pQGT_TAG: |
516 case TGQs_TAG: | |
5028 | 517 case MADk_TAG: |
3551 | 518 key = PKT_FLAG_KEY; |
519 case MVIf_TAG: | |
3697 | 520 case fVGT_TAG: |
5028 | 521 case MADm_TAG: |
522 case MADe_TAG: | |
3551 | 523 url_fseek(pb, -8, SEEK_CUR); // include chunk preamble |
524 chunk_size += 8; | |
525 goto get_video_packet; | |
526 | |
3704 | 527 case mTCD_TAG: |
528 url_fseek(pb, 8, SEEK_CUR); // skip ea dct header | |
529 chunk_size -= 8; | |
530 goto get_video_packet; | |
531 | |
2613 | 532 case MV0K_TAG: |
3706
590e8cbe6d77
Support Electronic Arts files containing MPEG2VIDEO.
pross
parents:
3704
diff
changeset
|
533 case MPCh_TAG: |
4379 | 534 case pIQT_TAG: |
2613 | 535 key = PKT_FLAG_KEY; |
536 case MV0F_TAG: | |
3551 | 537 get_video_packet: |
2613 | 538 ret = av_get_packet(pb, pkt, chunk_size); |
4849
92468cd5b594
Make electronicarts demuxer return partial frames, this is the default
reimar
parents:
4451
diff
changeset
|
539 if (ret < 0) |
92468cd5b594
Make electronicarts demuxer return partial frames, this is the default
reimar
parents:
4451
diff
changeset
|
540 return ret; |
4850 | 541 pkt->stream_index = ea->video_stream_index; |
542 pkt->flags |= key; | |
2613 | 543 packet_read = 1; |
544 break; | |
545 | |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
546 default: |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
547 url_fseek(pb, chunk_size, SEEK_CUR); |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
548 break; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
549 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
550 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
551 |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
552 return ret; |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
553 } |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
554 |
1169 | 555 AVInputFormat ea_demuxer = { |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
556 "ea", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3291
diff
changeset
|
557 NULL_IF_CONFIG_SMALL("Electronic Arts Multimedia Format"), |
565
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
558 sizeof(EaDemuxContext), |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
559 ea_probe, |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
560 ea_read_header, |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
561 ea_read_packet, |
485a529adaee
Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff
changeset
|
562 }; |