1 /*
2 * Silicon Graphics Movie demuxer
3 * Copyright (c) 2012 Peter Ross
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 * Silicon Graphics Movie demuxer
25 */
26
32
36
37 int eof_count;
/**< number of streams that have finished */
39 int frame[2];
/**< frame nb for current stream */
41
42 #define AUDIO_FORMAT_SIGNED 401
43
45 {
48 return 0;
49 }
50
52 {
55 if (!str)
56 return NULL;
58 if (n < size)
60 return str;
61 }
62
64 {
67 if (!s || sscanf(s, "%d", &v) != 1)
68 v = 0;
71 }
72
74 {
77 if (!s)
82 }
83
85 {
87 if (value)
89 }
90
92 if (channels <= 0) {
95 }
98 return 0;
99 }
100
101 /**
102 * Parse global variable
103 * @return < 0 if unknown
104 */
106 {
109 if (!strcmp(name, "__NUM_I_TRACKS")) {
111 } else if (!strcmp(name, "__NUM_A_TRACKS")) {
113 } else if (!strcmp(name, "COMMENT") || !strcmp(name, "TITLE")) {
115 } else if (!strcmp(name, "LOOP_MODE") || !strcmp(name, "NUM_LOOPS") || !strcmp(name, "OPTIMIZED")) {
117 } else
118 return -1;
119
120 return 0;
121 }
122
123 /**
124 * Parse audio variable
125 * @return < 0 if unknown
126 */
128 {
130 if (!strcmp(name, "__DIR_COUNT")) {
132 } else if (!strcmp(name, "AUDIO_FORMAT")) {
134 } else if (!strcmp(name, "COMPRESSION")) {
136 } else if (!strcmp(name, "DEFAULT_VOL")) {
138 } else if (!strcmp(name, "NUM_CHANNELS")) {
140 } else if (!strcmp(name, "SAMPLE_RATE")) {
143 } else if (!strcmp(name, "SAMPLE_WIDTH")) {
145 } else
146 return -1;
147 return 0;
148 }
149
150 /**
151 * Parse video variable
152 * @return < 0 if unknown
153 */
155 {
157 if (!strcmp(name, "__DIR_COUNT")) {
159 } else if (!strcmp(name, "COMPRESSION")) {
161 if (!str)
163 if (!strcmp(str, "1")) {
165 } else if (!strcmp(str, "2")) {
168 } else if (!strcmp(str, "3")) {
170 } else if (!strcmp(str, "10")) {
172 } else if (!strcmp(str, "MVC2")) {
174 } else {
176 }
178 } else if (!strcmp(name, "FPS")) {
181 } else if (!strcmp(name, "HEIGHT")) {
183 } else if (!strcmp(name, "PIXEL_ASPECT")) {
187 } else if (!strcmp(name, "WIDTH")) {
189 } else if (!strcmp(name, "ORIENTATION")) {
193 }
194 } else if (!strcmp(name, "Q_SPATIAL") || !strcmp(name, "Q_TEMPORAL")) {
196 } else if (!strcmp(name, "INTERLACING") || !strcmp(name, "PACKING")) {
198 } else
199 return -1;
200 return 0;
201 }
202
204 {
210 for (i = 0; i <
count; i++) {
211 char name[17];
214 name[
sizeof(
name) - 1] = 0;
216 if (
parse(avctx, st, name, size) < 0) {
219 }
220 }
221 }
222
224 {
225 uint64_t timestamp = 0;
226 int i;
234 } else {
235 timestamp++;
236 }
237 }
238 }
239
241 {
244 AVStream *ast = NULL, *vst = NULL;
//initialization to suppress warning
246
248
250 if (version == 2) {
251 uint64_t timestamp;
254
255 /* allocate audio track first to prevent unnecessary seeking
256 (audio packet always precede video packet for a given frame) */
258 if (!ast)
260
262 if (!vst)
268 switch (v) {
269 case 1:
271 break;
272 case 2:
275 break;
276 default:
278 break;
279 }
280 vst->codec->codec_tag = 0;
284
291
295 } else {
297 }
298
303
304 timestamp = 0;
305 for (i = 0; i < vst->nb_frames; i++) {
313 }
314 }
else if (!version &&
avio_rb16(pb) == 3) {
316
318
324 if (!ast)
327 /* temporarily store compression value in codec_tag; format value in codec_id */
331 } else {
335 }
340 }
341 }
342
348 if (!vst)
352 }
353
356
359 } else {
362 }
363
364 return 0;
365 }
366
368 {
375 uint64_t pos;
376
377 if (frame < st->nb_index_entries) {
380 if (index->
pos > pos)
382 else if (index->
pos < pos) {
386 if (ret < 0)
388 }
390 if (ret < 0)
392
396
399 } else {
403 }
404
408
409 return 0;
410 }
411
413 {
417
420
423
425 if (frame < 0)
426 return -1;
427
429 mv->
frame[i] = frame;
430 return 0;
431 }
432
441 };