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
35
36 #define RoQ_MAGIC_NUMBER 0x1084
37 #define RoQ_CHUNK_PREAMBLE_SIZE 8
38 #define RoQ_AUDIO_SAMPLE_RATE 22050
39 #define RoQ_CHUNKS_TO_SCAN 30
40
41 #define RoQ_INFO 0x1001
42 #define RoQ_QUAD_CODEBOOK 0x1002
43 #define RoQ_QUAD_VQ 0x1011
44 #define RoQ_SOUND_MONO 0x1020
45 #define RoQ_SOUND_STEREO 0x1021
46
48
53
56
59
61
63 {
66 return 0;
67
69 }
70
72 {
76
77 /* get the main header */
82
83 /* init private context parameters */
88
90
91 return 0;
92 }
93
96 {
100 unsigned int chunk_size;
101 unsigned int chunk_type;
102 unsigned int codebook_size;
104 int packet_read = 0;
105 int64_t codebook_offset;
106
107 while (!packet_read) {
108
111
112 /* get the next chunk preamble */
116
117 chunk_type =
AV_RL16(&preamble[0]);
118 chunk_size =
AV_RL32(&preamble[2]);
119 if(chunk_size > INT_MAX)
121
123
124 switch (chunk_type) {
125
129 if (!st)
136
141 break;
142 }
143 /* don't care about this chunk anymore */
145 break;
146
150 /* packet needs to contain both this codebook and next VQ chunk */
152 codebook_size = chunk_size;
158 codebook_size;
159
160 if (chunk_size > INT_MAX)
162
163 /* rewind */
164 avio_seek(pb, codebook_offset, SEEK_SET);
165
166 /* load up the packet */
168 if (
ret != chunk_size)
172
173 packet_read = 1;
174 break;
175
180 if (!st)
189 } else {
191 }
198 }
203 }
204
205 /* load up the packet */
209 /* copy over preamble */
211
215 } else {
219 }
220
223 chunk_size);
224 if (
ret != chunk_size) {
226 }
227
228 packet_read = 1;
229 break;
230
231 default:
234 }
235 }
236
238 }
239
247 };