annotate bink.c @ 5700:982edb9135ca libavformat

Cosmetics: reindent
author mstorsjo
date Tue, 23 Feb 2010 11:05:36 +0000
parents 2ace2ee84929
children 8a605bb5cee4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5614
d76904a638df Bink demuxer
pross
parents:
diff changeset
1 /*
d76904a638df Bink demuxer
pross
parents:
diff changeset
2 * Bink demuxer
d76904a638df Bink demuxer
pross
parents:
diff changeset
3 * Copyright (c) 2008-2010 Peter Ross (pross@xvid.org)
d76904a638df Bink demuxer
pross
parents:
diff changeset
4 * Copyright (c) 2009 Daniel Verkamp (daniel@drv.nu)
d76904a638df Bink demuxer
pross
parents:
diff changeset
5 *
d76904a638df Bink demuxer
pross
parents:
diff changeset
6 * This file is part of FFmpeg.
d76904a638df Bink demuxer
pross
parents:
diff changeset
7 *
d76904a638df Bink demuxer
pross
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
d76904a638df Bink demuxer
pross
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
d76904a638df Bink demuxer
pross
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
d76904a638df Bink demuxer
pross
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
d76904a638df Bink demuxer
pross
parents:
diff changeset
12 *
d76904a638df Bink demuxer
pross
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
d76904a638df Bink demuxer
pross
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d76904a638df Bink demuxer
pross
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d76904a638df Bink demuxer
pross
parents:
diff changeset
16 * Lesser General Public License for more details.
d76904a638df Bink demuxer
pross
parents:
diff changeset
17 *
d76904a638df Bink demuxer
pross
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
d76904a638df Bink demuxer
pross
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
d76904a638df Bink demuxer
pross
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
d76904a638df Bink demuxer
pross
parents:
diff changeset
21 */
d76904a638df Bink demuxer
pross
parents:
diff changeset
22
d76904a638df Bink demuxer
pross
parents:
diff changeset
23 /**
d76904a638df Bink demuxer
pross
parents:
diff changeset
24 * @file libavformat/bink.c
d76904a638df Bink demuxer
pross
parents:
diff changeset
25 * Bink demuxer
d76904a638df Bink demuxer
pross
parents:
diff changeset
26 *
d76904a638df Bink demuxer
pross
parents:
diff changeset
27 * Technical details here:
d76904a638df Bink demuxer
pross
parents:
diff changeset
28 * http://wiki.multimedia.cx/index.php?title=Bink_Container
d76904a638df Bink demuxer
pross
parents:
diff changeset
29 */
d76904a638df Bink demuxer
pross
parents:
diff changeset
30
d76904a638df Bink demuxer
pross
parents:
diff changeset
31 #include "libavutil/intreadwrite.h"
d76904a638df Bink demuxer
pross
parents:
diff changeset
32 #include "avformat.h"
d76904a638df Bink demuxer
pross
parents:
diff changeset
33
d76904a638df Bink demuxer
pross
parents:
diff changeset
34 enum BinkAudFlags {
d76904a638df Bink demuxer
pross
parents:
diff changeset
35 BINK_AUD_16BITS = 0x4000, ///< prefer 16-bit output
d76904a638df Bink demuxer
pross
parents:
diff changeset
36 BINK_AUD_STEREO = 0x2000,
d76904a638df Bink demuxer
pross
parents:
diff changeset
37 BINK_AUD_USEDCT = 0x1000,
d76904a638df Bink demuxer
pross
parents:
diff changeset
38 };
d76904a638df Bink demuxer
pross
parents:
diff changeset
39
d76904a638df Bink demuxer
pross
parents:
diff changeset
40 #define BINK_EXTRADATA_SIZE 1
d76904a638df Bink demuxer
pross
parents:
diff changeset
41 #define BINK_MAX_AUDIO_TRACKS 256
d76904a638df Bink demuxer
pross
parents:
diff changeset
42 #define BINK_MAX_WIDTH 7680
d76904a638df Bink demuxer
pross
parents:
diff changeset
43 #define BINK_MAX_HEIGHT 4800
d76904a638df Bink demuxer
pross
parents:
diff changeset
44
d76904a638df Bink demuxer
pross
parents:
diff changeset
45 typedef struct {
d76904a638df Bink demuxer
pross
parents:
diff changeset
46 uint32_t file_size;
d76904a638df Bink demuxer
pross
parents:
diff changeset
47 uint32_t total_frames;
d76904a638df Bink demuxer
pross
parents:
diff changeset
48
d76904a638df Bink demuxer
pross
parents:
diff changeset
49 uint32_t num_audio_tracks;
d76904a638df Bink demuxer
pross
parents:
diff changeset
50 int current_track; ///< audio track to return in next packet
d76904a638df Bink demuxer
pross
parents:
diff changeset
51 int64_t video_pts;
d76904a638df Bink demuxer
pross
parents:
diff changeset
52 int64_t audio_pts[BINK_MAX_AUDIO_TRACKS];
d76904a638df Bink demuxer
pross
parents:
diff changeset
53
d76904a638df Bink demuxer
pross
parents:
diff changeset
54 uint32_t remain_packet_size;
d76904a638df Bink demuxer
pross
parents:
diff changeset
55 } BinkDemuxContext;
d76904a638df Bink demuxer
pross
parents:
diff changeset
56
d76904a638df Bink demuxer
pross
parents:
diff changeset
57 static int probe(AVProbeData *p)
d76904a638df Bink demuxer
pross
parents:
diff changeset
58 {
d76904a638df Bink demuxer
pross
parents:
diff changeset
59 const uint8_t *b = p->buf;
d76904a638df Bink demuxer
pross
parents:
diff changeset
60
d76904a638df Bink demuxer
pross
parents:
diff changeset
61 if ( b[0] == 'B' && b[1] == 'I' && b[2] == 'K' &&
d76904a638df Bink demuxer
pross
parents:
diff changeset
62 (b[3] == 'b' || b[3] == 'f' || b[3] == 'g' || b[3] == 'h' || b[3] == 'i') &&
d76904a638df Bink demuxer
pross
parents:
diff changeset
63 AV_RL32(b+8) > 0 && // num_frames
d76904a638df Bink demuxer
pross
parents:
diff changeset
64 AV_RL32(b+20) > 0 && AV_RL32(b+20) <= BINK_MAX_WIDTH &&
d76904a638df Bink demuxer
pross
parents:
diff changeset
65 AV_RL32(b+24) > 0 && AV_RL32(b+24) <= BINK_MAX_HEIGHT &&
d76904a638df Bink demuxer
pross
parents:
diff changeset
66 AV_RL32(b+28) > 0 && AV_RL32(b+32) > 0) // fps num,den
d76904a638df Bink demuxer
pross
parents:
diff changeset
67 return AVPROBE_SCORE_MAX;
d76904a638df Bink demuxer
pross
parents:
diff changeset
68 return 0;
d76904a638df Bink demuxer
pross
parents:
diff changeset
69 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
70
d76904a638df Bink demuxer
pross
parents:
diff changeset
71 static int read_header(AVFormatContext *s, AVFormatParameters *ap)
d76904a638df Bink demuxer
pross
parents:
diff changeset
72 {
d76904a638df Bink demuxer
pross
parents:
diff changeset
73 BinkDemuxContext *bink = s->priv_data;
d76904a638df Bink demuxer
pross
parents:
diff changeset
74 ByteIOContext *pb = s->pb;
d76904a638df Bink demuxer
pross
parents:
diff changeset
75 uint32_t fps_num, fps_den;
d76904a638df Bink demuxer
pross
parents:
diff changeset
76 AVStream *vst, *ast;
d76904a638df Bink demuxer
pross
parents:
diff changeset
77 unsigned int i;
d76904a638df Bink demuxer
pross
parents:
diff changeset
78 uint32_t pos, prev_pos;
d76904a638df Bink demuxer
pross
parents:
diff changeset
79 uint16_t flags;
d76904a638df Bink demuxer
pross
parents:
diff changeset
80 int keyframe;
d76904a638df Bink demuxer
pross
parents:
diff changeset
81
d76904a638df Bink demuxer
pross
parents:
diff changeset
82 vst = av_new_stream(s, 0);
d76904a638df Bink demuxer
pross
parents:
diff changeset
83 if (!vst)
d76904a638df Bink demuxer
pross
parents:
diff changeset
84 return AVERROR(ENOMEM);
d76904a638df Bink demuxer
pross
parents:
diff changeset
85
d76904a638df Bink demuxer
pross
parents:
diff changeset
86 vst->codec->codec_tag = get_le32(pb);
d76904a638df Bink demuxer
pross
parents:
diff changeset
87
d76904a638df Bink demuxer
pross
parents:
diff changeset
88 bink->file_size = get_le32(pb) + 8;
d76904a638df Bink demuxer
pross
parents:
diff changeset
89 bink->total_frames = get_le32(pb);
d76904a638df Bink demuxer
pross
parents:
diff changeset
90
d76904a638df Bink demuxer
pross
parents:
diff changeset
91 if (bink->total_frames > 1000000) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
92 av_log(s, AV_LOG_ERROR, "invalid header: more than 1000000 frames\n");
d76904a638df Bink demuxer
pross
parents:
diff changeset
93 return AVERROR(EIO);
d76904a638df Bink demuxer
pross
parents:
diff changeset
94 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
95
d76904a638df Bink demuxer
pross
parents:
diff changeset
96 if (get_le32(pb) > bink->file_size) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
97 av_log(s, AV_LOG_ERROR,
d76904a638df Bink demuxer
pross
parents:
diff changeset
98 "invalid header: largest frame size greater than file size\n");
d76904a638df Bink demuxer
pross
parents:
diff changeset
99 return AVERROR(EIO);
d76904a638df Bink demuxer
pross
parents:
diff changeset
100 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
101
d76904a638df Bink demuxer
pross
parents:
diff changeset
102 url_fskip(pb, 4);
d76904a638df Bink demuxer
pross
parents:
diff changeset
103
d76904a638df Bink demuxer
pross
parents:
diff changeset
104 vst->codec->width = get_le32(pb);
d76904a638df Bink demuxer
pross
parents:
diff changeset
105 vst->codec->height = get_le32(pb);
d76904a638df Bink demuxer
pross
parents:
diff changeset
106
d76904a638df Bink demuxer
pross
parents:
diff changeset
107 fps_num = get_le32(pb);
d76904a638df Bink demuxer
pross
parents:
diff changeset
108 fps_den = get_le32(pb);
d76904a638df Bink demuxer
pross
parents:
diff changeset
109 if (fps_num == 0 || fps_den == 0) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
110 av_log(s, AV_LOG_ERROR, "invalid header: invalid fps (%d/%d)\n", fps_num, fps_den);
d76904a638df Bink demuxer
pross
parents:
diff changeset
111 return AVERROR(EIO);
d76904a638df Bink demuxer
pross
parents:
diff changeset
112 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
113 av_set_pts_info(vst, 64, fps_den, fps_num);
d76904a638df Bink demuxer
pross
parents:
diff changeset
114
d76904a638df Bink demuxer
pross
parents:
diff changeset
115 vst->codec->codec_type = CODEC_TYPE_VIDEO;
5616
9a624037cf06 Bink video codec id is there, demuxer can use it
kostya
parents: 5614
diff changeset
116 vst->codec->codec_id = CODEC_ID_BINKVIDEO;
5698
92fa6b12dc40 Make Bink demuxer pass video flags to decoder
kostya
parents: 5675
diff changeset
117 vst->codec->extradata = av_mallocz(4 + FF_INPUT_BUFFER_PADDING_SIZE);
92fa6b12dc40 Make Bink demuxer pass video flags to decoder
kostya
parents: 5675
diff changeset
118 vst->codec->extradata_size = 4;
92fa6b12dc40 Make Bink demuxer pass video flags to decoder
kostya
parents: 5675
diff changeset
119 get_buffer(pb, vst->codec->extradata, 4);
92fa6b12dc40 Make Bink demuxer pass video flags to decoder
kostya
parents: 5675
diff changeset
120
5614
d76904a638df Bink demuxer
pross
parents:
diff changeset
121 bink->num_audio_tracks = get_le32(pb);
d76904a638df Bink demuxer
pross
parents:
diff changeset
122
d76904a638df Bink demuxer
pross
parents:
diff changeset
123 if (bink->num_audio_tracks > BINK_MAX_AUDIO_TRACKS) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
124 av_log(s, AV_LOG_ERROR,
d76904a638df Bink demuxer
pross
parents:
diff changeset
125 "invalid header: more than "AV_STRINGIFY(BINK_MAX_AUDIO_TRACKS)" audio tracks (%d)\n",
d76904a638df Bink demuxer
pross
parents:
diff changeset
126 bink->num_audio_tracks);
d76904a638df Bink demuxer
pross
parents:
diff changeset
127 return AVERROR(EIO);
d76904a638df Bink demuxer
pross
parents:
diff changeset
128 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
129
d76904a638df Bink demuxer
pross
parents:
diff changeset
130 if (bink->num_audio_tracks) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
131 url_fskip(pb, 4 * bink->num_audio_tracks);
d76904a638df Bink demuxer
pross
parents:
diff changeset
132
d76904a638df Bink demuxer
pross
parents:
diff changeset
133 for (i = 0; i < bink->num_audio_tracks; i++) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
134 ast = av_new_stream(s, 1);
d76904a638df Bink demuxer
pross
parents:
diff changeset
135 if (!ast)
d76904a638df Bink demuxer
pross
parents:
diff changeset
136 return AVERROR(ENOMEM);
d76904a638df Bink demuxer
pross
parents:
diff changeset
137 ast->codec->codec_type = CODEC_TYPE_AUDIO;
d76904a638df Bink demuxer
pross
parents:
diff changeset
138 ast->codec->codec_tag = 0;
d76904a638df Bink demuxer
pross
parents:
diff changeset
139 ast->codec->sample_rate = get_le16(pb);
d76904a638df Bink demuxer
pross
parents:
diff changeset
140 av_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
d76904a638df Bink demuxer
pross
parents:
diff changeset
141 flags = get_le16(pb);
d76904a638df Bink demuxer
pross
parents:
diff changeset
142 ast->codec->codec_id = flags & BINK_AUD_USEDCT ?
d76904a638df Bink demuxer
pross
parents:
diff changeset
143 CODEC_ID_BINKAUDIO_DCT : CODEC_ID_BINKAUDIO_RDFT;
d76904a638df Bink demuxer
pross
parents:
diff changeset
144 ast->codec->channels = flags & BINK_AUD_STEREO ? 2 : 1;
d76904a638df Bink demuxer
pross
parents:
diff changeset
145 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
146
d76904a638df Bink demuxer
pross
parents:
diff changeset
147 url_fskip(pb, 4 * bink->num_audio_tracks);
d76904a638df Bink demuxer
pross
parents:
diff changeset
148 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
149
d76904a638df Bink demuxer
pross
parents:
diff changeset
150 /* frame index table */
d76904a638df Bink demuxer
pross
parents:
diff changeset
151 pos = get_le32(pb) & ~1;
d76904a638df Bink demuxer
pross
parents:
diff changeset
152 for (i = 0; i < bink->total_frames; i++) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
153 prev_pos = pos;
d76904a638df Bink demuxer
pross
parents:
diff changeset
154 if (i == bink->total_frames - 1) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
155 pos = bink->file_size;
d76904a638df Bink demuxer
pross
parents:
diff changeset
156 keyframe = 0;
d76904a638df Bink demuxer
pross
parents:
diff changeset
157 } else {
d76904a638df Bink demuxer
pross
parents:
diff changeset
158 pos = get_le32(pb);
d76904a638df Bink demuxer
pross
parents:
diff changeset
159 keyframe = pos & 1;
d76904a638df Bink demuxer
pross
parents:
diff changeset
160 pos &= ~1;
d76904a638df Bink demuxer
pross
parents:
diff changeset
161 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
162 if (pos <= prev_pos) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
163 av_log(s, AV_LOG_ERROR, "invalid frame index table\n");
d76904a638df Bink demuxer
pross
parents:
diff changeset
164 return AVERROR(EIO);
d76904a638df Bink demuxer
pross
parents:
diff changeset
165 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
166 av_add_index_entry(vst, pos, i, pos - prev_pos, 0,
d76904a638df Bink demuxer
pross
parents:
diff changeset
167 keyframe ? AVINDEX_KEYFRAME : 0);
d76904a638df Bink demuxer
pross
parents:
diff changeset
168 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
169
d76904a638df Bink demuxer
pross
parents:
diff changeset
170 url_fskip(pb, 4);
d76904a638df Bink demuxer
pross
parents:
diff changeset
171
d76904a638df Bink demuxer
pross
parents:
diff changeset
172 bink->current_track = -1;
d76904a638df Bink demuxer
pross
parents:
diff changeset
173 return 0;
d76904a638df Bink demuxer
pross
parents:
diff changeset
174 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
175
d76904a638df Bink demuxer
pross
parents:
diff changeset
176 static int read_packet(AVFormatContext *s, AVPacket *pkt)
d76904a638df Bink demuxer
pross
parents:
diff changeset
177 {
d76904a638df Bink demuxer
pross
parents:
diff changeset
178 BinkDemuxContext *bink = s->priv_data;
d76904a638df Bink demuxer
pross
parents:
diff changeset
179 ByteIOContext *pb = s->pb;
d76904a638df Bink demuxer
pross
parents:
diff changeset
180 int ret;
d76904a638df Bink demuxer
pross
parents:
diff changeset
181
d76904a638df Bink demuxer
pross
parents:
diff changeset
182 if (bink->current_track < 0) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
183 int index_entry;
d76904a638df Bink demuxer
pross
parents:
diff changeset
184 AVStream *st = s->streams[0]; // stream 0 is video stream with index
d76904a638df Bink demuxer
pross
parents:
diff changeset
185
d76904a638df Bink demuxer
pross
parents:
diff changeset
186 if (bink->video_pts >= bink->total_frames)
d76904a638df Bink demuxer
pross
parents:
diff changeset
187 return AVERROR(EIO);
d76904a638df Bink demuxer
pross
parents:
diff changeset
188
d76904a638df Bink demuxer
pross
parents:
diff changeset
189 index_entry = av_index_search_timestamp(st, bink->video_pts,
d76904a638df Bink demuxer
pross
parents:
diff changeset
190 AVSEEK_FLAG_ANY);
d76904a638df Bink demuxer
pross
parents:
diff changeset
191 if (index_entry < 0) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
192 av_log(s, AV_LOG_ERROR,
d76904a638df Bink demuxer
pross
parents:
diff changeset
193 "could not find index entry for frame %"PRId64"\n",
d76904a638df Bink demuxer
pross
parents:
diff changeset
194 bink->video_pts);
d76904a638df Bink demuxer
pross
parents:
diff changeset
195 return AVERROR(EIO);
d76904a638df Bink demuxer
pross
parents:
diff changeset
196 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
197
d76904a638df Bink demuxer
pross
parents:
diff changeset
198 bink->remain_packet_size = st->index_entries[index_entry].size;
d76904a638df Bink demuxer
pross
parents:
diff changeset
199 bink->current_track = 0;
d76904a638df Bink demuxer
pross
parents:
diff changeset
200 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
201
5675
bbbedc311b93 Make Bink demuxer skip all zero audio tracks, not only the first one
kostya
parents: 5616
diff changeset
202 while (bink->current_track < bink->num_audio_tracks) {
5614
d76904a638df Bink demuxer
pross
parents:
diff changeset
203 uint32_t audio_size = get_le32(pb);
d76904a638df Bink demuxer
pross
parents:
diff changeset
204 if (audio_size > bink->remain_packet_size - 4) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
205 av_log(s, AV_LOG_ERROR,
d76904a638df Bink demuxer
pross
parents:
diff changeset
206 "frame %"PRId64": audio size in header (%u) > size of packet left (%u)\n",
d76904a638df Bink demuxer
pross
parents:
diff changeset
207 bink->video_pts, audio_size, bink->remain_packet_size);
d76904a638df Bink demuxer
pross
parents:
diff changeset
208 return AVERROR(EIO);
d76904a638df Bink demuxer
pross
parents:
diff changeset
209 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
210 bink->remain_packet_size -= 4 + audio_size;
d76904a638df Bink demuxer
pross
parents:
diff changeset
211 bink->current_track++;
d76904a638df Bink demuxer
pross
parents:
diff changeset
212 if (audio_size > 0) {
d76904a638df Bink demuxer
pross
parents:
diff changeset
213 /* Each audio packet reports the number of decompressed samples
d76904a638df Bink demuxer
pross
parents:
diff changeset
214 (in bytes). We use this value to calcuate the audio PTS */
d76904a638df Bink demuxer
pross
parents:
diff changeset
215 int reported_size = get_le32(pb) / (2 * s->streams[bink->current_track]->codec->channels);
d76904a638df Bink demuxer
pross
parents:
diff changeset
216 url_fseek(pb, -4, SEEK_CUR);
d76904a638df Bink demuxer
pross
parents:
diff changeset
217
d76904a638df Bink demuxer
pross
parents:
diff changeset
218 /* get one audio packet per track */
d76904a638df Bink demuxer
pross
parents:
diff changeset
219 if ((ret = av_get_packet(pb, pkt, audio_size))
d76904a638df Bink demuxer
pross
parents:
diff changeset
220 != audio_size)
d76904a638df Bink demuxer
pross
parents:
diff changeset
221 return ret;
d76904a638df Bink demuxer
pross
parents:
diff changeset
222 pkt->stream_index = bink->current_track;
5699
2ace2ee84929 Bink audio pts starts at 0, not reported_size
pross
parents: 5698
diff changeset
223 pkt->pts = bink->audio_pts[bink->current_track - 1];
2ace2ee84929 Bink audio pts starts at 0, not reported_size
pross
parents: 5698
diff changeset
224 bink->audio_pts[bink->current_track -1] += reported_size;
5614
d76904a638df Bink demuxer
pross
parents:
diff changeset
225 return 0;
d76904a638df Bink demuxer
pross
parents:
diff changeset
226 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
227 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
228
d76904a638df Bink demuxer
pross
parents:
diff changeset
229 /* get video packet */
d76904a638df Bink demuxer
pross
parents:
diff changeset
230 if ((ret = av_get_packet(pb, pkt, bink->remain_packet_size))
d76904a638df Bink demuxer
pross
parents:
diff changeset
231 != bink->remain_packet_size)
d76904a638df Bink demuxer
pross
parents:
diff changeset
232 return ret;
d76904a638df Bink demuxer
pross
parents:
diff changeset
233 pkt->stream_index = 0;
d76904a638df Bink demuxer
pross
parents:
diff changeset
234 pkt->pts = bink->video_pts++;
d76904a638df Bink demuxer
pross
parents:
diff changeset
235 pkt->flags |= PKT_FLAG_KEY;
d76904a638df Bink demuxer
pross
parents:
diff changeset
236
d76904a638df Bink demuxer
pross
parents:
diff changeset
237 /* -1 instructs the next call to read_packet() to read the next frame */
d76904a638df Bink demuxer
pross
parents:
diff changeset
238 bink->current_track = -1;
d76904a638df Bink demuxer
pross
parents:
diff changeset
239
d76904a638df Bink demuxer
pross
parents:
diff changeset
240 return 0;
d76904a638df Bink demuxer
pross
parents:
diff changeset
241 }
d76904a638df Bink demuxer
pross
parents:
diff changeset
242
d76904a638df Bink demuxer
pross
parents:
diff changeset
243 AVInputFormat bink_demuxer = {
d76904a638df Bink demuxer
pross
parents:
diff changeset
244 "bink",
d76904a638df Bink demuxer
pross
parents:
diff changeset
245 NULL_IF_CONFIG_SMALL("Bink"),
d76904a638df Bink demuxer
pross
parents:
diff changeset
246 sizeof(BinkDemuxContext),
d76904a638df Bink demuxer
pross
parents:
diff changeset
247 probe,
d76904a638df Bink demuxer
pross
parents:
diff changeset
248 read_header,
d76904a638df Bink demuxer
pross
parents:
diff changeset
249 read_packet,
d76904a638df Bink demuxer
pross
parents:
diff changeset
250 };