annotate r3d.c @ 5185:0c742c9c4aa7 libavformat

Try harder to avoid false positives for DV probe. Require at least one signature match per provided 1MB of probe data, and if there is only a single match, return at most MAX/4. Fixes issue1382 but could/should probably still be improved.
author reimar
date Mon, 14 Sep 2009 22:03:07 +0000
parents 74d599c373f9
children f41a84612842
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);
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
59 st->codec->codec_type = CODEC_TYPE_VIDEO;
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);
4257
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
92 ast->codec->codec_type = CODEC_TYPE_AUDIO;
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;
993860d53040 use new metadata API in r3d demuxer
aurel
parents: 4257
diff changeset
100 av_metadata_set(&st->metadata, "filename", filename);
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;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
215
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
216 dts = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
217
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
218 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
219 dprintf(s, "frame num %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
220
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
221 tmp = get_byte(s->pb); // major version
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
222 tmp2 = get_byte(s->pb); // minor version
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
223 dprintf(s, "version %d.%d\n", tmp, tmp2);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
224
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
225 tmp = get_be16(s->pb); // unknown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
226 dprintf(s, "unknown %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
227
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
228 if (tmp > 4) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
229 tmp = get_be16(s->pb); // unknown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
230 dprintf(s, "unknown %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
231
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
232 tmp = get_be16(s->pb); // unknown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
233 dprintf(s, "unknown %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
234
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
235 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
236 dprintf(s, "width %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
237 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
238 dprintf(s, "height %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
239
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
240 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
241 dprintf(s, "metadata len %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
242 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
243 tmp = atom->size - 8 - (url_ftell(s->pb) - pos);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
244 if (tmp < 0)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
245 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
246
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
247 if (av_get_packet(s->pb, pkt, tmp) != tmp) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
248 av_log(s, AV_LOG_ERROR, "error reading video packet\n");
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
249 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
250 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
251
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
252 pkt->stream_index = 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
253 pkt->dts = dts;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
254 if (st->codec->time_base.den)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
255 pkt->duration = (uint64_t)st->time_base.den*
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
256 st->codec->time_base.num/st->codec->time_base.den;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
257 dprintf(s, "pkt dts %lld duration %d\n", pkt->dts, pkt->duration);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
258
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
259 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
260 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
261
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
262 static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
263 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
264 AVStream *st = s->streams[1];
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
265 int tmp, tmp2, samples, size;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
266 uint64_t pos = url_ftell(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
267 unsigned dts;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
268
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
269 dts = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
270
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
271 st->codec->sample_rate = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
272
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
273 samples = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
274
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
275 tmp = get_be32(s->pb);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
276 dprintf(s, "packet num %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
277
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
278 tmp = get_be16(s->pb); // unkown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
279 dprintf(s, "unknown %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
280
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
281 tmp = get_byte(s->pb); // major version
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
282 tmp2 = get_byte(s->pb); // minor version
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
283 dprintf(s, "version %d.%d\n", tmp, tmp2);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
284
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
285 tmp = get_be32(s->pb); // unknown
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
286 dprintf(s, "unknown %d\n", tmp);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
287
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
288 size = atom->size - 8 - (url_ftell(s->pb) - pos);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
289 if (size < 0)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
290 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
291 if (av_get_packet(s->pb, pkt, size) != size) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
292 av_log(s, AV_LOG_ERROR, "error reading video packet\n");
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
293 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
294 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
295
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
296 pkt->stream_index = 1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
297 pkt->dts = dts;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
298 pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
299 dprintf(s, "pkt dts %lld duration %d samples %d sample rate %d\n",
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
300 pkt->dts, pkt->duration, samples, st->codec->sample_rate);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
301
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
302 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
303 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
304
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
305 static int r3d_read_packet(AVFormatContext *s, AVPacket *pkt)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
306 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
307 Atom atom;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
308 int err = 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
309
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
310 while (!err) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
311 if (read_atom(s, &atom) < 0) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
312 err = -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
313 break;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
314 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
315 switch (atom.tag) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
316 case MKTAG('R','E','D','V'):
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
317 if (s->streams[0]->discard == AVDISCARD_ALL)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
318 goto skip;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
319 if (!(err = r3d_read_redv(s, pkt, &atom)))
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
320 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
321 break;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
322 case MKTAG('R','E','D','A'):
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
323 if (s->nb_streams < 2)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
324 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
325 if (s->streams[1]->discard == AVDISCARD_ALL)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
326 goto skip;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
327 if (!(err = r3d_read_reda(s, pkt, &atom)))
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
328 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
329 break;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
330 default:
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
331 skip:
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
332 url_fskip(s->pb, atom.size-8);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
333 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
334 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
335 return err;
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 static int r3d_probe(AVProbeData *p)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
339 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
340 if (AV_RL32(p->buf + 4) == MKTAG('R','E','D','1'))
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
341 return AVPROBE_SCORE_MAX;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
342 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
343 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
344
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
345 static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
346 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
347 AVStream *st = s->streams[0]; // video stream
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
348 R3DContext *r3d = s->priv_data;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
349 int frame_num;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
350
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
351 if (!st->codec->time_base.num || !st->time_base.den)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
352 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
353
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
354 frame_num = sample_time*st->codec->time_base.den/
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
355 ((int64_t)st->codec->time_base.num*st->time_base.den);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
356 dprintf(s, "seek frame num %d timestamp %lld\n", frame_num, sample_time);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
357
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
358 if (frame_num < r3d->video_offsets_count) {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
359 url_fseek(s->pb, r3d->video_offsets_count, SEEK_SET);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
360 } else {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
361 av_log(s, AV_LOG_ERROR, "could not seek to frame %d\n", frame_num);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
362 return -1;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
363 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
364
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
365 return 0;
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 static int r3d_close(AVFormatContext *s)
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
369 {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
370 R3DContext *r3d = s->priv_data;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
371
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
372 av_freep(&r3d->video_offsets);
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
373
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
374 return 0;
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
375 }
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
376
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
377 AVInputFormat r3d_demuxer = {
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
378 "r3d",
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
379 NULL_IF_CONFIG_SMALL("REDCODE R3D format"),
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
380 sizeof(R3DContext),
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
381 r3d_probe,
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
382 r3d_read_header,
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
383 r3d_read_packet,
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
384 r3d_close,
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
385 r3d_seek,
3f71ce8f8da1 R3D REDCODE demuxer
bcoudurier
parents:
diff changeset
386 };