annotate electronicarts.c @ 1782:4f4edbced58a libavformat

dont set the keyframe flag for audio as microshitty doesnt do it and some things have problems with our asfs, maybe that has a positive effect?
author michael
date Mon, 12 Feb 2007 19:24:53 +0000
parents a782462e2497
children 1a3c9056982a
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
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
3 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1169
diff changeset
4 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1169
diff changeset
5 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1169
diff changeset
6 * 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
7 * 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
8 * 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
9 * 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
10 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1169
diff changeset
11 * 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
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
14 * Lesser General Public License for more details.
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
15 *
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
16 * 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
17 * 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
18 * 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
19 */
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 * @file electronicarts.c
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
23 * Electronic Arts Multimedia file demuxer (WVE/UV2/etc.)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
24 * by Robin Kay (komadori at gekkou.co.uk)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
25 */
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 #include "avformat.h"
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
28
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
29 #define SCHl_TAG MKTAG('S', 'C', 'H', 'l')
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
30 #define PT00_TAG MKTAG('P', 'T', 0x0, 0x0)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
31 #define SCDl_TAG MKTAG('S', 'C', 'D', 'l')
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
32 #define pIQT_TAG MKTAG('p', 'I', 'Q', 'T')
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
33 #define SCEl_TAG MKTAG('S', 'C', 'E', 'l')
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
34 #define _TAG MKTAG('', '', '', '')
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
35
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
36 #define EA_SAMPLE_RATE 22050
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
37 #define EA_BITS_PER_SAMPLE 16
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
38 #define EA_PREAMBLE_SIZE 8
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
39
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
40 typedef struct EaDemuxContext {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
41 int width;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
42 int height;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
43 int video_stream_index;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
44 int track_count;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
45
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
46 int audio_stream_index;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
47 int audio_frame_counter;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
48
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
49 int64_t audio_pts;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
50 int64_t video_pts;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
51 int video_pts_inc;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
52 float fps;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
53
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
54 int num_channels;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
55 int num_samples;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
56 int compression_type;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
57 } EaDemuxContext;
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 static uint32_t read_arbitary(ByteIOContext *pb) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
60 uint8_t size, byte;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
61 int i;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
62 uint32_t word;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
63
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
64 size = get_byte(pb);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
65
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
66 word = 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
67 for (i = 0; i < size; i++) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
68 byte = get_byte(pb);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
69 word <<= 8;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
70 word |= byte;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
71 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
72
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
73 return word;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
74 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
75
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
76 /*
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
77 * Process WVE file header
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
78 * Returns 1 if the WVE file is valid and successfully opened, 0 otherwise
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 int process_ea_header(AVFormatContext *s) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
81 int inHeader;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
82 uint32_t blockid, size;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
83 EaDemuxContext *ea = (EaDemuxContext *)s->priv_data;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
84 ByteIOContext *pb = &s->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 if (get_buffer(pb, (void*)&blockid, 4) != 4) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
87 return 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
88 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
89 if (le2me_32(blockid) != SCHl_TAG) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
90 return 0;
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 if (get_buffer(pb, (void*)&size, 4) != 4) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
94 return 0;
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 size = le2me_32(size);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
97
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
98 if (get_buffer(pb, (void*)&blockid, 4) != 4) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
99 return 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
100 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
101 if (le2me_32(blockid) != PT00_TAG) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
102 av_log (s, AV_LOG_ERROR, "PT header missing\n");
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
103 return 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
104 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
105
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
106 inHeader = 1;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
107 while (inHeader) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
108 int inSubheader;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
109 uint8_t byte;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
110 byte = get_byte(pb) & 0xFF;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
111
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
112 switch (byte) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
113 case 0xFD:
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
114 av_log (s, AV_LOG_INFO, "entered audio subheader\n");
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
115 inSubheader = 1;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
116 while (inSubheader) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
117 uint8_t subbyte;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
118 subbyte = get_byte(pb) & 0xFF;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
119
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
120 switch (subbyte) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
121 case 0x82:
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
122 ea->num_channels = read_arbitary(pb);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
123 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
124 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
125 case 0x83:
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
126 ea->compression_type = read_arbitary(pb);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
127 av_log (s, AV_LOG_INFO, "compression_type (element 0x83) set to 0x%08x\n", ea->compression_type);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
128 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
129 case 0x85:
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
130 ea->num_samples = 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_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
132 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
133 case 0x8A:
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
134 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
135 av_log (s, AV_LOG_INFO, "exited audio subheader\n");
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
136 inSubheader = 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
137 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
138 default:
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
139 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
140 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
141 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
142 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
143 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
144 case 0xFF:
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
145 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
146 inHeader = 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
147 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
148 default:
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
149 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
150 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
151 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
152 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
153
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
154 if ((ea->num_channels != 2) || (ea->compression_type != 7)) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
155 av_log (s, AV_LOG_ERROR, "unsupported stream type\n");
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
156 return 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
157 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
158
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
159 /* skip to the start of the data */
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
160 url_fseek(pb, size, SEEK_SET);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
161
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
162 return 1;
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
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
166 static int ea_probe(AVProbeData *p)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
167 {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
168 if (p->buf_size < 4)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
169 return 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
170
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
171 if (AV_RL32(&p->buf[0]) != SCHl_TAG)
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
172 return 0;
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 return AVPROBE_SCORE_MAX;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
175 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
176
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
177 static int ea_read_header(AVFormatContext *s,
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
178 AVFormatParameters *ap)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
179 {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
180 EaDemuxContext *ea = (EaDemuxContext *)s->priv_data;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
181 AVStream *st;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
182
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
183 if (!process_ea_header(s))
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
184 return AVERROR_IO;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
185
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
186 #if 0
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
187 /* initialize the video decoder stream */
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
188 st = av_new_stream(s, 0);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
189 if (!st)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
190 return AVERROR_NOMEM;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
191 av_set_pts_info(st, 33, 1, 90000);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
192 ea->video_stream_index = st->index;
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
193 st->codec->codec_type = CODEC_TYPE_VIDEO;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
194 st->codec->codec_id = CODEC_ID_EA_MJPEG;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
195 st->codec->codec_tag = 0; /* no fourcc */
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 820
diff changeset
196 #endif
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
197
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
198 /* initialize the audio decoder stream */
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
199 st = av_new_stream(s, 0);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
200 if (!st)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
201 return AVERROR_NOMEM;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
202 av_set_pts_info(st, 33, 1, EA_SAMPLE_RATE);
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
203 st->codec->codec_type = CODEC_TYPE_AUDIO;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
204 st->codec->codec_id = CODEC_ID_ADPCM_EA;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
205 st->codec->codec_tag = 0; /* no tag */
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
206 st->codec->channels = ea->num_channels;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
207 st->codec->sample_rate = EA_SAMPLE_RATE;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
208 st->codec->bits_per_sample = EA_BITS_PER_SAMPLE;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
209 st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
210 st->codec->bits_per_sample / 4;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 775
diff changeset
211 st->codec->block_align = st->codec->channels * st->codec->bits_per_sample;
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
212
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
213 ea->audio_stream_index = st->index;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
214 ea->audio_frame_counter = 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
215
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
216 return 1;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
217 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
218
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
219 static int ea_read_packet(AVFormatContext *s,
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
220 AVPacket *pkt)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
221 {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
222 EaDemuxContext *ea = s->priv_data;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
223 ByteIOContext *pb = &s->pb;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
224 int ret = 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
225 int packet_read = 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
226 unsigned char preamble[EA_PREAMBLE_SIZE];
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
227 unsigned int chunk_type, chunk_size;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
228
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
229 while (!packet_read) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
230
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
231 if (get_buffer(pb, preamble, EA_PREAMBLE_SIZE) != EA_PREAMBLE_SIZE)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
232 return AVERROR_IO;
1673
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
233 chunk_type = AV_RL32(&preamble[0]);
a782462e2497 rename BE/LE_8/16/32 to AV_RL/B_8/16/32
alex
parents: 1358
diff changeset
234 chunk_size = AV_RL32(&preamble[4]) - EA_PREAMBLE_SIZE;
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
235
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
236 switch (chunk_type) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
237 /* audio data */
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
238 case SCDl_TAG:
775
c5077fdab490 AVPacket.pos
michael
parents: 565
diff changeset
239 ret = av_get_packet(pb, pkt, chunk_size);
c5077fdab490 AVPacket.pos
michael
parents: 565
diff changeset
240 if (ret != chunk_size)
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
241 ret = AVERROR_IO;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
242 else {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
243 pkt->stream_index = ea->audio_stream_index;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
244 pkt->pts = 90000;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
245 pkt->pts *= ea->audio_frame_counter;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
246 pkt->pts /= EA_SAMPLE_RATE;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
247
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 820
diff changeset
248 /* 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
249 * on stereo; chunk also has 12-byte header */
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
250 ea->audio_frame_counter += ((chunk_size - 12) * 2) /
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
251 ea->num_channels;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
252 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
253
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
254 packet_read = 1;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
255 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
256
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
257 /* ending tag */
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
258 case SCEl_TAG:
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
259 ret = AVERROR_IO;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
260 packet_read = 1;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
261 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
262
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
263 default:
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
264 url_fseek(pb, chunk_size, SEEK_CUR);
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
265 break;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
266 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
267
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
268 /* ending packet */
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
269 if (chunk_type == SCEl_TAG) {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
270 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
271 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
272
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
273 return ret;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
274 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
275
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
276 static int ea_read_close(AVFormatContext *s)
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
277 {
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
278 // EaDemuxContext *ea = (EaDemuxContext *)s->priv_data;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
279
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
280 return 0;
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
281 }
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
282
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
283 AVInputFormat ea_demuxer = {
565
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
284 "ea",
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
285 "Electronic Arts Multimedia Format",
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
286 sizeof(EaDemuxContext),
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
287 ea_probe,
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
288 ea_read_header,
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
289 ea_read_packet,
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
290 ea_read_close,
485a529adaee Electronic Arts Game Multimedia format demuxer (WVE/UV2/etc.)
melanson
parents:
diff changeset
291 };