annotate r3d.c @ 6434:ca5676c4563d libavformat

cosmetic
author aurel
date Sun, 29 Aug 2010 21:23:52 +0000
parents f74198942337
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
1 /*
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
2 * R3D REDCODE demuxer
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
3 * Copyright (c) 2008 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
4 *
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
5 * This file is part of FFmpeg.
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
6 *
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
11 *
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
15 * Lesser General Public License for more details.
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
16 *
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
20 */
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
21
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
22 //#define DEBUG
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
23
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
24 #include "libavutil/intreadwrite.h"
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
25 #include "avformat.h"
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
26
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
27 typedef struct {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
28 unsigned video_offsets_count;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
29 unsigned *video_offsets;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
30 unsigned rdvo_offset;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
31 } R3DContext;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
32
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
33 typedef struct {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
34 unsigned size;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
35 uint32_t tag;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
36 uint64_t offset;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
37 } Atom;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
38
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
39 static int read_atom(AVFormatContext *s, Atom *atom)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
40 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
41 atom->offset = url_ftell(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
42 atom->size = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
43 if (atom->size < 8)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
44 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
45 atom->tag = get_le32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
46 dprintf(s, "atom %d %.4s offset %#llx\n",
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
47 atom->size, (char*)&atom->tag, atom->offset);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
48 return atom->size;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
49 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
50
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
51 static int r3d_read_red1(AVFormatContext *s)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
52 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
53 AVStream *st = av_new_stream(s, 0);
4623
993860d53040 use new metadata API in r3d demuxer
aurel
parents: 4257
diff changeset
54 char filename[258];
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
55 int tmp, tmp2;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
56
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
57 if (!st)
5148
74d599c373f9 return AVERROR(ENOMEM) if stream could not be allocated
bcoudurier
parents: 5147
diff changeset
58 return AVERROR(ENOMEM);
5910
536e5527c1e0 Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 5734
diff changeset
59 st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
60 st->codec->codec_id = CODEC_ID_JPEG2000;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
61
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
62 tmp = get_byte(s->pb); // major version
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
63 tmp2 = get_byte(s->pb); // minor version
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
64 dprintf(s, "version %d.%d\n", tmp, tmp2);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
65
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
66 tmp = get_be16(s->pb); // unknown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
67 dprintf(s, "unknown1 %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
68
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
69 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
70 av_set_pts_info(st, 32, 1, tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
71
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
72 tmp = get_be32(s->pb); // filenum
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
73 dprintf(s, "filenum %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
74
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
75 url_fskip(s->pb, 32); // unknown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
76
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
77 st->codec->width = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
78 st->codec->height = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
79
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
80 tmp = get_be16(s->pb); // unknown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
81 dprintf(s, "unknown2 %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
82
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
83 st->codec->time_base.den = get_be16(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
84 st->codec->time_base.num = get_be16(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
85
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
86 tmp = get_byte(s->pb); // audio channels
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
87 dprintf(s, "audio channels %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
88 if (tmp > 0) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
89 AVStream *ast = av_new_stream(s, 1);
5147
64ad0b0e120d check av_new_stream return value, patch by Kent Mein, mein at cs dot umn dot edu
bcoudurier
parents: 4623
diff changeset
90 if (!ast)
64ad0b0e120d check av_new_stream return value, patch by Kent Mein, mein at cs dot umn dot edu
bcoudurier
parents: 4623
diff changeset
91 return AVERROR(ENOMEM);
5910
536e5527c1e0 Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 5734
diff changeset
92 ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
93 ast->codec->codec_id = CODEC_ID_PCM_S32BE;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
94 ast->codec->channels = tmp;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
95 av_set_pts_info(ast, 32, 1, st->time_base.den);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
96 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
97
4623
993860d53040 use new metadata API in r3d demuxer
aurel
parents: 4257
diff changeset
98 get_buffer(s->pb, filename, 257);
993860d53040 use new metadata API in r3d demuxer
aurel
parents: 4257
diff changeset
99 filename[sizeof(filename)-1] = 0;
5982
f74198942337 Mark av_metadata_set() as deprecated, and use av_metadata_set2()
stefano
parents: 5910
diff changeset
100 av_metadata_set2(&st->metadata, "filename", filename, 0);
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
101
4623
993860d53040 use new metadata API in r3d demuxer
aurel
parents: 4257
diff changeset
102 dprintf(s, "filename %s\n", filename);
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
103 dprintf(s, "resolution %dx%d\n", st->codec->width, st->codec->height);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
104 dprintf(s, "timescale %d\n", st->time_base.den);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
105 dprintf(s, "frame rate %d/%d\n",
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
106 st->codec->time_base.num, st->codec->time_base.den);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
107
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
108 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
109 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
110
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
111 static int r3d_read_rdvo(AVFormatContext *s, Atom *atom)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
112 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
113 R3DContext *r3d = s->priv_data;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
114 AVStream *st = s->streams[0];
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
115 int i;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
116
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
117 r3d->video_offsets_count = (atom->size - 8) / 4;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
118 r3d->video_offsets = av_malloc(atom->size);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
119 if (!r3d->video_offsets)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
120 return AVERROR(ENOMEM);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
121
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
122 for (i = 0; i < r3d->video_offsets_count; i++) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
123 r3d->video_offsets[i] = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
124 if (!r3d->video_offsets[i]) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
125 r3d->video_offsets_count = i;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
126 break;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
127 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
128 dprintf(s, "video offset %d: %#x\n", i, r3d->video_offsets[i]);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
129 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
130
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
131 if (st->codec->time_base.den)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
132 st->duration = (uint64_t)r3d->video_offsets_count*
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
133 st->time_base.den*st->codec->time_base.num/st->codec->time_base.den;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
134 dprintf(s, "duration %lld\n", st->duration);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
135
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
136 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
137 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
138
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
139 static void r3d_read_reos(AVFormatContext *s)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
140 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
141 R3DContext *r3d = s->priv_data;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
142 int tmp;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
143
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
144 r3d->rdvo_offset = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
145 get_be32(s->pb); // rdvs offset
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
146 get_be32(s->pb); // rdao offset
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
147 get_be32(s->pb); // rdas offset
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
148
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
149 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
150 dprintf(s, "num video chunks %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
151
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
152 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
153 dprintf(s, "num audio chunks %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
154
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
155 url_fskip(s->pb, 6*4);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
156 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
157
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
158 static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
159 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
160 R3DContext *r3d = s->priv_data;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
161 Atom atom;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
162 int ret;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
163
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
164 if (read_atom(s, &atom) < 0) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
165 av_log(s, AV_LOG_ERROR, "error reading atom\n");
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
166 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
167 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
168 if (atom.tag == MKTAG('R','E','D','1')) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
169 if ((ret = r3d_read_red1(s)) < 0) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
170 av_log(s, AV_LOG_ERROR, "error parsing 'red1' atom\n");
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
171 return ret;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
172 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
173 } else {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
174 av_log(s, AV_LOG_ERROR, "could not find 'red1' atom\n");
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
175 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
176 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
177
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
178 s->data_offset = url_ftell(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
179 dprintf(s, "data offset %#llx\n", s->data_offset);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
180 if (url_is_streamed(s->pb))
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
181 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
182 // find REOB/REOF/REOS to load index
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
183 url_fseek(s->pb, url_fsize(s->pb)-48-8, SEEK_SET);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
184 if (read_atom(s, &atom) < 0)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
185 av_log(s, AV_LOG_ERROR, "error reading end atom\n");
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
186
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
187 if (atom.tag != MKTAG('R','E','O','B') &&
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
188 atom.tag != MKTAG('R','E','O','F') &&
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
189 atom.tag != MKTAG('R','E','O','S'))
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
190 goto out;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
191
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
192 r3d_read_reos(s);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
193
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
194 if (r3d->rdvo_offset) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
195 url_fseek(s->pb, r3d->rdvo_offset, SEEK_SET);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
196 if (read_atom(s, &atom) < 0)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
197 av_log(s, AV_LOG_ERROR, "error reading 'rdvo' atom\n");
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
198 if (atom.tag == MKTAG('R','D','V','O')) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
199 if (r3d_read_rdvo(s, &atom) < 0)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
200 av_log(s, AV_LOG_ERROR, "error parsing 'rdvo' atom\n");
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
201 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
202 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
203
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
204 out:
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
205 url_fseek(s->pb, s->data_offset, SEEK_SET);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
206 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
207 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
208
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
209 static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
210 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
211 AVStream *st = s->streams[0];
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
212 int tmp, tmp2;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
213 uint64_t pos = url_ftell(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
214 unsigned dts;
5734
f41a84612842 Plug some memory leaks for truncated files
vitor
parents: 5148
diff changeset
215 int ret;
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
216
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
217 dts = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
218
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
219 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
220 dprintf(s, "frame num %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
221
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
222 tmp = get_byte(s->pb); // major version
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
223 tmp2 = get_byte(s->pb); // minor version
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
224 dprintf(s, "version %d.%d\n", tmp, tmp2);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
225
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
226 tmp = get_be16(s->pb); // unknown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
227 dprintf(s, "unknown %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
228
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
229 if (tmp > 4) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
230 tmp = get_be16(s->pb); // unknown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
231 dprintf(s, "unknown %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
232
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
233 tmp = get_be16(s->pb); // unknown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
234 dprintf(s, "unknown %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
235
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
236 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
237 dprintf(s, "width %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
238 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
239 dprintf(s, "height %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
240
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
241 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
242 dprintf(s, "metadata len %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
243 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
244 tmp = atom->size - 8 - (url_ftell(s->pb) - pos);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
245 if (tmp < 0)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
246 return -1;
5734
f41a84612842 Plug some memory leaks for truncated files
vitor
parents: 5148
diff changeset
247 ret = av_get_packet(s->pb, pkt, tmp);
f41a84612842 Plug some memory leaks for truncated files
vitor
parents: 5148
diff changeset
248 if (ret < 0) {
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
249 av_log(s, AV_LOG_ERROR, "error reading video packet\n");
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
250 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
251 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
252
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
253 pkt->stream_index = 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
254 pkt->dts = dts;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
255 if (st->codec->time_base.den)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
256 pkt->duration = (uint64_t)st->time_base.den*
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
257 st->codec->time_base.num/st->codec->time_base.den;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
258 dprintf(s, "pkt dts %lld duration %d\n", pkt->dts, pkt->duration);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
259
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
260 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
261 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
262
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
263 static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
264 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
265 AVStream *st = s->streams[1];
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
266 int tmp, tmp2, samples, size;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
267 uint64_t pos = url_ftell(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
268 unsigned dts;
5734
f41a84612842 Plug some memory leaks for truncated files
vitor
parents: 5148
diff changeset
269 int ret;
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
270
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
271 dts = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
272
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
273 st->codec->sample_rate = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
274
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
275 samples = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
276
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
277 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
278 dprintf(s, "packet num %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
279
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
280 tmp = get_be16(s->pb); // unkown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
281 dprintf(s, "unknown %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
282
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
283 tmp = get_byte(s->pb); // major version
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
284 tmp2 = get_byte(s->pb); // minor version
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
285 dprintf(s, "version %d.%d\n", tmp, tmp2);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
286
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
287 tmp = get_be32(s->pb); // unknown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
288 dprintf(s, "unknown %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
289
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
290 size = atom->size - 8 - (url_ftell(s->pb) - pos);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
291 if (size < 0)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
292 return -1;
5734
f41a84612842 Plug some memory leaks for truncated files
vitor
parents: 5148
diff changeset
293 ret = av_get_packet(s->pb, pkt, size);
f41a84612842 Plug some memory leaks for truncated files
vitor
parents: 5148
diff changeset
294 if (ret < 0) {
f41a84612842 Plug some memory leaks for truncated files
vitor
parents: 5148
diff changeset
295 av_log(s, AV_LOG_ERROR, "error reading audio packet\n");
f41a84612842 Plug some memory leaks for truncated files
vitor
parents: 5148
diff changeset
296 return ret;
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
297 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
298
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
299 pkt->stream_index = 1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
300 pkt->dts = dts;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
301 pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
302 dprintf(s, "pkt dts %lld duration %d samples %d sample rate %d\n",
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
303 pkt->dts, pkt->duration, samples, st->codec->sample_rate);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
304
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
305 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
306 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
307
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
308 static int r3d_read_packet(AVFormatContext *s, AVPacket *pkt)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
309 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
310 Atom atom;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
311 int err = 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
312
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
313 while (!err) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
314 if (read_atom(s, &atom) < 0) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
315 err = -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
316 break;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
317 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
318 switch (atom.tag) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
319 case MKTAG('R','E','D','V'):
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
320 if (s->streams[0]->discard == AVDISCARD_ALL)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
321 goto skip;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
322 if (!(err = r3d_read_redv(s, pkt, &atom)))
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
323 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
324 break;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
325 case MKTAG('R','E','D','A'):
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
326 if (s->nb_streams < 2)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
327 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
328 if (s->streams[1]->discard == AVDISCARD_ALL)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
329 goto skip;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
330 if (!(err = r3d_read_reda(s, pkt, &atom)))
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
331 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
332 break;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
333 default:
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
334 skip:
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
335 url_fskip(s->pb, atom.size-8);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
336 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
337 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
338 return err;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
339 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
340
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
341 static int r3d_probe(AVProbeData *p)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
342 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
343 if (AV_RL32(p->buf + 4) == MKTAG('R','E','D','1'))
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
344 return AVPROBE_SCORE_MAX;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
345 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
346 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
347
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
348 static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
349 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
350 AVStream *st = s->streams[0]; // video stream
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
351 R3DContext *r3d = s->priv_data;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
352 int frame_num;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
353
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
354 if (!st->codec->time_base.num || !st->time_base.den)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
355 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
356
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
357 frame_num = sample_time*st->codec->time_base.den/
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
358 ((int64_t)st->codec->time_base.num*st->time_base.den);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
359 dprintf(s, "seek frame num %d timestamp %lld\n", frame_num, sample_time);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
360
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
361 if (frame_num < r3d->video_offsets_count) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
362 url_fseek(s->pb, r3d->video_offsets_count, SEEK_SET);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
363 } else {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
364 av_log(s, AV_LOG_ERROR, "could not seek to frame %d\n", frame_num);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
365 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
366 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
367
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
368 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
369 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
370
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
371 static int r3d_close(AVFormatContext *s)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
372 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
373 R3DContext *r3d = s->priv_data;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
374
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
375 av_freep(&r3d->video_offsets);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
376
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
377 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
378 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
379
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
380 AVInputFormat r3d_demuxer = {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
381 "r3d",
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
382 NULL_IF_CONFIG_SMALL("REDCODE R3D format"),
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
383 sizeof(R3DContext),
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
384 r3d_probe,
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
385 r3d_read_header,
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
386 r3d_read_packet,
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
387 r3d_close,
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
388 r3d_seek,
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
389 };