annotate electronicarts.c @ 5562:5d938dd16b34 libavformat

set average frame rate in mov demuxer
author bcoudurier
date Mon, 18 Jan 2010 23:56:04 +0000
parents a45748f721d1
children 536e5527c1e0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
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
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
32 #define SEAD_TAG MKTAG('S', 'E', 'A', 'D') /* Sxxx header */
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
33 #define SNDC_TAG MKTAG('S', 'N', 'D', 'C') /* Sxxx data */
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
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
feb0352f07e5 don't use #define with names starting with _
aurel
parents: 2673
diff changeset
38 #define ISNh_TAG MKTAG('1', 'S', 'N', 'h') /* 1SNx header */
2673
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
39 #define EACS_TAG MKTAG('E', 'A', 'C', 'S')
2674
feb0352f07e5 don't use #define with names starting with _
aurel
parents: 2673
diff changeset
40 #define ISNd_TAG MKTAG('1', 'S', 'N', 'd') /* 1SNx data */
feb0352f07e5 don't use #define with names starting with _
aurel
parents: 2673
diff changeset
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
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
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
4cfddd2c98a5 probe more kind of electronic arts files
aurel
parents: 2686
diff changeset
46 #define kVGT_TAG MKTAG('k', 'V', 'G', 'T') /* TGV i-frame */
3697
c458ae91b0f9 Add Electronic Arts TGV chunk tags to EA demuxer.
pross
parents: 3609
diff changeset
47 #define fVGT_TAG MKTAG('f', 'V', 'G', 'T') /* TGV p-frame */
3704
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
48 #define mTCD_TAG MKTAG('m', 'T', 'C', 'D') /* MDEC */
2717
4cfddd2c98a5 probe more kind of electronic arts files
aurel
parents: 2686
diff changeset
49 #define MADk_TAG MKTAG('M', 'A', 'D', 'k') /* MAD i-frame */
5028
4ba7fd2077bd Electronic Arts demuxer: support Madcow video tag
pross
parents: 4881
diff changeset
50 #define MADm_TAG MKTAG('M', 'A', 'D', 'm') /* MAD p-frame */
4ba7fd2077bd Electronic Arts demuxer: support Madcow video tag
pross
parents: 4881
diff changeset
51 #define MADe_TAG MKTAG('M', 'A', 'D', 'e') /* MAD lqp-frame */
2717
4cfddd2c98a5 probe more kind of electronic arts files
aurel
parents: 2686
diff changeset
52 #define MPCh_TAG MKTAG('M', 'P', 'C', 'h') /* MPEG2 */
4018
0c2f650d31bb Electronic Arts demuxer: support TGQ video tags
pross
parents: 3908
diff changeset
53 #define TGQs_TAG MKTAG('T', 'G', 'Q', 's') /* TGQ i-frame (appears in .TGQ files) */
0c2f650d31bb Electronic Arts demuxer: support TGQ video tags
pross
parents: 3908
diff changeset
54 #define pQGT_TAG MKTAG('p', 'Q', 'G', 'T') /* TGQ i-frame (appears in .UV files) */
4379
7c628699cc3d Electronic Arts demuxer: support TQI video tag
pross
parents: 4331
diff changeset
55 #define pIQT_TAG MKTAG('p', 'I', 'Q', 'T') /* TQI/UV2 i-frame (.UV2/.WVE) */
2613
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
56 #define MVhd_TAG MKTAG('M', 'V', 'h', 'd')
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
57 #define MV0K_TAG MKTAG('M', 'V', '0', 'K')
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
58 #define MV0F_TAG MKTAG('M', 'V', '0', 'F')
2717
4cfddd2c98a5 probe more kind of electronic arts files
aurel
parents: 2686
diff changeset
59 #define MVIh_TAG MKTAG('M', 'V', 'I', 'h') /* CMV header */
3551
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
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
9513cc77beb0 add support for big_endian encoded headers
aurel
parents: 2634
diff changeset
63 int big_endian;
9513cc77beb0 add support for big_endian encoded headers
aurel
parents: 2634
diff changeset
64
3291
fb5f48e1956f Fix icc warning #188: enumerated type mixed with another type
cehoyos
parents: 2780
diff changeset
65 enum CodecID video_codec;
2613
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
66 AVRational time_base;
3704
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
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
6a53777da0c9 set bytes per sample in the context
aurel
parents: 2641
diff changeset
74 int bytes;
2639
39efecda734f parse sample rate instead of setting a default one
aurel
parents: 2638
diff changeset
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
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
98 * Process PT/GSTR sound header
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
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
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
101 static int process_audio_header_elements(AVFormatContext *s)
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
102 {
2611
48784931f30a merge declaration and initialization
aurel
parents: 2610
diff changeset
103 int inHeader = 1;
2006
2f0154760e5f Get rid of unnecessary pointer casts.
diego
parents: 2001
diff changeset
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
6a53777da0c9 set bytes per sample in the context
aurel
parents: 2641
diff changeset
108 ea->bytes = 2;
2639
39efecda734f parse sample rate instead of setting a default one
aurel
parents: 2638
diff changeset
109 ea->sample_rate = -1;
2627
af403e794831 set a default value for num_channels
aurel
parents: 2626
diff changeset
110 ea->num_channels = 1;
af403e794831 set a default value for num_channels
aurel
parents: 2626
diff changeset
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
256e5d7828e5 remove useless &0xFF
aurel
parents: 2611
diff changeset
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
256e5d7828e5 remove useless &0xFF
aurel
parents: 2611
diff changeset
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
39efecda734f parse sample rate instead of setting a default one
aurel
parents: 2638
diff changeset
126 case 0x80:
39efecda734f parse sample rate instead of setting a default one
aurel
parents: 2638
diff changeset
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
39efecda734f parse sample rate instead of setting a default one
aurel
parents: 2638
diff changeset
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
39efecda734f parse sample rate instead of setting a default one
aurel
parents: 2638
diff changeset
138 case 0x84:
39efecda734f parse sample rate instead of setting a default one
aurel
parents: 2638
diff changeset
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
39efecda734f parse sample rate instead of setting a default one
aurel
parents: 2638
diff changeset
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
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
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
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
157 inSubheader = 0;
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
158 inHeader = 0;
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
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
b8f97bf41cc3 check compression_type to assign audio codec
aurel
parents: 2636
diff changeset
176 switch (compression_type) {
2638
ba383dcf2465 add support for PCM codec
aurel
parents: 2637
diff changeset
177 case 0: ea->audio_codec = CODEC_ID_PCM_S16LE; break;
2637
b8f97bf41cc3 check compression_type to assign audio codec
aurel
parents: 2636
diff changeset
178 case 7: ea->audio_codec = CODEC_ID_ADPCM_EA; break;
2670
7e9a23c3f20d EA ADPCM R1, R2 and R3 decoder
aurel
parents: 2661
diff changeset
179 case -1:
7e9a23c3f20d EA ADPCM R1, R2 and R3 decoder
aurel
parents: 2661
diff changeset
180 switch (revision) {
7e9a23c3f20d EA ADPCM R1, R2 and R3 decoder
aurel
parents: 2661
diff changeset
181 case 1: ea->audio_codec = CODEC_ID_ADPCM_EA_R1; break;
7e9a23c3f20d EA ADPCM R1, R2 and R3 decoder
aurel
parents: 2661
diff changeset
182 case 2: ea->audio_codec = CODEC_ID_ADPCM_EA_R2; break;
7e9a23c3f20d EA ADPCM R1, R2 and R3 decoder
aurel
parents: 2661
diff changeset
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
7e9a23c3f20d EA ADPCM R1, R2 and R3 decoder
aurel
parents: 2661
diff changeset
185 default:
7e9a23c3f20d EA ADPCM R1, R2 and R3 decoder
aurel
parents: 2661
diff changeset
186 av_log(s, AV_LOG_ERROR, "unsupported stream type; revision=%i\n", revision);
7e9a23c3f20d EA ADPCM R1, R2 and R3 decoder
aurel
parents: 2661
diff changeset
187 return 0;
7e9a23c3f20d EA ADPCM R1, R2 and R3 decoder
aurel
parents: 2661
diff changeset
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
f8aa0763f334 Support Electronic Arts files containing MP3 audio.
pross
parents: 3709
diff changeset
192 case 16: ea->audio_codec = CODEC_ID_MP3; break;
3609
08688b4b1441 EA Demuxer: make rev2 flag optional
pross
parents: 3551
diff changeset
193 case -1: break;
2780
0b9d29522781 add pcm_s16le_planar support for electronicarts files
aurel
parents: 2771
diff changeset
194 default:
5511
a45748f721d1 Use enum CodecID where appropriate.
cehoyos
parents: 5509
diff changeset
195 ea->audio_codec = CODEC_ID_NONE;
2780
0b9d29522781 add pcm_s16le_planar support for electronicarts files
aurel
parents: 2771
diff changeset
196 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
197 return 0;
0b9d29522781 add pcm_s16le_planar support for electronicarts files
aurel
parents: 2771
diff changeset
198 }
2670
7e9a23c3f20d EA ADPCM R1, R2 and R3 decoder
aurel
parents: 2661
diff changeset
199 break;
2637
b8f97bf41cc3 check compression_type to assign audio codec
aurel
parents: 2636
diff changeset
200 default:
b8f97bf41cc3 check compression_type to assign audio codec
aurel
parents: 2636
diff changeset
201 av_log(s, AV_LOG_ERROR, "unsupported stream type; compression_type=%i\n", compression_type);
b8f97bf41cc3 check compression_type to assign audio codec
aurel
parents: 2636
diff changeset
202 return 0;
b8f97bf41cc3 check compression_type to assign audio codec
aurel
parents: 2636
diff changeset
203 }
2631
f37d16f2c940 add audio and video codec context vars
aurel
parents: 2630
diff changeset
204
2639
39efecda734f parse sample rate instead of setting a default one
aurel
parents: 2638
diff changeset
205 if (ea->sample_rate == -1)
39efecda734f parse sample rate instead of setting a default one
aurel
parents: 2638
diff changeset
206 ea->sample_rate = revision==3 ? 48000 : 22050;
39efecda734f parse sample rate instead of setting a default one
aurel
parents: 2638
diff changeset
207
2626
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
208 return 1;
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
209 }
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
210
2673
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
211 /*
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
212 * Process EACS sound header
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
213 * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
214 */
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
215 static int process_audio_header_eacs(AVFormatContext *s)
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
216 {
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
217 EaDemuxContext *ea = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2717
diff changeset
218 ByteIOContext *pb = s->pb;
2673
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
219 int compression_type;
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
220
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
221 ea->sample_rate = ea->big_endian ? get_be32(pb) : get_le32(pb);
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
222 ea->bytes = get_byte(pb); /* 1=8-bit, 2=16-bit */
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
223 ea->num_channels = get_byte(pb);
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
224 compression_type = get_byte(pb);
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
225 url_fskip(pb, 13);
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
226
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
227 switch (compression_type) {
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
228 case 0:
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
229 switch (ea->bytes) {
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
230 case 1: ea->audio_codec = CODEC_ID_PCM_S8; break;
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
231 case 2: ea->audio_codec = CODEC_ID_PCM_S16LE; break;
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
232 }
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
233 break;
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
234 case 1: ea->audio_codec = CODEC_ID_PCM_MULAW; ea->bytes = 1; break;
2686
af608703bde1 EA IMA EACS decoder
aurel
parents: 2685
diff changeset
235 case 2: ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_EACS; break;
2673
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
236 default:
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
237 av_log (s, AV_LOG_ERROR, "unsupported stream type; audio compression_type=%i\n", compression_type);
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
238 }
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
239
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
240 return 1;
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
241 }
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
242
2685
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
243 /*
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
244 * Process SEAD sound header
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
245 * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
246 */
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
247 static int process_audio_header_sead(AVFormatContext *s)
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
248 {
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
249 EaDemuxContext *ea = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2717
diff changeset
250 ByteIOContext *pb = s->pb;
2685
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
251
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
252 ea->sample_rate = get_le32(pb);
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
253 ea->bytes = get_le32(pb); /* 1=8-bit, 2=16-bit */
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
254 ea->num_channels = get_le32(pb);
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
255 ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_SEAD;
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
256
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
257 return 1;
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
258 }
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
259
3704
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
260 static int process_video_header_mdec(AVFormatContext *s)
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
261 {
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
262 EaDemuxContext *ea = s->priv_data;
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
263 ByteIOContext *pb = s->pb;
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
264 url_fskip(pb, 4);
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
265 ea->width = get_le16(pb);
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
266 ea->height = get_le16(pb);
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
267 ea->time_base = (AVRational){1,15};
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
268 ea->video_codec = CODEC_ID_MDEC;
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
269 return 1;
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
270 }
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
271
2629
eaebf51f195d move vp6 header parsing into its own function
aurel
parents: 2628
diff changeset
272 static int process_video_header_vp6(AVFormatContext *s)
eaebf51f195d move vp6 header parsing into its own function
aurel
parents: 2628
diff changeset
273 {
eaebf51f195d move vp6 header parsing into its own function
aurel
parents: 2628
diff changeset
274 EaDemuxContext *ea = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2717
diff changeset
275 ByteIOContext *pb = s->pb;
2629
eaebf51f195d move vp6 header parsing into its own function
aurel
parents: 2628
diff changeset
276
eaebf51f195d move vp6 header parsing into its own function
aurel
parents: 2628
diff changeset
277 url_fskip(pb, 16);
eaebf51f195d move vp6 header parsing into its own function
aurel
parents: 2628
diff changeset
278 ea->time_base.den = get_le32(pb);
eaebf51f195d move vp6 header parsing into its own function
aurel
parents: 2628
diff changeset
279 ea->time_base.num = get_le32(pb);
2631
f37d16f2c940 add audio and video codec context vars
aurel
parents: 2630
diff changeset
280 ea->video_codec = CODEC_ID_VP6;
2629
eaebf51f195d move vp6 header parsing into its own function
aurel
parents: 2628
diff changeset
281
eaebf51f195d move vp6 header parsing into its own function
aurel
parents: 2628
diff changeset
282 return 1;
eaebf51f195d move vp6 header parsing into its own function
aurel
parents: 2628
diff changeset
283 }
eaebf51f195d move vp6 header parsing into its own function
aurel
parents: 2628
diff changeset
284
2626
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
285 /*
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
286 * Process EA file header
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
287 * Returns 1 if the EA file is valid and successfully opened, 0 otherwise
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
288 */
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
289 static int process_ea_header(AVFormatContext *s) {
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
290 uint32_t blockid, size = 0;
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
291 EaDemuxContext *ea = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2717
diff changeset
292 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
293 int i;
c5118e086450 parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents: 2631
diff changeset
294
c5118e086450 parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents: 2631
diff changeset
295 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
296 unsigned int startpos = url_ftell(pb);
2634
95cfd6b8f8d5 add some error processing
aurel
parents: 2633
diff changeset
297 int err = 0;
2626
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
298
2633
0605d25fba46 cosmetics: indentation
aurel
parents: 2632
diff changeset
299 blockid = get_le32(pb);
2626
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
300 size = get_le32(pb);
2635
9513cc77beb0 add support for big_endian encoded headers
aurel
parents: 2634
diff changeset
301 if (i == 0)
9513cc77beb0 add support for big_endian encoded headers
aurel
parents: 2634
diff changeset
302 ea->big_endian = size > 0x000FFFFF;
9513cc77beb0 add support for big_endian encoded headers
aurel
parents: 2634
diff changeset
303 if (ea->big_endian)
9513cc77beb0 add support for big_endian encoded headers
aurel
parents: 2634
diff changeset
304 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
305
c5118e086450 parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents: 2631
diff changeset
306 switch (blockid) {
2674
feb0352f07e5 don't use #define with names starting with _
aurel
parents: 2673
diff changeset
307 case ISNh_TAG:
2673
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
308 if (get_le32(pb) != EACS_TAG) {
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
309 av_log (s, AV_LOG_ERROR, "unknown 1SNh headerid\n");
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
310 return 0;
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
311 }
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
312 err = process_audio_header_eacs(s);
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
313 break;
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
314
2632
c5118e086450 parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents: 2631
diff changeset
315 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
316 case SHEN_TAG :
2633
0605d25fba46 cosmetics: indentation
aurel
parents: 2632
diff changeset
317 blockid = get_le32(pb);
0605d25fba46 cosmetics: indentation
aurel
parents: 2632
diff changeset
318 if (blockid == GSTR_TAG) {
0605d25fba46 cosmetics: indentation
aurel
parents: 2632
diff changeset
319 url_fskip(pb, 4);
3707
57d88d565add Electronic Arts demuxer: ignore PTxx platform ID values.
pross
parents: 3706
diff changeset
320 } else if ((blockid & 0xFFFF)!=PT00_TAG) {
2633
0605d25fba46 cosmetics: indentation
aurel
parents: 2632
diff changeset
321 av_log (s, AV_LOG_ERROR, "unknown SCHl headerid\n");
0605d25fba46 cosmetics: indentation
aurel
parents: 2632
diff changeset
322 return 0;
0605d25fba46 cosmetics: indentation
aurel
parents: 2632
diff changeset
323 }
2634
95cfd6b8f8d5 add some error processing
aurel
parents: 2633
diff changeset
324 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
325 break;
2626
39ede602ff13 move audio header parsing in its own function
aurel
parents: 2625
diff changeset
326
2685
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
327 case SEAD_TAG:
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
328 err = process_audio_header_sead(s);
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
329 break;
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
330
3551
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
331 case MVIh_TAG :
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
332 ea->video_codec = CODEC_ID_CMV;
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
333 ea->time_base = (AVRational){0,0};
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
334 break;
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
335
3697
c458ae91b0f9 Add Electronic Arts TGV chunk tags to EA demuxer.
pross
parents: 3609
diff changeset
336 case kVGT_TAG:
c458ae91b0f9 Add Electronic Arts TGV chunk tags to EA demuxer.
pross
parents: 3609
diff changeset
337 ea->video_codec = CODEC_ID_TGV;
c458ae91b0f9 Add Electronic Arts TGV chunk tags to EA demuxer.
pross
parents: 3609
diff changeset
338 ea->time_base = (AVRational){0,0};
c458ae91b0f9 Add Electronic Arts TGV chunk tags to EA demuxer.
pross
parents: 3609
diff changeset
339 break;
c458ae91b0f9 Add Electronic Arts TGV chunk tags to EA demuxer.
pross
parents: 3609
diff changeset
340
3704
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
341 case mTCD_TAG :
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
342 err = process_video_header_mdec(s);
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
343 break;
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
344
3706
590e8cbe6d77 Support Electronic Arts files containing MPEG2VIDEO.
pross
parents: 3704
diff changeset
345 case MPCh_TAG:
590e8cbe6d77 Support Electronic Arts files containing MPEG2VIDEO.
pross
parents: 3704
diff changeset
346 ea->video_codec = CODEC_ID_MPEG2VIDEO;
590e8cbe6d77 Support Electronic Arts files containing MPEG2VIDEO.
pross
parents: 3704
diff changeset
347 break;
590e8cbe6d77 Support Electronic Arts files containing MPEG2VIDEO.
pross
parents: 3704
diff changeset
348
4018
0c2f650d31bb Electronic Arts demuxer: support TGQ video tags
pross
parents: 3908
diff changeset
349 case pQGT_TAG:
0c2f650d31bb Electronic Arts demuxer: support TGQ video tags
pross
parents: 3908
diff changeset
350 case TGQs_TAG:
0c2f650d31bb Electronic Arts demuxer: support TGQ video tags
pross
parents: 3908
diff changeset
351 ea->video_codec = CODEC_ID_TGQ;
0c2f650d31bb Electronic Arts demuxer: support TGQ video tags
pross
parents: 3908
diff changeset
352 break;
0c2f650d31bb Electronic Arts demuxer: support TGQ video tags
pross
parents: 3908
diff changeset
353
4379
7c628699cc3d Electronic Arts demuxer: support TQI video tag
pross
parents: 4331
diff changeset
354 case pIQT_TAG:
7c628699cc3d Electronic Arts demuxer: support TQI video tag
pross
parents: 4331
diff changeset
355 ea->video_codec = CODEC_ID_TQI;
7c628699cc3d Electronic Arts demuxer: support TQI video tag
pross
parents: 4331
diff changeset
356 break;
7c628699cc3d Electronic Arts demuxer: support TQI video tag
pross
parents: 4331
diff changeset
357
5028
4ba7fd2077bd Electronic Arts demuxer: support Madcow video tag
pross
parents: 4881
diff changeset
358 case MADk_TAG :
4ba7fd2077bd Electronic Arts demuxer: support Madcow video tag
pross
parents: 4881
diff changeset
359 ea->video_codec = CODEC_ID_MAD;
4ba7fd2077bd Electronic Arts demuxer: support Madcow video tag
pross
parents: 4881
diff changeset
360 break;
4ba7fd2077bd Electronic Arts demuxer: support Madcow video tag
pross
parents: 4881
diff changeset
361
2632
c5118e086450 parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents: 2631
diff changeset
362 case MVhd_TAG :
2634
95cfd6b8f8d5 add some error processing
aurel
parents: 2633
diff changeset
363 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
364 break;
c5118e086450 parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents: 2631
diff changeset
365 }
c5118e086450 parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents: 2631
diff changeset
366
2634
95cfd6b8f8d5 add some error processing
aurel
parents: 2633
diff changeset
367 if (err < 0) {
95cfd6b8f8d5 add some error processing
aurel
parents: 2633
diff changeset
368 av_log(s, AV_LOG_ERROR, "error parsing header: %i\n", err);
95cfd6b8f8d5 add some error processing
aurel
parents: 2633
diff changeset
369 return err;
95cfd6b8f8d5 add some error processing
aurel
parents: 2633
diff changeset
370 }
95cfd6b8f8d5 add some error processing
aurel
parents: 2633
diff changeset
371
2632
c5118e086450 parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents: 2631
diff changeset
372 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
373 }
c5118e086450 parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents: 2631
diff changeset
374
c5118e086450 parse header chunk in a loop (don't depend on a fixed chunk ordering)
aurel
parents: 2631
diff changeset
375 url_fseek(pb, 0, SEEK_SET);
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
376
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
377 return 1;
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
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
381 static int ea_probe(AVProbeData *p)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
382 {
2661
bed166d88f63 convert a if() into a switch() to ease addition of new tags to probe
aurel
parents: 2647
diff changeset
383 switch (AV_RL32(&p->buf[0])) {
2675
43ca0db0aa92 probe files starting with the 1SNh tag
aurel
parents: 2674
diff changeset
384 case ISNh_TAG:
2661
bed166d88f63 convert a if() into a switch() to ease addition of new tags to probe
aurel
parents: 2647
diff changeset
385 case SCHl_TAG:
2685
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
386 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
387 case SHEN_TAG:
2717
4cfddd2c98a5 probe more kind of electronic arts files
aurel
parents: 2686
diff changeset
388 case kVGT_TAG:
4cfddd2c98a5 probe more kind of electronic arts files
aurel
parents: 2686
diff changeset
389 case MADk_TAG:
4cfddd2c98a5 probe more kind of electronic arts files
aurel
parents: 2686
diff changeset
390 case MPCh_TAG:
2661
bed166d88f63 convert a if() into a switch() to ease addition of new tags to probe
aurel
parents: 2647
diff changeset
391 case MVhd_TAG:
2717
4cfddd2c98a5 probe more kind of electronic arts files
aurel
parents: 2686
diff changeset
392 case MVIh_TAG:
5215
6fc9f9d8aaa1 Slightly improve probe for ea format by checking that it is possible to
reimar
parents: 5028
diff changeset
393 break;
6fc9f9d8aaa1 Slightly improve probe for ea format by checking that it is possible to
reimar
parents: 5028
diff changeset
394 default:
6fc9f9d8aaa1 Slightly improve probe for ea format by checking that it is possible to
reimar
parents: 5028
diff changeset
395 return 0;
2661
bed166d88f63 convert a if() into a switch() to ease addition of new tags to probe
aurel
parents: 2647
diff changeset
396 }
5215
6fc9f9d8aaa1 Slightly improve probe for ea format by checking that it is possible to
reimar
parents: 5028
diff changeset
397 if (AV_RL32(&p->buf[4]) > 0xfffff && AV_RB32(&p->buf[4]) > 0xfffff)
6fc9f9d8aaa1 Slightly improve probe for ea format by checking that it is possible to
reimar
parents: 5028
diff changeset
398 return 0;
6fc9f9d8aaa1 Slightly improve probe for ea format by checking that it is possible to
reimar
parents: 5028
diff changeset
399 return AVPROBE_SCORE_MAX;
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
400 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
401
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
402 static int ea_read_header(AVFormatContext *s,
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
403 AVFormatParameters *ap)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
404 {
2006
2f0154760e5f Get rid of unnecessary pointer casts.
diego
parents: 2001
diff changeset
405 EaDemuxContext *ea = s->priv_data;
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
406 AVStream *st;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
407
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
408 if (!process_ea_header(s))
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
409 return AVERROR(EIO);
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
410
2647
48526bd11471 better check for video track detection
aurel
parents: 2646
diff changeset
411 if (ea->video_codec) {
2614
46d233a8d62b cosmetics: reindent
aurel
parents: 2613
diff changeset
412 /* initialize the video decoder stream */
46d233a8d62b cosmetics: reindent
aurel
parents: 2613
diff changeset
413 st = av_new_stream(s, 0);
46d233a8d62b cosmetics: reindent
aurel
parents: 2613
diff changeset
414 if (!st)
46d233a8d62b cosmetics: reindent
aurel
parents: 2613
diff changeset
415 return AVERROR(ENOMEM);
46d233a8d62b cosmetics: reindent
aurel
parents: 2613
diff changeset
416 ea->video_stream_index = st->index;
46d233a8d62b cosmetics: reindent
aurel
parents: 2613
diff changeset
417 st->codec->codec_type = CODEC_TYPE_VIDEO;
2631
f37d16f2c940 add audio and video codec context vars
aurel
parents: 2630
diff changeset
418 st->codec->codec_id = ea->video_codec;
2614
46d233a8d62b cosmetics: reindent
aurel
parents: 2613
diff changeset
419 st->codec->codec_tag = 0; /* no fourcc */
46d233a8d62b cosmetics: reindent
aurel
parents: 2613
diff changeset
420 st->codec->time_base = ea->time_base;
3704
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
421 st->codec->width = ea->width;
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
422 st->codec->height = ea->height;
2613
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
423 }
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
424
2644
ad769d06b84c check if we found an audio track before initializing the audio stream
aurel
parents: 2643
diff changeset
425 if (ea->audio_codec) {
2645
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
426 /* initialize the audio decoder stream */
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
427 st = av_new_stream(s, 0);
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
428 if (!st)
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
429 return AVERROR(ENOMEM);
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
430 av_set_pts_info(st, 33, 1, ea->sample_rate);
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
431 st->codec->codec_type = CODEC_TYPE_AUDIO;
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
432 st->codec->codec_id = ea->audio_codec;
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
433 st->codec->codec_tag = 0; /* no tag */
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
434 st->codec->channels = ea->num_channels;
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
435 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
436 st->codec->bits_per_coded_sample = ea->bytes * 8;
2645
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
437 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
438 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
439 st->codec->block_align = st->codec->channels*st->codec->bits_per_coded_sample;
2645
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
440 ea->audio_stream_index = st->index;
cd029641333b cosmetics: indentation
aurel
parents: 2644
diff changeset
441 ea->audio_frame_counter = 0;
2644
ad769d06b84c check if we found an audio track before initializing the audio stream
aurel
parents: 2643
diff changeset
442 }
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 return 1;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
445 }
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 static int ea_read_packet(AVFormatContext *s,
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
448 AVPacket *pkt)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
449 {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
450 EaDemuxContext *ea = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2717
diff changeset
451 ByteIOContext *pb = s->pb;
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
452 int ret = 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
453 int packet_read = 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
454 unsigned int chunk_type, chunk_size;
2613
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
455 int key = 0;
4451
4b44e8f4853e Add av_uninit macro to variable to avoid false positive warning:
diego
parents: 4379
diff changeset
456 int av_uninit(num_samples);
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
457
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
458 while (!packet_read) {
2640
2947743d78be simplify
aurel
parents: 2639
diff changeset
459 chunk_type = get_le32(pb);
2641
9725a5726fec fix big endian files support
aurel
parents: 2640
diff changeset
460 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
461
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
462 switch (chunk_type) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
463 /* audio data */
2674
feb0352f07e5 don't use #define with names starting with _
aurel
parents: 2673
diff changeset
464 case ISNh_TAG:
2673
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
465 /* header chunk also contains data; skip over the header portion*/
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
466 url_fskip(pb, 32);
a9e2afed4aa7 add parsing of 1SNh header in the EA demuxer
aurel
parents: 2671
diff changeset
467 chunk_size -= 32;
2674
feb0352f07e5 don't use #define with names starting with _
aurel
parents: 2673
diff changeset
468 case ISNd_TAG:
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
469 case SCDl_TAG:
2685
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
470 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
471 case SDEN_TAG:
2646
f85d4b3d2d7c skip unsupported audio track data
aurel
parents: 2645
diff changeset
472 if (!ea->audio_codec) {
f85d4b3d2d7c skip unsupported audio track data
aurel
parents: 2645
diff changeset
473 url_fskip(pb, chunk_size);
f85d4b3d2d7c skip unsupported audio track data
aurel
parents: 2645
diff changeset
474 break;
3733
f8aa0763f334 Support Electronic Arts files containing MP3 audio.
pross
parents: 3709
diff changeset
475 } else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR ||
f8aa0763f334 Support Electronic Arts files containing MP3 audio.
pross
parents: 3709
diff changeset
476 ea->audio_codec == CODEC_ID_MP3) {
f8aa0763f334 Support Electronic Arts files containing MP3 audio.
pross
parents: 3709
diff changeset
477 num_samples = get_le32(pb);
f8aa0763f334 Support Electronic Arts files containing MP3 audio.
pross
parents: 3709
diff changeset
478 url_fskip(pb, 8);
2780
0b9d29522781 add pcm_s16le_planar support for electronicarts files
aurel
parents: 2771
diff changeset
479 chunk_size -= 12;
2646
f85d4b3d2d7c skip unsupported audio track data
aurel
parents: 2645
diff changeset
480 }
775
c5077fdab490 AVPacket.pos
michael
parents: 565
diff changeset
481 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
482 if (ret < 0)
92468cd5b594 Make electronicarts demuxer return partial frames, this is the default
reimar
parents: 4451
diff changeset
483 return ret;
4850
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
484 pkt->stream_index = ea->audio_stream_index;
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
485 pkt->pts = 90000;
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
486 pkt->pts *= ea->audio_frame_counter;
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
487 pkt->pts /= ea->sample_rate;
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
488
4850
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
489 switch (ea->audio_codec) {
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
490 case CODEC_ID_ADPCM_EA:
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
491 /* 2 samples/byte, 1 or 2 samples per frame depending
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
492 * on stereo; chunk also has 12-byte header */
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
493 ea->audio_frame_counter += ((chunk_size - 12) * 2) /
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
494 ea->num_channels;
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
495 break;
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
496 case CODEC_ID_PCM_S16LE_PLANAR:
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
497 case CODEC_ID_MP3:
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
498 ea->audio_frame_counter += num_samples;
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
499 break;
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
500 default:
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
501 ea->audio_frame_counter += chunk_size /
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
502 (ea->bytes * ea->num_channels);
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
503 }
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
504
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
505 packet_read = 1;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
506 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
507
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
508 /* ending tag */
2671
7f320fb9f1c9 avoid infinite loop at the end of files which are not properly terminated
aurel
parents: 2670
diff changeset
509 case 0:
2674
feb0352f07e5 don't use #define with names starting with _
aurel
parents: 2673
diff changeset
510 case ISNe_TAG:
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
511 case SCEl_TAG:
2685
1774032af3e6 EA IMA SEAD decoder
aurel
parents: 2675
diff changeset
512 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
513 case SEEN_TAG:
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
514 ret = AVERROR(EIO);
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
515 packet_read = 1;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
516 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
517
3551
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
518 case MVIh_TAG:
3697
c458ae91b0f9 Add Electronic Arts TGV chunk tags to EA demuxer.
pross
parents: 3609
diff changeset
519 case kVGT_TAG:
4018
0c2f650d31bb Electronic Arts demuxer: support TGQ video tags
pross
parents: 3908
diff changeset
520 case pQGT_TAG:
0c2f650d31bb Electronic Arts demuxer: support TGQ video tags
pross
parents: 3908
diff changeset
521 case TGQs_TAG:
5028
4ba7fd2077bd Electronic Arts demuxer: support Madcow video tag
pross
parents: 4881
diff changeset
522 case MADk_TAG:
3551
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
523 key = PKT_FLAG_KEY;
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
524 case MVIf_TAG:
3697
c458ae91b0f9 Add Electronic Arts TGV chunk tags to EA demuxer.
pross
parents: 3609
diff changeset
525 case fVGT_TAG:
5028
4ba7fd2077bd Electronic Arts demuxer: support Madcow video tag
pross
parents: 4881
diff changeset
526 case MADm_TAG:
4ba7fd2077bd Electronic Arts demuxer: support Madcow video tag
pross
parents: 4881
diff changeset
527 case MADe_TAG:
3551
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
528 url_fseek(pb, -8, SEEK_CUR); // include chunk preamble
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
529 chunk_size += 8;
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
530 goto get_video_packet;
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
531
3704
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
532 case mTCD_TAG:
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
533 url_fseek(pb, 8, SEEK_CUR); // skip ea dct header
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
534 chunk_size -= 8;
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
535 goto get_video_packet;
03f3eca1498a Add MDEC tags to Electronic Arts demuxer.
pross
parents: 3697
diff changeset
536
2613
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
537 case MV0K_TAG:
3706
590e8cbe6d77 Support Electronic Arts files containing MPEG2VIDEO.
pross
parents: 3704
diff changeset
538 case MPCh_TAG:
4379
7c628699cc3d Electronic Arts demuxer: support TQI video tag
pross
parents: 4331
diff changeset
539 case pIQT_TAG:
2613
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
540 key = PKT_FLAG_KEY;
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
541 case MV0F_TAG:
3551
a4fb7b8098c3 Electronic Arts CMV demuxer
pross
parents: 3424
diff changeset
542 get_video_packet:
2613
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
543 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
544 if (ret < 0)
92468cd5b594 Make electronicarts demuxer return partial frames, this is the default
reimar
parents: 4451
diff changeset
545 return ret;
4850
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
546 pkt->stream_index = ea->video_stream_index;
50df4a8b9733 Reindent
reimar
parents: 4849
diff changeset
547 pkt->flags |= key;
2613
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
548 packet_read = 1;
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
549 break;
8e31eb11b5f2 add support for VP6 in electronicarts demuxer
aurel
parents: 2612
diff changeset
550
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
551 default:
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
552 url_fseek(pb, chunk_size, SEEK_CUR);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
553 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
554 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
555 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
556
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
557 return ret;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
558 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
559
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
560 AVInputFormat ea_demuxer = {
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
561 "ea",
3424
7a0230981402 Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents: 3291
diff changeset
562 NULL_IF_CONFIG_SMALL("Electronic Arts Multimedia Format"),
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
563 sizeof(EaDemuxContext),
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
564 ea_probe,
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
565 ea_read_header,
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
566 ea_read_packet,
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
567 };