1 /*
2 * R3D REDCODE demuxer
3 * Copyright (c) 2008 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
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
27
32
35
41
43 {
47 return -1;
52 }
53
55 {
58 char filename[258];
62
63 if (!st)
67
71
74
77
80
82
85
88
91 if (framerate.
num > 0 && framerate.
den > 0) {
92 #if FF_API_R_FRAME_RATE
94 #endif
96 }
97
100
102 filename[sizeof(filename)-1] = 0;
104
109 framerate.
num, framerate.
den);
110
111 return 0;
112 }
113
115 {
118 int i;
119
124
129 break;
130 }
132 }
133
139
140 return 0;
141 }
142
144 {
147
152
155
158
160 }
161
163 {
166 int ret;
167
170 return -1;
171 }
172 if (atom.
tag ==
MKTAG(
'R',
'E',
'D',
'1')) {
175 return ret;
176 }
177 } else {
179 return -1;
180 }
181
182 /* we cannot create the audio stream now because we do not know the
183 * sample rate */
186
190 return 0;
191 // find REOB/REOF/REOS to load index
195
196 if (atom.
tag !=
MKTAG(
'R',
'E',
'O',
'B') &&
197 atom.
tag !=
MKTAG(
'R',
'E',
'O',
'F') &&
200
202
207 if (atom.
tag ==
MKTAG(
'R',
'D',
'V',
'O')) {
210 }
211 }
212
215 return 0;
216 }
217
219 {
224 unsigned dts;
225 int ret;
226
228
231
235
238
239 if (tmp > 4) {
242
245
250
253 }
255 if (tmp < 0)
256 return -1;
258 if (ret < 0) {
260 return -1;
261 }
262
269
270 return 0;
271 }
272
274 {
280 unsigned dts;
281 int ret;
282
285 if (!st)
291 } else {
293 }
294
296
301 }
302
304
307
310
314
317
319 if (size < 0)
320 return -1;
322 if (ret < 0) {
324 return ret;
325 }
326
331 av_log(s,
AV_LOG_TRACE,
"pkt dts %"PRId64
" duration %"PRId64
" samples %d sample rate %d\n",
333
334 return 0;
335 }
336
338 {
341 int err = 0;
342
343 while (!err) {
345 err = -1;
346 break;
347 }
349 case MKTAG(
'R',
'E',
'D',
'V'):
351 goto skip;
353 return 0;
354 break;
355 case MKTAG(
'R',
'E',
'D',
'A'):
357 return -1;
359 goto skip;
361 return 0;
362 break;
363 default:
364 skip:
366 }
367 }
368 return err;
369 }
370
372 {
375 return 0;
376 }
377
379 {
382 int frame_num;
383
385 return -1;
386
390 frame_num, sample_time);
391
392 if (frame_num < r3d->video_offsets_count) {
394 return -1;
395 } else {
397 return -1;
398 }
399
400 return 0;
401 }
402
404 {
406
408
409 return 0;
410 }
411
421 };
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
unsigned video_offsets_count
static int read_atom(AVFormatContext *s, Atom *atom)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static int r3d_close(AVFormatContext *s)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
unsigned int avio_rb16(AVIOContext *s)
int ctx_flags
Flags signalling stream properties.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
unsigned int avio_rb32(AVIOContext *s)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static void r3d_read_reos(AVFormatContext *s)
enum AVMediaType codec_type
General type of the encoded data.
AVRational avg_frame_rate
Average framerate.
int avio_r8(AVIOContext *s)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
AVInputFormat ff_r3d_demuxer
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
AVIOContext * pb
I/O context.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static int r3d_probe(AVProbeData *p)
Rational number (pair of numerator and denominator).
static int r3d_read_rdvo(AVFormatContext *s, Atom *atom)
This structure contains the data a format has to probe a file.
static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
int64_t duration
Decoding: duration of the stream, in stream time base.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int sample_rate
Audio only.
static int r3d_read_header(AVFormatContext *s)
static int r3d_read_packet(AVFormatContext *s, AVPacket *pkt)
void * priv_data
Format private data.
static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
static int r3d_read_red1(AVFormatContext *s)
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...
#define MKTAG(a, b, c, d)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVRational r_frame_rate
Real base framerate of the stream.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.