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