FFmpeg: libavformat/bink.c Source File
Go to the documentation of this file. 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
31 #include <inttypes.h>
32
38
43 };
44
45 #define BINK_EXTRADATA_SIZE 1
46 #define BINK_MAX_AUDIO_TRACKS 256
47 #define BINK_MAX_WIDTH 7680
48 #define BINK_MAX_HEIGHT 4800
49 #define SMUSH_BLOCK_SIZE 512
50
53
58
63
65 {
66 const uint8_t *
b = p->
buf;
68
69 do {
70 if (((
b[0] ==
'B' &&
b[1] ==
'I' &&
b[2] ==
'K' &&
/* Bink 1 */
71 (
b[3] ==
'b' ||
b[3] ==
'f' ||
b[3] ==
'g' ||
b[3] ==
'h' ||
b[3] ==
'i' ||
73 (
b[0] ==
'K' &&
b[1] ==
'B' &&
b[2] ==
'2' &&
/* Bink 2 */
74 (
b[3] ==
'a' ||
b[3] ==
'd' ||
b[3] ==
'f' ||
b[3] ==
'g' ||
b[3] ==
'h' ||
75 b[3] ==
'i' ||
b[3] ==
'j' ||
b[3] ==
'k'))) &&
82 }
while (smush && b < p->buf + p->
buf_size - 32);
83 return 0;
84 }
85
87 {
90 uint32_t fps_num, fps_den;
94 uint32_t
pos, next_pos;
96 int next_keyframe = 1;
97 int keyframe;
100 uint8_t revision;
101
102 if (!vst)
104
107 do {
115 }
116 }
117
120
124 }
125
128 "invalid header: largest frame size greater than file size\n");
130 }
131
133
136
139 if (fps_num == 0 || fps_den == 0) {
141 "invalid header: invalid fps (%"PRIu32"/%"PRIu32")\n",
142 fps_num, fps_den);
144 }
147
150
154 }
155
158
160
166 }
167
170
172 (
signature ==
AV_RL32(
"KB2") && (revision ==
'i' || revision ==
'j' || revision ==
'k')))
173 avio_skip(pb, 4);
/* unknown new field */
174
177
180 if (!ast)
191 } else {
193 }
197 }
198
201 }
202
203 /* frame index table */
207 keyframe = next_keyframe;
210 next_keyframe = 0;
211 } else {
213 next_keyframe = next_pos & 1;
214 }
216 next_pos &= ~1;
217
218 if (next_pos <=
pos) {
221 }
225 }
226
229 else
231
233 return 0;
234 }
235
237 {
241
243 int index_entry;
244 AVStream *st =
s->streams[0];
// stream 0 is video stream with index
246
249
252 if (index_entry < 0) {
254 "could not find index entry for frame %"PRId64"\n",
257 }
258
262 }
263
268 "frame %"PRId64": audio size in header (%"PRIu32") > size of packet left (%"PRIu32")\n",
271 }
274 if (audio_size >= 4) {
275 /* get one audio packet per track */
280
281 /* Each audio packet reports the number of decompressed samples
282 (in bytes). We use this value to calculate the audio PTS */
286 return 0;
287 } else {
289 }
290 }
291
292 /* get video packet */
299
300 /* -1 instructs the next call to read_packet() to read the next frame */
302
303 return 0;
304 }
305
307 {
312
314 return -1;
315
316 /* seek to the first frame */
320
324 return 0;
325 }
326
336 };
#define AV_LOG_WARNING
Something somehow does not look correct.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
#define AV_CHANNEL_LAYOUT_STEREO
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
AVRational avg_frame_rate
Average framerate.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
int buf_size
Size of buf except extra allocated bytes.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int current_track
audio track to return in next packet
int ff_get_extradata(void *logctx, AVCodecParameters *par, AVIOContext *pb, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0 and f...
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
uint32_t num_audio_tracks
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rl16(AVIOContext *s)
static const char signature[]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
@ AV_CODEC_ID_BINKAUDIO_DCT
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
This structure contains the data a format has to probe a file.
AVChannelLayout ch_layout
Audio only.
int sample_rate
Audio only.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
int flags
A combination of AV_PKT_FLAG values.
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int64_t audio_pts[BINK_MAX_AUDIO_TRACKS]
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
uint32_t remain_packet_size
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
static int read_probe(const AVProbeData *p)
#define AV_CHANNEL_LAYOUT_MONO
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
@ AV_CODEC_ID_BINKAUDIO_RDFT
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Generated on Thu Sep 26 2024 23:14:50 for FFmpeg by
doxygen
1.8.17