1 /*
2 * Bink demuxer
3 * Copyright (c) 2008-2010 Peter Ross (pross@xvid.org)
4 * Copyright (c) 2009 Daniel Verkamp (daniel@drv.nu)
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * @file
25 * Bink demuxer
26 *
27 * Technical details here:
28 * http://wiki.multimedia.cx/index.php?title=Bink_Container
29 */
30
35
40 };
41
42 #define BINK_EXTRADATA_SIZE 1
43 #define BINK_MAX_AUDIO_TRACKS 256
44 #define BINK_MAX_WIDTH 7680
45 #define BINK_MAX_HEIGHT 4800
46
49
54
57
59 {
61
62 if ( b[0] == 'B' && b[1] == 'I' && b[2] == 'K' &&
63 (b[3] == 'b' || b[3] == 'f' || b[3] == 'g' || b[3] == 'h' || b[3] == 'i') &&
64 AV_RL32(b+8) > 0 &&
// num_frames
69 return 0;
70 }
71
73 {
76 uint32_t fps_num, fps_den;
78 unsigned int i;
79 uint32_t pos, next_pos;
81 int keyframe;
82
84 if (!vst)
86
88
91
95 }
96
99 "invalid header: largest frame size greater than file size\n");
101 }
102
104
107
110 if (fps_num == 0 || fps_den == 0) {
113 }
116
122
124
130 }
131
134
137 if (!ast)
149 } else {
152 }
156 }
157
160 }
161
162 /* frame index table */
164 for (i = 0; i < vst->
duration; i++) {
165 pos = next_pos;
168 keyframe = 0;
169 } else {
171 keyframe = pos & 1;
172 }
173 pos &= ~1;
174 next_pos &= ~1;
175
176 if (next_pos <= pos) {
179 }
182 }
183
185
187 return 0;
188 }
189
191 {
195
197 int index_entry;
199
202
205 if (index_entry < 0) {
207 "could not find index entry for frame %"PRId64"\n",
210 }
211
214 }
215
220 "frame %"PRId64": audio size in header (%u) > size of packet left (%u)\n",
223 }
226 if (audio_size >= 4) {
227 /* get one audio packet per track */
232
233 /* Each audio packet reports the number of decompressed samples
234 (in bytes). We use this value to calcuate the audio PTS */
238 return 0;
239 } else {
241 }
242 }
243
244 /* get video packet */
250
251 /* -1 instructs the next call to read_packet() to read the next frame */
253
254 return 0;
255 }
256
258 {
261
263 return -1;
264
265 /* seek to the first frame */
267 return -1;
268
272 return 0;
273 }
274
283 };