1 /*
2 * id RoQ (.roq) File Demuxer
3 * Copyright (c) 2003 The FFmpeg project
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * id RoQ format file demuxer
25 * by Mike Melanson (melanson@pcisys.net)
26 * for more information on the .roq file format, visit:
27 * http://www.csse.monash.edu.au/~timf/
28 */
29
36
37 #define RoQ_MAGIC_NUMBER 0x1084
38 #define RoQ_CHUNK_PREAMBLE_SIZE 8
39 #define RoQ_AUDIO_SAMPLE_RATE 22050
40 #define RoQ_CHUNKS_TO_SCAN 30
41
42 #define RoQ_INFO 0x1001
43 #define RoQ_QUAD_CODEBOOK 0x1002
44 #define RoQ_QUAD_VQ 0x1011
45 #define RoQ_SOUND_MONO 0x1020
46 #define RoQ_SOUND_STEREO 0x1021
47
49
54
57
60
62
64 {
67 return 0;
68
70 }
71
73 {
77
78 /* get the main header */
83
84 /* init private context parameters */
89
91
92 return 0;
93 }
94
97 {
101 unsigned int chunk_size;
102 unsigned int chunk_type;
103 unsigned int codebook_size;
105 int packet_read = 0;
107
108 while (!packet_read) {
109
112
113 /* get the next chunk preamble */
117
118 chunk_type =
AV_RL16(&preamble[0]);
119 chunk_size =
AV_RL32(&preamble[2]);
120 if(chunk_size > INT_MAX)
122
124
125 switch (chunk_type) {
126
130 if (!st)
137
142 break;
143 }
144 /* don't care about this chunk anymore */
146 break;
147
151 /* packet needs to contain both this codebook and next VQ chunk */
153 codebook_size = chunk_size;
159 codebook_size;
160
161 if (chunk_size > INT_MAX)
163
164 /* rewind */
165 avio_seek(pb, codebook_offset, SEEK_SET);
166
167 /* load up the packet */
169 if (
ret != chunk_size)
173
174 packet_read = 1;
175 break;
176
181 if (!st)
190 } else {
192 }
199 }
204 }
205
206 /* load up the packet */
210 /* copy over preamble */
212
216 } else {
220 }
221
224 chunk_size);
225 if (
ret != chunk_size) {
227 }
228
229 packet_read = 1;
230 break;
231
232 default:
235 }
236 }
237
239 }
240
248 };