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