Mercurial > libavformat.hg
annotate matroskadec.c @ 5550:133a0ee142a8 libavformat
Support decoding of Avid uncompressed mov files, fixes issue 1685.
author | cehoyos |
---|---|
date | Fri, 15 Jan 2010 11:03:40 +0000 |
parents | f4eceb1eb100 |
children | 27fd77f20a89 |
rev | line source |
---|---|
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1 /* |
3685
c077c928bfe6
matroskadec: update copyright year and related comments
aurel
parents:
3684
diff
changeset
|
2 * Matroska file demuxer |
3692 | 3 * Copyright (c) 2003-2008 The FFmpeg Project |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
4 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
5 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
6 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
11 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
16 * |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1332
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
887
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
20 */ |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
21 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
22 /** |
4331
49c1d3b27727
Use full internal pathname in doxygen @file directives.
diego
parents:
4249
diff
changeset
|
23 * @file libavformat/matroskadec.c |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
24 * Matroska file demuxer |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
25 * by Ronald Bultje <rbultje@ronald.bitfreak.net> |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
26 * with a little help from Moritz Bunkus <moritz@bunkus.org> |
3685
c077c928bfe6
matroskadec: update copyright year and related comments
aurel
parents:
3684
diff
changeset
|
27 * totally reworked by Aurelien Jacobs <aurel@gnuage.org> |
3692 | 28 * Specs available on the Matroska project page: http://www.matroska.org/. |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
29 */ |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
30 |
3894
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
31 #include <stdio.h> |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
32 #include "avformat.h" |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
5031
diff
changeset
|
33 /* For ff_codec_get_id(). */ |
1172
6a5e58d2114b
move common stuff from avienc.c and wav.c to new file riff.c
mru
parents:
1169
diff
changeset
|
34 #include "riff.h" |
3601 | 35 #include "isom.h" |
2142
3aa1f0f698de
split some common code from the mkv demuxer that will be useful to the muxer
aurel
parents:
2023
diff
changeset
|
36 #include "matroska.h" |
3201 | 37 #include "libavcodec/mpeg4audio.h" |
3286 | 38 #include "libavutil/intfloat_readwrite.h" |
4201
7d2f3f1b68d8
Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents:
4124
diff
changeset
|
39 #include "libavutil/intreadwrite.h" |
3628
5f2e1da55755
matroskadec: use more robust av_strlcpy() instead of strcpy()
aurel
parents:
3601
diff
changeset
|
40 #include "libavutil/avstring.h" |
3281 | 41 #include "libavutil/lzo.h" |
4206 | 42 #if CONFIG_ZLIB |
3293 | 43 #include <zlib.h> |
44 #endif | |
4206 | 45 #if CONFIG_BZLIB |
3298
edabe3db2b6e
matroskadec: add support for bzlib compressed tracks
aurel
parents:
3294
diff
changeset
|
46 #include <bzlib.h> |
edabe3db2b6e
matroskadec: add support for bzlib compressed tracks
aurel
parents:
3294
diff
changeset
|
47 #endif |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
48 |
3632 | 49 typedef enum { |
50 EBML_NONE, | |
51 EBML_UINT, | |
52 EBML_FLOAT, | |
53 EBML_STR, | |
54 EBML_UTF8, | |
55 EBML_BIN, | |
56 EBML_NEST, | |
57 EBML_PASS, | |
58 EBML_STOP, | |
59 } EbmlType; | |
60 | |
61 typedef const struct EbmlSyntax { | |
62 uint32_t id; | |
63 EbmlType type; | |
64 int list_elem_size; | |
65 int data_offset; | |
66 union { | |
67 uint64_t u; | |
68 double f; | |
69 const char *s; | |
70 const struct EbmlSyntax *n; | |
71 } def; | |
72 } EbmlSyntax; | |
73 | |
74 typedef struct { | |
75 int nb_elem; | |
76 void *elem; | |
77 } EbmlList; | |
78 | |
79 typedef struct { | |
80 int size; | |
81 uint8_t *data; | |
82 int64_t pos; | |
83 } EbmlBin; | |
84 | |
3633
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
85 typedef struct { |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
86 uint64_t version; |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
87 uint64_t max_size; |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
88 uint64_t id_length; |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
89 char *doctype; |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
90 uint64_t doctype_version; |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
91 } Ebml; |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
92 |
3642 | 93 typedef struct { |
94 uint64_t algo; | |
95 EbmlBin settings; | |
96 } MatroskaTrackCompression; | |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
97 |
3642 | 98 typedef struct { |
99 uint64_t scope; | |
100 uint64_t type; | |
101 MatroskaTrackCompression compression; | |
102 } MatroskaTrackEncoding; | |
103 | |
104 typedef struct { | |
105 double frame_rate; | |
106 uint64_t display_width; | |
107 uint64_t display_height; | |
108 uint64_t pixel_width; | |
109 uint64_t pixel_height; | |
110 uint64_t fourcc; | |
111 } MatroskaTrackVideo; | |
2147 | 112 |
3642 | 113 typedef struct { |
114 double samplerate; | |
115 double out_samplerate; | |
116 uint64_t bitdepth; | |
117 uint64_t channels; | |
2147 | 118 |
3642 | 119 /* real audio header (extracted from extradata) */ |
120 int coded_framesize; | |
121 int sub_packet_h; | |
122 int frame_size; | |
123 int sub_packet_size; | |
124 int sub_packet_cnt; | |
125 int pkt_cnt; | |
126 uint8_t *buf; | |
127 } MatroskaTrackAudio; | |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
128 |
3642 | 129 typedef struct { |
130 uint64_t num; | |
4494 | 131 uint64_t uid; |
3642 | 132 uint64_t type; |
4493
40499405ef63
matroskadec: export track name through the metadata API
aurel
parents:
4492
diff
changeset
|
133 char *name; |
3642 | 134 char *codec_id; |
135 EbmlBin codec_priv; | |
136 char *language; | |
3408
da09478c97ce
matroskadec: read TrackTimecodeScale and set timebase accordingly
aurel
parents:
3407
diff
changeset
|
137 double time_scale; |
1912 | 138 uint64_t default_duration; |
3630 | 139 uint64_t flag_default; |
3642 | 140 MatroskaTrackVideo video; |
141 MatroskaTrackAudio audio; | |
142 EbmlList encodings; | |
3634
f206f746ff61
matroskadec: store an AVStream pointer instead of a stream index
aurel
parents:
3633
diff
changeset
|
143 |
f206f746ff61
matroskadec: store an AVStream pointer instead of a stream index
aurel
parents:
3633
diff
changeset
|
144 AVStream *stream; |
3915
7643d7c3fcf6
matroskadec: ensure that overlapping subtitles are not added to the index
aurel
parents:
3914
diff
changeset
|
145 int64_t end_timecode; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
146 } MatroskaTrack; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
147 |
3637 | 148 typedef struct { |
4494 | 149 uint64_t uid; |
3640
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
150 char *filename; |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
151 char *mime; |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
152 EbmlBin bin; |
4495 | 153 |
154 AVStream *stream; | |
3640
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
155 } MatroskaAttachement; |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
156 |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
157 typedef struct { |
3639 | 158 uint64_t start; |
159 uint64_t end; | |
160 uint64_t uid; | |
161 char *title; | |
4492
56ea2b1028fe
matroskadec: use new metadata API to export some simple information
aurel
parents:
4352
diff
changeset
|
162 |
56ea2b1028fe
matroskadec: use new metadata API to export some simple information
aurel
parents:
4352
diff
changeset
|
163 AVChapter *chapter; |
3639 | 164 } MatroskaChapter; |
165 | |
166 typedef struct { | |
3637 | 167 uint64_t track; |
168 uint64_t pos; | |
169 } MatroskaIndexPos; | |
170 | |
171 typedef struct { | |
172 uint64_t time; | |
173 EbmlList pos; | |
174 } MatroskaIndex; | |
175 | |
3644 | 176 typedef struct { |
3702 | 177 char *name; |
178 char *string; | |
4497
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
179 char *lang; |
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
180 uint64_t def; |
3702 | 181 EbmlList sub; |
182 } MatroskaTag; | |
183 | |
184 typedef struct { | |
4495 | 185 char *type; |
186 uint64_t typevalue; | |
187 uint64_t trackuid; | |
188 uint64_t chapteruid; | |
189 uint64_t attachuid; | |
190 } MatroskaTagTarget; | |
191 | |
192 typedef struct { | |
193 MatroskaTagTarget target; | |
194 EbmlList tag; | |
195 } MatroskaTags; | |
196 | |
197 typedef struct { | |
3644 | 198 uint64_t id; |
199 uint64_t pos; | |
200 } MatroskaSeekhead; | |
201 | |
3658 | 202 typedef struct { |
2147 | 203 uint64_t start; |
204 uint64_t length; | |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
205 } MatroskaLevel; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
206 |
3658 | 207 typedef struct { |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
208 AVFormatContext *ctx; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
209 |
3692 | 210 /* EBML stuff */ |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
211 int num_levels; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
212 MatroskaLevel levels[EBML_MAX_DEPTH]; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
213 int level_up; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
214 |
3641 | 215 uint64_t time_scale; |
216 double duration; | |
217 char *title; | |
3642 | 218 EbmlList tracks; |
3640
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
219 EbmlList attachments; |
3639 | 220 EbmlList chapters; |
3637 | 221 EbmlList index; |
3702 | 222 EbmlList tags; |
3644 | 223 EbmlList seekhead; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
224 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
225 /* byte position of the segment inside the stream */ |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3972
diff
changeset
|
226 int64_t segment_start; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
227 |
3692 | 228 /* the packet queue */ |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
229 AVPacket **packets; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
230 int num_packets; |
3954
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
231 AVPacket *prev_pkt; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
232 |
2147 | 233 int done; |
3651
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
234 int has_cluster_id; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
235 |
2014
de75a5a81f28
add support for seeking to a keyframe instead of a random frame
aurel
parents:
2013
diff
changeset
|
236 /* What to skip before effectively reading a packet. */ |
de75a5a81f28
add support for seeking to a keyframe instead of a random frame
aurel
parents:
2013
diff
changeset
|
237 int skip_to_keyframe; |
3914
f7a20cf5438f
matroskadec: after seeking, skip up to the desired timestamp instead of
aurel
parents:
3913
diff
changeset
|
238 uint64_t skip_to_timecode; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
239 } MatroskaDemuxContext; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
240 |
3653 | 241 typedef struct { |
242 uint64_t duration; | |
243 int64_t reference; | |
5128
2397bd089f70
matroskadec: correctly parse flags for simpleblock frames
aurel
parents:
5058
diff
changeset
|
244 uint64_t non_simple; |
3653 | 245 EbmlBin bin; |
246 } MatroskaBlock; | |
247 | |
248 typedef struct { | |
249 uint64_t timecode; | |
250 EbmlList blocks; | |
251 } MatroskaCluster; | |
252 | |
3633
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
253 static EbmlSyntax ebml_header[] = { |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
254 { EBML_ID_EBMLREADVERSION, EBML_UINT, 0, offsetof(Ebml,version), {.u=EBML_VERSION} }, |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
255 { EBML_ID_EBMLMAXSIZELENGTH, EBML_UINT, 0, offsetof(Ebml,max_size), {.u=8} }, |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
256 { EBML_ID_EBMLMAXIDLENGTH, EBML_UINT, 0, offsetof(Ebml,id_length), {.u=4} }, |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
257 { EBML_ID_DOCTYPE, EBML_STR, 0, offsetof(Ebml,doctype), {.s="(none)"} }, |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
258 { EBML_ID_DOCTYPEREADVERSION, EBML_UINT, 0, offsetof(Ebml,doctype_version), {.u=1} }, |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
259 { EBML_ID_EBMLVERSION, EBML_NONE }, |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
260 { EBML_ID_DOCTYPEVERSION, EBML_NONE }, |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
261 { 0 } |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
262 }; |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
263 |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
264 static EbmlSyntax ebml_syntax[] = { |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
265 { EBML_ID_HEADER, EBML_NEST, 0, 0, {.n=ebml_header} }, |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
266 { 0 } |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
267 }; |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
268 |
3641 | 269 static EbmlSyntax matroska_info[] = { |
270 { MATROSKA_ID_TIMECODESCALE, EBML_UINT, 0, offsetof(MatroskaDemuxContext,time_scale), {.u=1000000} }, | |
271 { MATROSKA_ID_DURATION, EBML_FLOAT, 0, offsetof(MatroskaDemuxContext,duration) }, | |
272 { MATROSKA_ID_TITLE, EBML_UTF8, 0, offsetof(MatroskaDemuxContext,title) }, | |
273 { MATROSKA_ID_WRITINGAPP, EBML_NONE }, | |
274 { MATROSKA_ID_MUXINGAPP, EBML_NONE }, | |
275 { MATROSKA_ID_DATEUTC, EBML_NONE }, | |
276 { MATROSKA_ID_SEGMENTUID, EBML_NONE }, | |
277 { 0 } | |
278 }; | |
279 | |
3642 | 280 static EbmlSyntax matroska_track_video[] = { |
281 { MATROSKA_ID_VIDEOFRAMERATE, EBML_FLOAT,0, offsetof(MatroskaTrackVideo,frame_rate) }, | |
282 { MATROSKA_ID_VIDEODISPLAYWIDTH, EBML_UINT, 0, offsetof(MatroskaTrackVideo,display_width) }, | |
283 { MATROSKA_ID_VIDEODISPLAYHEIGHT, EBML_UINT, 0, offsetof(MatroskaTrackVideo,display_height) }, | |
284 { MATROSKA_ID_VIDEOPIXELWIDTH, EBML_UINT, 0, offsetof(MatroskaTrackVideo,pixel_width) }, | |
285 { MATROSKA_ID_VIDEOPIXELHEIGHT, EBML_UINT, 0, offsetof(MatroskaTrackVideo,pixel_height) }, | |
286 { MATROSKA_ID_VIDEOCOLORSPACE, EBML_UINT, 0, offsetof(MatroskaTrackVideo,fourcc) }, | |
3717
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
287 { MATROSKA_ID_VIDEOPIXELCROPB, EBML_NONE }, |
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
288 { MATROSKA_ID_VIDEOPIXELCROPT, EBML_NONE }, |
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
289 { MATROSKA_ID_VIDEOPIXELCROPL, EBML_NONE }, |
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
290 { MATROSKA_ID_VIDEOPIXELCROPR, EBML_NONE }, |
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
291 { MATROSKA_ID_VIDEODISPLAYUNIT, EBML_NONE }, |
3642 | 292 { MATROSKA_ID_VIDEOFLAGINTERLACED,EBML_NONE }, |
293 { MATROSKA_ID_VIDEOSTEREOMODE, EBML_NONE }, | |
294 { MATROSKA_ID_VIDEOASPECTRATIO, EBML_NONE }, | |
295 { 0 } | |
296 }; | |
297 | |
298 static EbmlSyntax matroska_track_audio[] = { | |
299 { MATROSKA_ID_AUDIOSAMPLINGFREQ, EBML_FLOAT,0, offsetof(MatroskaTrackAudio,samplerate), {.f=8000.0} }, | |
300 { MATROSKA_ID_AUDIOOUTSAMPLINGFREQ,EBML_FLOAT,0,offsetof(MatroskaTrackAudio,out_samplerate) }, | |
301 { MATROSKA_ID_AUDIOBITDEPTH, EBML_UINT, 0, offsetof(MatroskaTrackAudio,bitdepth) }, | |
302 { MATROSKA_ID_AUDIOCHANNELS, EBML_UINT, 0, offsetof(MatroskaTrackAudio,channels), {.u=1} }, | |
303 { 0 } | |
304 }; | |
305 | |
306 static EbmlSyntax matroska_track_encoding_compression[] = { | |
307 { MATROSKA_ID_ENCODINGCOMPALGO, EBML_UINT, 0, offsetof(MatroskaTrackCompression,algo), {.u=0} }, | |
308 { MATROSKA_ID_ENCODINGCOMPSETTINGS,EBML_BIN, 0, offsetof(MatroskaTrackCompression,settings) }, | |
309 { 0 } | |
310 }; | |
311 | |
312 static EbmlSyntax matroska_track_encoding[] = { | |
313 { MATROSKA_ID_ENCODINGSCOPE, EBML_UINT, 0, offsetof(MatroskaTrackEncoding,scope), {.u=1} }, | |
314 { MATROSKA_ID_ENCODINGTYPE, EBML_UINT, 0, offsetof(MatroskaTrackEncoding,type), {.u=0} }, | |
315 { MATROSKA_ID_ENCODINGCOMPRESSION,EBML_NEST, 0, offsetof(MatroskaTrackEncoding,compression), {.n=matroska_track_encoding_compression} }, | |
3717
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
316 { MATROSKA_ID_ENCODINGORDER, EBML_NONE }, |
3642 | 317 { 0 } |
318 }; | |
319 | |
320 static EbmlSyntax matroska_track_encodings[] = { | |
321 { MATROSKA_ID_TRACKCONTENTENCODING, EBML_NEST, sizeof(MatroskaTrackEncoding), offsetof(MatroskaTrack,encodings), {.n=matroska_track_encoding} }, | |
322 { 0 } | |
323 }; | |
324 | |
325 static EbmlSyntax matroska_track[] = { | |
326 { MATROSKA_ID_TRACKNUMBER, EBML_UINT, 0, offsetof(MatroskaTrack,num) }, | |
4493
40499405ef63
matroskadec: export track name through the metadata API
aurel
parents:
4492
diff
changeset
|
327 { MATROSKA_ID_TRACKNAME, EBML_UTF8, 0, offsetof(MatroskaTrack,name) }, |
4494 | 328 { MATROSKA_ID_TRACKUID, EBML_UINT, 0, offsetof(MatroskaTrack,uid) }, |
3642 | 329 { MATROSKA_ID_TRACKTYPE, EBML_UINT, 0, offsetof(MatroskaTrack,type) }, |
330 { MATROSKA_ID_CODECID, EBML_STR, 0, offsetof(MatroskaTrack,codec_id) }, | |
331 { MATROSKA_ID_CODECPRIVATE, EBML_BIN, 0, offsetof(MatroskaTrack,codec_priv) }, | |
332 { MATROSKA_ID_TRACKLANGUAGE, EBML_UTF8, 0, offsetof(MatroskaTrack,language), {.s="eng"} }, | |
333 { MATROSKA_ID_TRACKDEFAULTDURATION, EBML_UINT, 0, offsetof(MatroskaTrack,default_duration) }, | |
334 { MATROSKA_ID_TRACKTIMECODESCALE, EBML_FLOAT,0, offsetof(MatroskaTrack,time_scale), {.f=1.0} }, | |
335 { MATROSKA_ID_TRACKFLAGDEFAULT, EBML_UINT, 0, offsetof(MatroskaTrack,flag_default), {.u=1} }, | |
336 { MATROSKA_ID_TRACKVIDEO, EBML_NEST, 0, offsetof(MatroskaTrack,video), {.n=matroska_track_video} }, | |
337 { MATROSKA_ID_TRACKAUDIO, EBML_NEST, 0, offsetof(MatroskaTrack,audio), {.n=matroska_track_audio} }, | |
338 { MATROSKA_ID_TRACKCONTENTENCODINGS,EBML_NEST, 0, 0, {.n=matroska_track_encodings} }, | |
339 { MATROSKA_ID_TRACKFLAGENABLED, EBML_NONE }, | |
340 { MATROSKA_ID_TRACKFLAGFORCED, EBML_NONE }, | |
341 { MATROSKA_ID_TRACKFLAGLACING, EBML_NONE }, | |
342 { MATROSKA_ID_CODECNAME, EBML_NONE }, | |
343 { MATROSKA_ID_CODECDECODEALL, EBML_NONE }, | |
344 { MATROSKA_ID_CODECINFOURL, EBML_NONE }, | |
345 { MATROSKA_ID_CODECDOWNLOADURL, EBML_NONE }, | |
346 { MATROSKA_ID_TRACKMINCACHE, EBML_NONE }, | |
347 { MATROSKA_ID_TRACKMAXCACHE, EBML_NONE }, | |
3717
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
348 { MATROSKA_ID_TRACKMAXBLKADDID, EBML_NONE }, |
3642 | 349 { 0 } |
350 }; | |
351 | |
352 static EbmlSyntax matroska_tracks[] = { | |
353 { MATROSKA_ID_TRACKENTRY, EBML_NEST, sizeof(MatroskaTrack), offsetof(MatroskaDemuxContext,tracks), {.n=matroska_track} }, | |
354 { 0 } | |
355 }; | |
356 | |
3640
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
357 static EbmlSyntax matroska_attachment[] = { |
4494 | 358 { MATROSKA_ID_FILEUID, EBML_UINT, 0, offsetof(MatroskaAttachement,uid) }, |
3640
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
359 { MATROSKA_ID_FILENAME, EBML_UTF8, 0, offsetof(MatroskaAttachement,filename) }, |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
360 { MATROSKA_ID_FILEMIMETYPE, EBML_STR, 0, offsetof(MatroskaAttachement,mime) }, |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
361 { MATROSKA_ID_FILEDATA, EBML_BIN, 0, offsetof(MatroskaAttachement,bin) }, |
3717
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
362 { MATROSKA_ID_FILEDESC, EBML_NONE }, |
3640
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
363 { 0 } |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
364 }; |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
365 |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
366 static EbmlSyntax matroska_attachments[] = { |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
367 { MATROSKA_ID_ATTACHEDFILE, EBML_NEST, sizeof(MatroskaAttachement), offsetof(MatroskaDemuxContext,attachments), {.n=matroska_attachment} }, |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
368 { 0 } |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
369 }; |
122a7c807f80
matroskadec: use generic parser to parse attachments
aurel
parents:
3639
diff
changeset
|
370 |
3639 | 371 static EbmlSyntax matroska_chapter_display[] = { |
372 { MATROSKA_ID_CHAPSTRING, EBML_UTF8, 0, offsetof(MatroskaChapter,title) }, | |
3717
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
373 { MATROSKA_ID_CHAPLANG, EBML_NONE }, |
3639 | 374 { 0 } |
375 }; | |
376 | |
377 static EbmlSyntax matroska_chapter_entry[] = { | |
378 { MATROSKA_ID_CHAPTERTIMESTART, EBML_UINT, 0, offsetof(MatroskaChapter,start), {.u=AV_NOPTS_VALUE} }, | |
379 { MATROSKA_ID_CHAPTERTIMEEND, EBML_UINT, 0, offsetof(MatroskaChapter,end), {.u=AV_NOPTS_VALUE} }, | |
380 { MATROSKA_ID_CHAPTERUID, EBML_UINT, 0, offsetof(MatroskaChapter,uid) }, | |
381 { MATROSKA_ID_CHAPTERDISPLAY, EBML_NEST, 0, 0, {.n=matroska_chapter_display} }, | |
382 { MATROSKA_ID_CHAPTERFLAGHIDDEN, EBML_NONE }, | |
3717
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
383 { MATROSKA_ID_CHAPTERFLAGENABLED, EBML_NONE }, |
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
384 { MATROSKA_ID_CHAPTERPHYSEQUIV, EBML_NONE }, |
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
385 { MATROSKA_ID_CHAPTERATOM, EBML_NONE }, |
3639 | 386 { 0 } |
387 }; | |
388 | |
389 static EbmlSyntax matroska_chapter[] = { | |
390 { MATROSKA_ID_CHAPTERATOM, EBML_NEST, sizeof(MatroskaChapter), offsetof(MatroskaDemuxContext,chapters), {.n=matroska_chapter_entry} }, | |
391 { MATROSKA_ID_EDITIONUID, EBML_NONE }, | |
392 { MATROSKA_ID_EDITIONFLAGHIDDEN, EBML_NONE }, | |
393 { MATROSKA_ID_EDITIONFLAGDEFAULT, EBML_NONE }, | |
3717
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
394 { MATROSKA_ID_EDITIONFLAGORDERED, EBML_NONE }, |
3639 | 395 { 0 } |
396 }; | |
397 | |
398 static EbmlSyntax matroska_chapters[] = { | |
399 { MATROSKA_ID_EDITIONENTRY, EBML_NEST, 0, 0, {.n=matroska_chapter} }, | |
400 { 0 } | |
401 }; | |
402 | |
3637 | 403 static EbmlSyntax matroska_index_pos[] = { |
404 { MATROSKA_ID_CUETRACK, EBML_UINT, 0, offsetof(MatroskaIndexPos,track) }, | |
405 { MATROSKA_ID_CUECLUSTERPOSITION, EBML_UINT, 0, offsetof(MatroskaIndexPos,pos) }, | |
3717
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
406 { MATROSKA_ID_CUEBLOCKNUMBER, EBML_NONE }, |
3637 | 407 { 0 } |
408 }; | |
409 | |
410 static EbmlSyntax matroska_index_entry[] = { | |
411 { MATROSKA_ID_CUETIME, EBML_UINT, 0, offsetof(MatroskaIndex,time) }, | |
412 { MATROSKA_ID_CUETRACKPOSITION, EBML_NEST, sizeof(MatroskaIndexPos), offsetof(MatroskaIndex,pos), {.n=matroska_index_pos} }, | |
413 { 0 } | |
414 }; | |
415 | |
416 static EbmlSyntax matroska_index[] = { | |
417 { MATROSKA_ID_POINTENTRY, EBML_NEST, sizeof(MatroskaIndex), offsetof(MatroskaDemuxContext,index), {.n=matroska_index_entry} }, | |
418 { 0 } | |
419 }; | |
420 | |
3702 | 421 static EbmlSyntax matroska_simpletag[] = { |
422 { MATROSKA_ID_TAGNAME, EBML_UTF8, 0, offsetof(MatroskaTag,name) }, | |
423 { MATROSKA_ID_TAGSTRING, EBML_UTF8, 0, offsetof(MatroskaTag,string) }, | |
4497
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
424 { MATROSKA_ID_TAGLANG, EBML_STR, 0, offsetof(MatroskaTag,lang), {.s="und"} }, |
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
425 { MATROSKA_ID_TAGDEFAULT, EBML_UINT, 0, offsetof(MatroskaTag,def) }, |
3702 | 426 { MATROSKA_ID_SIMPLETAG, EBML_NEST, sizeof(MatroskaTag), offsetof(MatroskaTag,sub), {.n=matroska_simpletag} }, |
427 { 0 } | |
428 }; | |
429 | |
4495 | 430 static EbmlSyntax matroska_tagtargets[] = { |
431 { MATROSKA_ID_TAGTARGETS_TYPE, EBML_STR, 0, offsetof(MatroskaTagTarget,type) }, | |
432 { MATROSKA_ID_TAGTARGETS_TYPEVALUE, EBML_UINT, 0, offsetof(MatroskaTagTarget,typevalue), {.u=50} }, | |
433 { MATROSKA_ID_TAGTARGETS_TRACKUID, EBML_UINT, 0, offsetof(MatroskaTagTarget,trackuid) }, | |
434 { MATROSKA_ID_TAGTARGETS_CHAPTERUID,EBML_UINT, 0, offsetof(MatroskaTagTarget,chapteruid) }, | |
435 { MATROSKA_ID_TAGTARGETS_ATTACHUID, EBML_UINT, 0, offsetof(MatroskaTagTarget,attachuid) }, | |
436 { 0 } | |
437 }; | |
438 | |
3702 | 439 static EbmlSyntax matroska_tag[] = { |
4495 | 440 { MATROSKA_ID_SIMPLETAG, EBML_NEST, sizeof(MatroskaTag), offsetof(MatroskaTags,tag), {.n=matroska_simpletag} }, |
441 { MATROSKA_ID_TAGTARGETS, EBML_NEST, 0, offsetof(MatroskaTags,target), {.n=matroska_tagtargets} }, | |
3702 | 442 { 0 } |
443 }; | |
444 | |
3638 | 445 static EbmlSyntax matroska_tags[] = { |
4495 | 446 { MATROSKA_ID_TAG, EBML_NEST, sizeof(MatroskaTags), offsetof(MatroskaDemuxContext,tags), {.n=matroska_tag} }, |
3638 | 447 { 0 } |
448 }; | |
449 | |
3644 | 450 static EbmlSyntax matroska_seekhead_entry[] = { |
451 { MATROSKA_ID_SEEKID, EBML_UINT, 0, offsetof(MatroskaSeekhead,id) }, | |
452 { MATROSKA_ID_SEEKPOSITION, EBML_UINT, 0, offsetof(MatroskaSeekhead,pos), {.u=-1} }, | |
453 { 0 } | |
454 }; | |
455 | |
456 static EbmlSyntax matroska_seekhead[] = { | |
457 { MATROSKA_ID_SEEKENTRY, EBML_NEST, sizeof(MatroskaSeekhead), offsetof(MatroskaDemuxContext,seekhead), {.n=matroska_seekhead_entry} }, | |
458 { 0 } | |
459 }; | |
460 | |
3651
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
461 static EbmlSyntax matroska_segment[] = { |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
462 { MATROSKA_ID_INFO, EBML_NEST, 0, 0, {.n=matroska_info } }, |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
463 { MATROSKA_ID_TRACKS, EBML_NEST, 0, 0, {.n=matroska_tracks } }, |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
464 { MATROSKA_ID_ATTACHMENTS, EBML_NEST, 0, 0, {.n=matroska_attachments} }, |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
465 { MATROSKA_ID_CHAPTERS, EBML_NEST, 0, 0, {.n=matroska_chapters } }, |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
466 { MATROSKA_ID_CUES, EBML_NEST, 0, 0, {.n=matroska_index } }, |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
467 { MATROSKA_ID_TAGS, EBML_NEST, 0, 0, {.n=matroska_tags } }, |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
468 { MATROSKA_ID_SEEKHEAD, EBML_NEST, 0, 0, {.n=matroska_seekhead } }, |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
469 { MATROSKA_ID_CLUSTER, EBML_STOP, 0, offsetof(MatroskaDemuxContext,has_cluster_id) }, |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
470 { 0 } |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
471 }; |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
472 |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
473 static EbmlSyntax matroska_segments[] = { |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
474 { MATROSKA_ID_SEGMENT, EBML_NEST, 0, 0, {.n=matroska_segment } }, |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
475 { 0 } |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
476 }; |
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
477 |
3653 | 478 static EbmlSyntax matroska_blockgroup[] = { |
479 { MATROSKA_ID_BLOCK, EBML_BIN, 0, offsetof(MatroskaBlock,bin) }, | |
480 { MATROSKA_ID_SIMPLEBLOCK, EBML_BIN, 0, offsetof(MatroskaBlock,bin) }, | |
481 { MATROSKA_ID_BLOCKDURATION, EBML_UINT, 0, offsetof(MatroskaBlock,duration), {.u=AV_NOPTS_VALUE} }, | |
482 { MATROSKA_ID_BLOCKREFERENCE, EBML_UINT, 0, offsetof(MatroskaBlock,reference) }, | |
5128
2397bd089f70
matroskadec: correctly parse flags for simpleblock frames
aurel
parents:
5058
diff
changeset
|
483 { 1, EBML_UINT, 0, offsetof(MatroskaBlock,non_simple), {.u=1} }, |
3653 | 484 { 0 } |
485 }; | |
486 | |
487 static EbmlSyntax matroska_cluster[] = { | |
488 { MATROSKA_ID_CLUSTERTIMECODE,EBML_UINT,0, offsetof(MatroskaCluster,timecode) }, | |
489 { MATROSKA_ID_BLOCKGROUP, EBML_NEST, sizeof(MatroskaBlock), offsetof(MatroskaCluster,blocks), {.n=matroska_blockgroup} }, | |
490 { MATROSKA_ID_SIMPLEBLOCK, EBML_PASS, sizeof(MatroskaBlock), offsetof(MatroskaCluster,blocks), {.n=matroska_blockgroup} }, | |
3717
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
491 { MATROSKA_ID_CLUSTERPOSITION,EBML_NONE }, |
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
492 { MATROSKA_ID_CLUSTERPREVSIZE,EBML_NONE }, |
3653 | 493 { 0 } |
494 }; | |
495 | |
496 static EbmlSyntax matroska_clusters[] = { | |
497 { MATROSKA_ID_CLUSTER, EBML_NEST, 0, 0, {.n=matroska_cluster} }, | |
3717
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
498 { MATROSKA_ID_INFO, EBML_NONE }, |
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
499 { MATROSKA_ID_CUES, EBML_NONE }, |
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
500 { MATROSKA_ID_TAGS, EBML_NONE }, |
f65dc584662d
matroskadec: list some more ebml IDs found in the wild and that we ignore
aurel
parents:
3713
diff
changeset
|
501 { MATROSKA_ID_SEEKHEAD, EBML_NONE }, |
3653 | 502 { 0 } |
503 }; | |
504 | |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
505 /* |
3692 | 506 * Return: Whether we reached the end of a level in the hierarchy or not. |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
507 */ |
3674 | 508 static int ebml_level_end(MatroskaDemuxContext *matroska) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
509 { |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2657
diff
changeset
|
510 ByteIOContext *pb = matroska->ctx->pb; |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3972
diff
changeset
|
511 int64_t pos = url_ftell(pb); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
512 |
3674 | 513 if (matroska->num_levels > 0) { |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
514 MatroskaLevel *level = &matroska->levels[matroska->num_levels - 1]; |
3674 | 515 if (pos - level->start >= level->length) { |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
516 matroska->num_levels--; |
3674 | 517 return 1; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
518 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
519 } |
3674 | 520 return 0; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
521 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
522 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
523 /* |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
524 * Read: an "EBML number", which is defined as a variable-length |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
525 * array of bytes. The first byte indicates the length by giving a |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
526 * number of 0-bits followed by a one. The position of the first |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
527 * "one" bit inside the first byte indicates the length of this |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
528 * number. |
3692 | 529 * Returns: number of bytes read, < 0 on error |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
530 */ |
3688
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
531 static int ebml_read_num(MatroskaDemuxContext *matroska, ByteIOContext *pb, |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
532 int max_size, uint64_t *number) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
533 { |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
534 int len_mask = 0x80, read = 1, n = 1; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
535 int64_t total = 0; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
536 |
3692 | 537 /* The first byte tells us the length in bytes - get_byte() can normally |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
538 * return 0, but since that's not a valid first ebmlID byte, we can |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
539 * use it safely here to catch EOS. */ |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
540 if (!(total = get_byte(pb))) { |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
541 /* we might encounter EOS here */ |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
542 if (!url_feof(pb)) { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3972
diff
changeset
|
543 int64_t pos = url_ftell(pb); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
544 av_log(matroska->ctx, AV_LOG_ERROR, |
881 | 545 "Read error at pos. %"PRIu64" (0x%"PRIx64")\n", |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
546 pos, pos); |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
547 } |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2273
diff
changeset
|
548 return AVERROR(EIO); /* EOS or actual I/O error */ |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
549 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
550 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
551 /* get the length of the EBML number */ |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
552 while (read <= max_size && !(total & len_mask)) { |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
553 read++; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
554 len_mask >>= 1; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
555 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
556 if (read > max_size) { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3972
diff
changeset
|
557 int64_t pos = url_ftell(pb) - 1; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
558 av_log(matroska->ctx, AV_LOG_ERROR, |
881 | 559 "Invalid EBML number size tag 0x%02x at pos %"PRIu64" (0x%"PRIx64")\n", |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
560 (uint8_t) total, pos, pos); |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
561 return AVERROR_INVALIDDATA; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
562 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
563 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
564 /* read out length */ |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
565 total &= ~len_mask; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
566 while (n++ < read) |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
567 total = (total << 8) | get_byte(pb); |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
568 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
569 *number = total; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
570 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
571 return read; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
572 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
573 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
574 /* |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
575 * Read the next element as an unsigned int. |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
576 * 0 is success, < 0 is failure. |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
577 */ |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
578 static int ebml_read_uint(ByteIOContext *pb, int size, uint64_t *num) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
579 { |
3670
04b4e89c09d6
matroskadec: extract common code out of ebml_read_*()
aurel
parents:
3669
diff
changeset
|
580 int n = 0; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
581 |
3669
836de2dd2615
matroskadec: simplify/cleanup error logging in ebml_read_*()
aurel
parents:
3668
diff
changeset
|
582 if (size < 1 || size > 8) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
583 return AVERROR_INVALIDDATA; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
584 |
3692 | 585 /* big-endian ordering; build up number */ |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
586 *num = 0; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
587 while (n++ < size) |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
588 *num = (*num << 8) | get_byte(pb); |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
589 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
590 return 0; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
591 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
592 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
593 /* |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
594 * Read the next element as a float. |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
595 * 0 is success, < 0 is failure. |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
596 */ |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
597 static int ebml_read_float(ByteIOContext *pb, int size, double *num) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
598 { |
824 | 599 if (size == 4) { |
600 *num= av_int2flt(get_be32(pb)); | |
601 } else if(size==8){ | |
602 *num= av_int2dbl(get_be64(pb)); | |
3669
836de2dd2615
matroskadec: simplify/cleanup error logging in ebml_read_*()
aurel
parents:
3668
diff
changeset
|
603 } else |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
604 return AVERROR_INVALIDDATA; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
605 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
606 return 0; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
607 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
608 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
609 /* |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
610 * Read the next element as an ASCII string. |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
611 * 0 is success, < 0 is failure. |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
612 */ |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
613 static int ebml_read_ascii(ByteIOContext *pb, int size, char **str) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
614 { |
3670
04b4e89c09d6
matroskadec: extract common code out of ebml_read_*()
aurel
parents:
3669
diff
changeset
|
615 av_free(*str); |
3692 | 616 /* EBML strings are usually not 0-terminated, so we allocate one |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
617 * byte more, read the string and NULL-terminate it ourselves. */ |
3670
04b4e89c09d6
matroskadec: extract common code out of ebml_read_*()
aurel
parents:
3669
diff
changeset
|
618 if (!(*str = av_malloc(size + 1))) |
2273
7eb456c4ed8a
Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents:
2264
diff
changeset
|
619 return AVERROR(ENOMEM); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
620 if (get_buffer(pb, (uint8_t *) *str, size) != size) { |
3416 | 621 av_free(*str); |
2274
b21c2af60bc9
Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents:
2273
diff
changeset
|
622 return AVERROR(EIO); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
623 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
624 (*str)[size] = '\0'; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
625 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
626 return 0; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
627 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
628 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
629 /* |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
630 * Read the next element as binary data. |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
631 * 0 is success, < 0 is failure. |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
632 */ |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
633 static int ebml_read_binary(ByteIOContext *pb, int length, EbmlBin *bin) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
634 { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
635 av_free(bin->data); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
636 if (!(bin->data = av_malloc(length))) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
637 return AVERROR(ENOMEM); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
638 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
639 bin->size = length; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
640 bin->pos = url_ftell(pb); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
641 if (get_buffer(pb, bin->data, length) != length) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
642 return AVERROR(EIO); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
643 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
644 return 0; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
645 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
646 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
647 /* |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
648 * Read the next element, but only the header. The contents |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
649 * are supposed to be sub-elements which can be read separately. |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
650 * 0 is success, < 0 is failure. |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
651 */ |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
652 static int ebml_read_master(MatroskaDemuxContext *matroska, int length) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
653 { |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
2657
diff
changeset
|
654 ByteIOContext *pb = matroska->ctx->pb; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
655 MatroskaLevel *level; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
656 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
657 if (matroska->num_levels >= EBML_MAX_DEPTH) { |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
658 av_log(matroska->ctx, AV_LOG_ERROR, |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
659 "File moves beyond max. allowed depth (%d)\n", EBML_MAX_DEPTH); |
2276
3c1e2d519277
Replace all occurrences of AVERROR_NOTSUPP with AVERROR(ENOSYS).
takis
parents:
2274
diff
changeset
|
660 return AVERROR(ENOSYS); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
661 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
662 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
663 level = &matroska->levels[matroska->num_levels++]; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
664 level->start = url_ftell(pb); |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
665 level->length = length; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
666 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
667 return 0; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
668 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
669 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
670 /* |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
671 * Read signed/unsigned "EBML" numbers. |
3692 | 672 * Return: number of bytes processed, < 0 on error |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
673 */ |
3688
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
674 static int matroska_ebmlnum_uint(MatroskaDemuxContext *matroska, |
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
675 uint8_t *data, uint32_t size, uint64_t *num) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
676 { |
3688
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
677 ByteIOContext pb; |
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
678 init_put_byte(&pb, data, size, 0, NULL, NULL, NULL, NULL); |
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
679 return ebml_read_num(matroska, &pb, 8, num); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
680 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
681 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
682 /* |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
683 * Same as above, but signed. |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
684 */ |
3688
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
685 static int matroska_ebmlnum_sint(MatroskaDemuxContext *matroska, |
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
686 uint8_t *data, uint32_t size, int64_t *num) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
687 { |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
688 uint64_t unum; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
689 int res; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
690 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
691 /* read as unsigned number first */ |
3688
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
692 if ((res = matroska_ebmlnum_uint(matroska, data, size, &unum)) < 0) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
693 return res; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
694 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
695 /* make signed (weird way) */ |
3689 | 696 *num = unum - ((1LL << (7*res - 1)) - 1); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
697 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
698 return res; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
699 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
700 |
3632 | 701 static int ebml_parse_elem(MatroskaDemuxContext *matroska, |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
702 EbmlSyntax *syntax, void *data); |
3632 | 703 |
704 static int ebml_parse_id(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, | |
705 uint32_t id, void *data) | |
706 { | |
707 int i; | |
708 for (i=0; syntax[i].id; i++) | |
709 if (id == syntax[i].id) | |
710 break; | |
3745
47807c439186
matroskadec: handle EBML_ID_VOID and EBML_ID_CRC32 in a generic way
aurel
parents:
3717
diff
changeset
|
711 if (!syntax[i].id && id != EBML_ID_VOID && id != EBML_ID_CRC32) |
3632 | 712 av_log(matroska->ctx, AV_LOG_INFO, "Unknown entry 0x%X\n", id); |
713 return ebml_parse_elem(matroska, &syntax[i], data); | |
714 } | |
715 | |
3677
0aed3a6e4e81
matroskadec: new ebml_parse() function, centralize ebml_read_element_id() calls
aurel
parents:
3676
diff
changeset
|
716 static int ebml_parse(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, |
0aed3a6e4e81
matroskadec: new ebml_parse() function, centralize ebml_read_element_id() calls
aurel
parents:
3676
diff
changeset
|
717 void *data) |
0aed3a6e4e81
matroskadec: new ebml_parse() function, centralize ebml_read_element_id() calls
aurel
parents:
3676
diff
changeset
|
718 { |
3690
50c074bc02b4
matroskadec: expand useless ebml_read_element_id() wrapper
aurel
parents:
3689
diff
changeset
|
719 uint64_t id; |
50c074bc02b4
matroskadec: expand useless ebml_read_element_id() wrapper
aurel
parents:
3689
diff
changeset
|
720 int res = ebml_read_num(matroska, matroska->ctx->pb, 4, &id); |
50c074bc02b4
matroskadec: expand useless ebml_read_element_id() wrapper
aurel
parents:
3689
diff
changeset
|
721 id |= 1 << 7*res; |
3677
0aed3a6e4e81
matroskadec: new ebml_parse() function, centralize ebml_read_element_id() calls
aurel
parents:
3676
diff
changeset
|
722 return res < 0 ? res : ebml_parse_id(matroska, syntax, id, data); |
0aed3a6e4e81
matroskadec: new ebml_parse() function, centralize ebml_read_element_id() calls
aurel
parents:
3676
diff
changeset
|
723 } |
0aed3a6e4e81
matroskadec: new ebml_parse() function, centralize ebml_read_element_id() calls
aurel
parents:
3676
diff
changeset
|
724 |
3676
d2ff1b7ad060
matroskadec: rename ebml_parse() to ebml_parse_nest()
aurel
parents:
3675
diff
changeset
|
725 static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax, |
3679
039a28684d43
matroskadec: remove now unused parameter 'once' from ebml_parse_nest()
aurel
parents:
3678
diff
changeset
|
726 void *data) |
3632 | 727 { |
3675
736c7c66234a
matroskadec: don't care about the number of bytes read by ebml_read_element_id()
aurel
parents:
3674
diff
changeset
|
728 int i, res = 0; |
3632 | 729 |
730 for (i=0; syntax[i].id; i++) | |
731 switch (syntax[i].type) { | |
732 case EBML_UINT: | |
733 *(uint64_t *)((char *)data+syntax[i].data_offset) = syntax[i].def.u; | |
734 break; | |
735 case EBML_FLOAT: | |
736 *(double *)((char *)data+syntax[i].data_offset) = syntax[i].def.f; | |
737 break; | |
738 case EBML_STR: | |
739 case EBML_UTF8: | |
740 *(char **)((char *)data+syntax[i].data_offset) = av_strdup(syntax[i].def.s); | |
741 break; | |
742 } | |
743 | |
3679
039a28684d43
matroskadec: remove now unused parameter 'once' from ebml_parse_nest()
aurel
parents:
3678
diff
changeset
|
744 while (!res && !ebml_level_end(matroska)) |
3677
0aed3a6e4e81
matroskadec: new ebml_parse() function, centralize ebml_read_element_id() calls
aurel
parents:
3676
diff
changeset
|
745 res = ebml_parse(matroska, syntax, data); |
3632 | 746 |
747 return res; | |
748 } | |
749 | |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
750 static int ebml_parse_elem(MatroskaDemuxContext *matroska, |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
751 EbmlSyntax *syntax, void *data) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
752 { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
753 ByteIOContext *pb = matroska->ctx->pb; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
754 uint32_t id = syntax->id; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
755 uint64_t length; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
756 int res; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
757 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
758 data = (char *)data + syntax->data_offset; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
759 if (syntax->list_elem_size) { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
760 EbmlList *list = data; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
761 list->elem = av_realloc(list->elem, (list->nb_elem+1)*syntax->list_elem_size); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
762 data = (char*)list->elem + list->nb_elem*syntax->list_elem_size; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
763 memset(data, 0, syntax->list_elem_size); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
764 list->nb_elem++; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
765 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
766 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
767 if (syntax->type != EBML_PASS && syntax->type != EBML_STOP) |
3688
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
768 if ((res = ebml_read_num(matroska, pb, 8, &length)) < 0) |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
769 return res; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
770 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
771 switch (syntax->type) { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
772 case EBML_UINT: res = ebml_read_uint (pb, length, data); break; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
773 case EBML_FLOAT: res = ebml_read_float (pb, length, data); break; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
774 case EBML_STR: |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
775 case EBML_UTF8: res = ebml_read_ascii (pb, length, data); break; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
776 case EBML_BIN: res = ebml_read_binary(pb, length, data); break; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
777 case EBML_NEST: if ((res=ebml_read_master(matroska, length)) < 0) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
778 return res; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
779 if (id == MATROSKA_ID_SEGMENT) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
780 matroska->segment_start = url_ftell(matroska->ctx->pb); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
781 return ebml_parse_nest(matroska, syntax->def.n, data); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
782 case EBML_PASS: return ebml_parse_id(matroska, syntax->def.n, id, data); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
783 case EBML_STOP: *(int *)data = 1; return 1; |
3747
b8f428926617
matroskadec: stop parsing when skipping en element crossing over the end of file
aurel
parents:
3746
diff
changeset
|
784 default: return url_fseek(pb,length,SEEK_CUR)<0 ? AVERROR(EIO) : 0; |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
785 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
786 if (res == AVERROR_INVALIDDATA) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
787 av_log(matroska->ctx, AV_LOG_ERROR, "Invalid element\n"); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
788 else if (res == AVERROR(EIO)) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
789 av_log(matroska->ctx, AV_LOG_ERROR, "Read error\n"); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
790 return res; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
791 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
792 |
3632 | 793 static void ebml_free(EbmlSyntax *syntax, void *data) |
794 { | |
795 int i, j; | |
796 for (i=0; syntax[i].id; i++) { | |
797 void *data_off = (char *)data + syntax[i].data_offset; | |
798 switch (syntax[i].type) { | |
799 case EBML_STR: | |
800 case EBML_UTF8: av_freep(data_off); break; | |
801 case EBML_BIN: av_freep(&((EbmlBin *)data_off)->data); break; | |
802 case EBML_NEST: | |
803 if (syntax[i].list_elem_size) { | |
804 EbmlList *list = data_off; | |
805 char *ptr = list->elem; | |
806 for (j=0; j<list->nb_elem; j++, ptr+=syntax[i].list_elem_size) | |
807 ebml_free(syntax[i].def.n, ptr); | |
808 av_free(list->elem); | |
809 } else | |
810 ebml_free(syntax[i].def.n, data_off); | |
811 default: break; | |
812 } | |
813 } | |
814 } | |
815 | |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
816 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
817 /* |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
818 * Autodetecting... |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
819 */ |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
820 static int matroska_probe(AVProbeData *p) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
821 { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
822 uint64_t total = 0; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
823 int len_mask = 0x80, size = 1, n = 1; |
3768 | 824 static const char probe_data[] = "matroska"; |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
825 |
3692 | 826 /* EBML header? */ |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
827 if (AV_RB32(p->buf) != EBML_ID_HEADER) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
828 return 0; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
829 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
830 /* length of header */ |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
831 total = p->buf[4]; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
832 while (size <= 8 && !(total & len_mask)) { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
833 size++; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
834 len_mask >>= 1; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
835 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
836 if (size > 8) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
837 return 0; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
838 total &= (len_mask - 1); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
839 while (n < size) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
840 total = (total << 8) | p->buf[4 + n++]; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
841 |
3692 | 842 /* Does the probe data contain the whole header? */ |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
843 if (p->buf_size < 4 + size + total) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
844 return 0; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
845 |
3692 | 846 /* The header must contain the document type 'matroska'. For now, |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
847 * we don't parse the whole header but simply check for the |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
848 * availability of that array of characters inside the header. |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
849 * Not fully fool-proof, but good enough. */ |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
850 for (n = 4+size; n <= 4+size+total-(sizeof(probe_data)-1); n++) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
851 if (!memcmp(p->buf+n, probe_data, sizeof(probe_data)-1)) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
852 return AVPROBE_SCORE_MAX; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
853 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
854 return 0; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
855 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
856 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
857 static MatroskaTrack *matroska_find_track_by_num(MatroskaDemuxContext *matroska, |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
858 int num) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
859 { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
860 MatroskaTrack *tracks = matroska->tracks.elem; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
861 int i; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
862 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
863 for (i=0; i < matroska->tracks.nb_elem; i++) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
864 if (tracks[i].num == num) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
865 return &tracks[i]; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
866 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
867 av_log(matroska->ctx, AV_LOG_ERROR, "Invalid track number %d\n", num); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
868 return NULL; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
869 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
870 |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
871 static int matroska_decode_buffer(uint8_t** buf, int* buf_size, |
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
872 MatroskaTrack *track) |
3494
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
873 { |
3642 | 874 MatroskaTrackEncoding *encodings = track->encodings.elem; |
3494
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
875 uint8_t* data = *buf; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
876 int isize = *buf_size; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
877 uint8_t* pkt_data = NULL; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
878 int pkt_size = isize; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
879 int result = 0; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
880 int olen; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
881 |
3642 | 882 switch (encodings[0].compression.algo) { |
3494
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
883 case MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP: |
3642 | 884 return encodings[0].compression.settings.size; |
3494
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
885 case MATROSKA_TRACK_ENCODING_COMP_LZO: |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
886 do { |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
887 olen = pkt_size *= 3; |
4352 | 888 pkt_data = av_realloc(pkt_data, pkt_size+AV_LZO_OUTPUT_PADDING); |
4349
96dba41bad7f
Add av_ prefix to LZO stuff and thus make it officially part of the public API.
reimar
parents:
4331
diff
changeset
|
889 result = av_lzo1x_decode(pkt_data, &olen, data, &isize); |
96dba41bad7f
Add av_ prefix to LZO stuff and thus make it officially part of the public API.
reimar
parents:
4331
diff
changeset
|
890 } while (result==AV_LZO_OUTPUT_FULL && pkt_size<10000000); |
3494
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
891 if (result) |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
892 goto failed; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
893 pkt_size -= olen; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
894 break; |
4206 | 895 #if CONFIG_ZLIB |
3494
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
896 case MATROSKA_TRACK_ENCODING_COMP_ZLIB: { |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
897 z_stream zstream = {0}; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
898 if (inflateInit(&zstream) != Z_OK) |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
899 return -1; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
900 zstream.next_in = data; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
901 zstream.avail_in = isize; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
902 do { |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
903 pkt_size *= 3; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
904 pkt_data = av_realloc(pkt_data, pkt_size); |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
905 zstream.avail_out = pkt_size - zstream.total_out; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
906 zstream.next_out = pkt_data + zstream.total_out; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
907 result = inflate(&zstream, Z_NO_FLUSH); |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
908 } while (result==Z_OK && pkt_size<10000000); |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
909 pkt_size = zstream.total_out; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
910 inflateEnd(&zstream); |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
911 if (result != Z_STREAM_END) |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
912 goto failed; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
913 break; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
914 } |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
915 #endif |
4206 | 916 #if CONFIG_BZLIB |
3494
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
917 case MATROSKA_TRACK_ENCODING_COMP_BZLIB: { |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
918 bz_stream bzstream = {0}; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
919 if (BZ2_bzDecompressInit(&bzstream, 0, 0) != BZ_OK) |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
920 return -1; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
921 bzstream.next_in = data; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
922 bzstream.avail_in = isize; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
923 do { |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
924 pkt_size *= 3; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
925 pkt_data = av_realloc(pkt_data, pkt_size); |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
926 bzstream.avail_out = pkt_size - bzstream.total_out_lo32; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
927 bzstream.next_out = pkt_data + bzstream.total_out_lo32; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
928 result = BZ2_bzDecompress(&bzstream); |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
929 } while (result==BZ_OK && pkt_size<10000000); |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
930 pkt_size = bzstream.total_out_lo32; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
931 BZ2_bzDecompressEnd(&bzstream); |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
932 if (result != BZ_STREAM_END) |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
933 goto failed; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
934 break; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
935 } |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
936 #endif |
3748
6b469866ffda
matroskadec: fail cleanly when the required compression lib is not compiled in
aurel
parents:
3747
diff
changeset
|
937 default: |
6b469866ffda
matroskadec: fail cleanly when the required compression lib is not compiled in
aurel
parents:
3747
diff
changeset
|
938 return -1; |
3494
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
939 } |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
940 |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
941 *buf = pkt_data; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
942 *buf_size = pkt_size; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
943 return 0; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
944 failed: |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
945 av_free(pkt_data); |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
946 return -1; |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
947 } |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
948 |
3894
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
949 static void matroska_fix_ass_packet(MatroskaDemuxContext *matroska, |
3951
9315ab7b1c0d
matroskadec: pass duration as parameter of matroska_fix_ass_packet()
aurel
parents:
3922
diff
changeset
|
950 AVPacket *pkt, uint64_t display_duration) |
3894
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
951 { |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
952 char *line, *layer, *ptr = pkt->data, *end = ptr+pkt->size; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
953 for (; *ptr!=',' && ptr<end-1; ptr++); |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
954 if (*ptr == ',') |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
955 layer = ++ptr; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
956 for (; *ptr!=',' && ptr<end-1; ptr++); |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
957 if (*ptr == ',') { |
3951
9315ab7b1c0d
matroskadec: pass duration as parameter of matroska_fix_ass_packet()
aurel
parents:
3922
diff
changeset
|
958 int64_t end_pts = pkt->pts + display_duration; |
3894
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
959 int sc = matroska->time_scale * pkt->pts / 10000000; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
960 int ec = matroska->time_scale * end_pts / 10000000; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
961 int sh, sm, ss, eh, em, es, len; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
962 sh = sc/360000; sc -= 360000*sh; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
963 sm = sc/ 6000; sc -= 6000*sm; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
964 ss = sc/ 100; sc -= 100*ss; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
965 eh = ec/360000; ec -= 360000*eh; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
966 em = ec/ 6000; ec -= 6000*em; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
967 es = ec/ 100; ec -= 100*es; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
968 *ptr++ = '\0'; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
969 len = 50 + end-ptr + FF_INPUT_BUFFER_PADDING_SIZE; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
970 if (!(line = av_malloc(len))) |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
971 return; |
3953
f1a9ff04eb4b
matroskadec: ass events lines must end with a DOS style EOL
aurel
parents:
3952
diff
changeset
|
972 snprintf(line,len,"Dialogue: %s,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s\r\n", |
3894
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
973 layer, sh, sm, ss, sc, eh, em, es, ec, ptr); |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
974 av_free(pkt->data); |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
975 pkt->data = line; |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
976 pkt->size = strlen(line); |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
977 } |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
978 } |
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
979 |
3954
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
980 static void matroska_merge_packets(AVPacket *out, AVPacket *in) |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
981 { |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
982 out->data = av_realloc(out->data, out->size+in->size); |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
983 memcpy(out->data+out->size, in->data, in->size); |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
984 out->size += in->size; |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
985 av_destruct_packet(in); |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
986 av_free(in); |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
987 } |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
988 |
4495 | 989 static void matroska_convert_tag(AVFormatContext *s, EbmlList *list, |
990 AVMetadata **metadata, char *prefix) | |
3702 | 991 { |
992 MatroskaTag *tags = list->elem; | |
4495 | 993 char key[1024]; |
994 int i; | |
3702 | 995 |
996 for (i=0; i < list->nb_elem; i++) { | |
4497
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
997 const char *lang = strcmp(tags[i].lang, "und") ? tags[i].lang : NULL; |
4495 | 998 if (prefix) snprintf(key, sizeof(key), "%s/%s", prefix, tags[i].name); |
999 else av_strlcpy(key, tags[i].name, sizeof(key)); | |
4497
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
1000 if (tags[i].def || !lang) { |
4495 | 1001 av_metadata_set(metadata, key, tags[i].string); |
1002 if (tags[i].sub.nb_elem) | |
1003 matroska_convert_tag(s, &tags[i].sub, metadata, key); | |
4497
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
1004 } |
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
1005 if (lang) { |
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
1006 av_strlcat(key, "-", sizeof(key)); |
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
1007 av_strlcat(key, lang, sizeof(key)); |
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
1008 av_metadata_set(metadata, key, tags[i].string); |
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
1009 if (tags[i].sub.nb_elem) |
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
1010 matroska_convert_tag(s, &tags[i].sub, metadata, key); |
dc79722bbc25
matroskadec: export language of metadata tags when available
aurel
parents:
4495
diff
changeset
|
1011 } |
4495 | 1012 } |
1013 } | |
1014 | |
1015 static void matroska_convert_tags(AVFormatContext *s) | |
1016 { | |
1017 MatroskaDemuxContext *matroska = s->priv_data; | |
1018 MatroskaTags *tags = matroska->tags.elem; | |
1019 int i, j; | |
1020 | |
1021 for (i=0; i < matroska->tags.nb_elem; i++) { | |
1022 if (tags[i].target.attachuid) { | |
1023 MatroskaAttachement *attachment = matroska->attachments.elem; | |
1024 for (j=0; j<matroska->attachments.nb_elem; j++) | |
1025 if (attachment[j].uid == tags[i].target.attachuid) | |
1026 matroska_convert_tag(s, &tags[i].tag, | |
1027 &attachment[j].stream->metadata, NULL); | |
1028 } else if (tags[i].target.chapteruid) { | |
1029 MatroskaChapter *chapter = matroska->chapters.elem; | |
1030 for (j=0; j<matroska->chapters.nb_elem; j++) | |
1031 if (chapter[j].uid == tags[i].target.chapteruid) | |
1032 matroska_convert_tag(s, &tags[i].tag, | |
1033 &chapter[j].chapter->metadata, NULL); | |
1034 } else if (tags[i].target.trackuid) { | |
1035 MatroskaTrack *track = matroska->tracks.elem; | |
1036 for (j=0; j<matroska->tracks.nb_elem; j++) | |
1037 if (track[j].uid == tags[i].target.trackuid) | |
1038 matroska_convert_tag(s, &tags[i].tag, | |
1039 &track[j].stream->metadata, NULL); | |
1040 } else { | |
5031
1b5282d4863f
matroskadec: prepend TargetType to metadata key name
aurel
parents:
4916
diff
changeset
|
1041 matroska_convert_tag(s, &tags[i].tag, &s->metadata, |
1b5282d4863f
matroskadec: prepend TargetType to metadata key name
aurel
parents:
4916
diff
changeset
|
1042 tags[i].target.type); |
3702 | 1043 } |
1044 } | |
1045 } | |
1046 | |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
1047 static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) |
3644 | 1048 { |
1049 EbmlList *seekhead_list = &matroska->seekhead; | |
1050 MatroskaSeekhead *seekhead = seekhead_list->elem; | |
1051 uint32_t level_up = matroska->level_up; | |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3972
diff
changeset
|
1052 int64_t before_pos = url_ftell(matroska->ctx->pb); |
3644 | 1053 MatroskaLevel level; |
3652
a22da874fc50
matroskadec: use generic parser inside matroska_execute_seekhead()
aurel
parents:
3651
diff
changeset
|
1054 int i; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1055 |
3644 | 1056 for (i=0; i<seekhead_list->nb_elem; i++) { |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3972
diff
changeset
|
1057 int64_t offset = seekhead[i].pos + matroska->segment_start; |
3682
1332d68c8210
matroskadec: remove now useless wrapper ebml_read_seek()
aurel
parents:
3681
diff
changeset
|
1058 |
3644 | 1059 if (seekhead[i].pos <= before_pos |
1060 || seekhead[i].id == MATROSKA_ID_SEEKHEAD | |
1061 || seekhead[i].id == MATROSKA_ID_CLUSTER) | |
1062 continue; | |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1063 |
3646
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1064 /* seek */ |
3682
1332d68c8210
matroskadec: remove now useless wrapper ebml_read_seek()
aurel
parents:
3681
diff
changeset
|
1065 if (url_fseek(matroska->ctx->pb, offset, SEEK_SET) != offset) |
3646
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1066 continue; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1067 |
3692 | 1068 /* We don't want to lose our seekhead level, so we add |
3646
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1069 * a dummy. This is a crude hack. */ |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1070 if (matroska->num_levels == EBML_MAX_DEPTH) { |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1071 av_log(matroska->ctx, AV_LOG_INFO, |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1072 "Max EBML element depth (%d) reached, " |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1073 "cannot parse further.\n", EBML_MAX_DEPTH); |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1074 break; |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1075 } |
885 | 1076 |
3646
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1077 level.start = 0; |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1078 level.length = (uint64_t)-1; |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1079 matroska->levels[matroska->num_levels] = level; |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1080 matroska->num_levels++; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1081 |
3677
0aed3a6e4e81
matroskadec: new ebml_parse() function, centralize ebml_read_element_id() calls
aurel
parents:
3676
diff
changeset
|
1082 ebml_parse(matroska, matroska_segment, matroska); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1083 |
3646
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1084 /* remove dummy level */ |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1085 while (matroska->num_levels) { |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1086 uint64_t length = matroska->levels[--matroska->num_levels].length; |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1087 if (length == (uint64_t)-1) |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1088 break; |
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1089 } |
3644 | 1090 } |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1091 |
3646
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1092 /* seek back */ |
3682
1332d68c8210
matroskadec: remove now useless wrapper ebml_read_seek()
aurel
parents:
3681
diff
changeset
|
1093 url_fseek(matroska->ctx->pb, before_pos, SEEK_SET); |
3646
370243aa26c0
matroskadec: cosmetics: indentation of matroska_execute_seekhead()
aurel
parents:
3645
diff
changeset
|
1094 matroska->level_up = level_up; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1095 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1096 |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
1097 static int matroska_aac_profile(char *codec_id) |
1468 | 1098 { |
3762 | 1099 static const char * const aac_profiles[] = { "MAIN", "LC", "SSR" }; |
1468 | 1100 int profile; |
1101 | |
4001 | 1102 for (profile=0; profile<FF_ARRAY_ELEMS(aac_profiles); profile++) |
1468 | 1103 if (strstr(codec_id, aac_profiles[profile])) |
1104 break; | |
1105 return profile + 1; | |
1106 } | |
1107 | |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
1108 static int matroska_aac_sri(int samplerate) |
1468 | 1109 { |
1110 int sri; | |
1111 | |
4001 | 1112 for (sri=0; sri<FF_ARRAY_ELEMS(ff_mpeg4audio_sample_rates); sri++) |
3201 | 1113 if (ff_mpeg4audio_sample_rates[sri] == samplerate) |
1468 | 1114 break; |
1115 return sri; | |
1116 } | |
1117 | |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
1118 static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1119 { |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1120 MatroskaDemuxContext *matroska = s->priv_data; |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1121 EbmlList *attachements_list = &matroska->attachments; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1122 MatroskaAttachement *attachements; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1123 EbmlList *chapters_list = &matroska->chapters; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1124 MatroskaChapter *chapters; |
3648 | 1125 MatroskaTrack *tracks; |
3637 | 1126 EbmlList *index_list; |
1127 MatroskaIndex *index; | |
4027
11fbf47f3e16
matroskadec: fix index timestamps for some broken files
aurel
parents:
4001
diff
changeset
|
1128 int index_scale = 1; |
4218
4162b8362ed6
matroskadec: ensure we only consider chapters which are properly ordered
aurel
parents:
4206
diff
changeset
|
1129 uint64_t max_start = 0; |
3633
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
1130 Ebml ebml = { 0 }; |
3648 | 1131 AVStream *st; |
3651
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
1132 int i, j; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1133 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1134 matroska->ctx = s; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1135 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1136 /* First read the EBML header. */ |
3678
fd968e67ac6a
matroskadec: directly use ebml_parse() or ebml_parse_id() where it's enough
aurel
parents:
3677
diff
changeset
|
1137 if (ebml_parse(matroska, ebml_syntax, &ebml) |
3633
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
1138 || ebml.version > EBML_VERSION || ebml.max_size > sizeof(uint64_t) |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
1139 || ebml.id_length > sizeof(uint32_t) || strcmp(ebml.doctype, "matroska") |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
1140 || ebml.doctype_version > 2) { |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1141 av_log(matroska->ctx, AV_LOG_ERROR, |
3633
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
1142 "EBML header using unsupported features\n" |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
1143 "(EBML version %"PRIu64", doctype %s, doc version %"PRIu64")\n", |
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
1144 ebml.version, ebml.doctype, ebml.doctype_version); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1145 return AVERROR_NOFMT; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1146 } |
3633
7a44217312bb
matroskadec: use generic ebml parser to parse ebml header
aurel
parents:
3632
diff
changeset
|
1147 ebml_free(ebml_syntax, &ebml); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1148 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1149 /* The next thing is a segment. */ |
3678
fd968e67ac6a
matroskadec: directly use ebml_parse() or ebml_parse_id() where it's enough
aurel
parents:
3677
diff
changeset
|
1150 if (ebml_parse(matroska, matroska_segments, matroska) < 0) |
3651
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
1151 return -1; |
3644 | 1152 matroska_execute_seekhead(matroska); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1153 |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1154 if (matroska->duration) |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1155 matroska->ctx->duration = matroska->duration * matroska->time_scale |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1156 * 1000 / AV_TIME_BASE; |
4492
56ea2b1028fe
matroskadec: use new metadata API to export some simple information
aurel
parents:
4352
diff
changeset
|
1157 av_metadata_set(&s->metadata, "title", matroska->title); |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1158 |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1159 tracks = matroska->tracks.elem; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1160 for (i=0; i < matroska->tracks.nb_elem; i++) { |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1161 MatroskaTrack *track = &tracks[i]; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1162 enum CodecID codec_id = CODEC_ID_NONE; |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1163 EbmlList *encodings_list = &tracks->encodings; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1164 MatroskaTrackEncoding *encodings = encodings_list->elem; |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1165 uint8_t *extradata = NULL; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1166 int extradata_size = 0; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1167 int extradata_offset = 0; |
4249
ffedcd3d4bed
matroskadec: merge ByteIOContext declarations at upper level
aurel
parents:
4248
diff
changeset
|
1168 ByteIOContext b; |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1169 |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1170 /* Apply some sanity checks. */ |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1171 if (track->type != MATROSKA_TRACK_TYPE_VIDEO && |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1172 track->type != MATROSKA_TRACK_TYPE_AUDIO && |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1173 track->type != MATROSKA_TRACK_TYPE_SUBTITLE) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1174 av_log(matroska->ctx, AV_LOG_INFO, |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1175 "Unknown or unsupported track type %"PRIu64"\n", |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1176 track->type); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1177 continue; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1178 } |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1179 if (track->codec_id == NULL) |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1180 continue; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1181 |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1182 if (track->type == MATROSKA_TRACK_TYPE_VIDEO) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1183 if (!track->default_duration) |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1184 track->default_duration = 1000000000/track->video.frame_rate; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1185 if (!track->video.display_width) |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1186 track->video.display_width = track->video.pixel_width; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1187 if (!track->video.display_height) |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1188 track->video.display_height = track->video.pixel_height; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1189 } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1190 if (!track->audio.out_samplerate) |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1191 track->audio.out_samplerate = track->audio.samplerate; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1192 } |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1193 if (encodings_list->nb_elem > 1) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1194 av_log(matroska->ctx, AV_LOG_ERROR, |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1195 "Multiple combined encodings no supported"); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1196 } else if (encodings_list->nb_elem == 1) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1197 if (encodings[0].type || |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1198 (encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP && |
4206 | 1199 #if CONFIG_ZLIB |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1200 encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_ZLIB && |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1201 #endif |
4206 | 1202 #if CONFIG_BZLIB |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1203 encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_BZLIB && |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1204 #endif |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1205 encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO)) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1206 encodings[0].scope = 0; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1207 av_log(matroska->ctx, AV_LOG_ERROR, |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1208 "Unsupported encoding type"); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1209 } else if (track->codec_priv.size && encodings[0].scope&2) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1210 uint8_t *codec_priv = track->codec_priv.data; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1211 int offset = matroska_decode_buffer(&track->codec_priv.data, |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1212 &track->codec_priv.size, |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1213 track); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1214 if (offset < 0) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1215 track->codec_priv.data = NULL; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1216 track->codec_priv.size = 0; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1217 av_log(matroska->ctx, AV_LOG_ERROR, |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1218 "Failed to decode codec private data\n"); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1219 } else if (offset > 0) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1220 track->codec_priv.data = av_malloc(track->codec_priv.size + offset); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1221 memcpy(track->codec_priv.data, |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1222 encodings[0].compression.settings.data, offset); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1223 memcpy(track->codec_priv.data+offset, codec_priv, |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1224 track->codec_priv.size); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1225 track->codec_priv.size += offset; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1226 } |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1227 if (codec_priv != track->codec_priv.data) |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1228 av_free(codec_priv); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1229 } |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1230 } |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1231 |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1232 for(j=0; ff_mkv_codec_tags[j].id != CODEC_ID_NONE; j++){ |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1233 if(!strncmp(ff_mkv_codec_tags[j].str, track->codec_id, |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1234 strlen(ff_mkv_codec_tags[j].str))){ |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1235 codec_id= ff_mkv_codec_tags[j].id; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1236 break; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1237 } |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1238 } |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1239 |
3691 | 1240 st = track->stream = av_new_stream(s, 0); |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1241 if (st == NULL) |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1242 return AVERROR(ENOMEM); |
1024 | 1243 |
3687
494a55f131f3
matroska: expand useless define for MS compat codec id strings
aurel
parents:
3685
diff
changeset
|
1244 if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC") |
3662 | 1245 && track->codec_priv.size >= 40 |
1246 && track->codec_priv.data != NULL) { | |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1247 track->video.fourcc = AV_RL32(track->codec_priv.data + 16); |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
5031
diff
changeset
|
1248 codec_id = ff_codec_get_id(ff_codec_bmp_tags, track->video.fourcc); |
5142
1f237326c8bc
matroskadec: add correct extradata offset for V_MS/VFW/FOURCC tracks
aurel
parents:
5141
diff
changeset
|
1249 extradata_offset = 40; |
3687
494a55f131f3
matroska: expand useless define for MS compat codec id strings
aurel
parents:
3685
diff
changeset
|
1250 } else if (!strcmp(track->codec_id, "A_MS/ACM") |
5250
4b736fd7d0fd
matroskadec: fix handling of A_MS/ACM track with no extradata
aurel
parents:
5142
diff
changeset
|
1251 && track->codec_priv.size >= 14 |
3662 | 1252 && track->codec_priv.data != NULL) { |
4248
6e4ce186db2e
matroskadec: parse the WAVEFORMATEX header and discard it from extradata
aurel
parents:
4218
diff
changeset
|
1253 init_put_byte(&b, track->codec_priv.data, track->codec_priv.size, |
6e4ce186db2e
matroskadec: parse the WAVEFORMATEX header and discard it from extradata
aurel
parents:
4218
diff
changeset
|
1254 URL_RDONLY, NULL, NULL, NULL, NULL); |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
5031
diff
changeset
|
1255 ff_get_wav_header(&b, st->codec, track->codec_priv.size); |
4248
6e4ce186db2e
matroskadec: parse the WAVEFORMATEX header and discard it from extradata
aurel
parents:
4218
diff
changeset
|
1256 codec_id = st->codec->codec_id; |
5250
4b736fd7d0fd
matroskadec: fix handling of A_MS/ACM track with no extradata
aurel
parents:
5142
diff
changeset
|
1257 extradata_offset = FFMIN(track->codec_priv.size, 18); |
3662 | 1258 } else if (!strcmp(track->codec_id, "V_QUICKTIME") |
1259 && (track->codec_priv.size >= 86) | |
1260 && (track->codec_priv.data != NULL)) { | |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1261 track->video.fourcc = AV_RL32(track->codec_priv.data); |
5058
33a244b7ca65
Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents:
5031
diff
changeset
|
1262 codec_id=ff_codec_get_id(codec_movvideo_tags, track->video.fourcc); |
3746 | 1263 } else if (codec_id == CODEC_ID_PCM_S16BE) { |
1264 switch (track->audio.bitdepth) { | |
1265 case 8: codec_id = CODEC_ID_PCM_U8; break; | |
1266 case 24: codec_id = CODEC_ID_PCM_S24BE; break; | |
1267 case 32: codec_id = CODEC_ID_PCM_S32BE; break; | |
1268 } | |
1269 } else if (codec_id == CODEC_ID_PCM_S16LE) { | |
1270 switch (track->audio.bitdepth) { | |
1271 case 8: codec_id = CODEC_ID_PCM_U8; break; | |
1272 case 24: codec_id = CODEC_ID_PCM_S24LE; break; | |
1273 case 32: codec_id = CODEC_ID_PCM_S32LE; break; | |
1274 } | |
1275 } else if (codec_id==CODEC_ID_PCM_F32LE && track->audio.bitdepth==64) { | |
1276 codec_id = CODEC_ID_PCM_F64LE; | |
3662 | 1277 } else if (codec_id == CODEC_ID_AAC && !track->codec_priv.size) { |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1278 int profile = matroska_aac_profile(track->codec_id); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1279 int sri = matroska_aac_sri(track->audio.samplerate); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1280 extradata = av_malloc(5); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1281 if (extradata == NULL) |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1282 return AVERROR(ENOMEM); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1283 extradata[0] = (profile << 3) | ((sri&0x0E) >> 1); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1284 extradata[1] = ((sri&0x01) << 7) | (track->audio.channels<<3); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1285 if (strstr(track->codec_id, "SBR")) { |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1286 sri = matroska_aac_sri(track->audio.out_samplerate); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1287 extradata[2] = 0x56; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1288 extradata[3] = 0xE5; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1289 extradata[4] = 0x80 | (sri<<3); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1290 extradata_size = 5; |
3655 | 1291 } else |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1292 extradata_size = 2; |
3662 | 1293 } else if (codec_id == CODEC_ID_TTA) { |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1294 extradata_size = 30; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1295 extradata = av_mallocz(extradata_size); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1296 if (extradata == NULL) |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1297 return AVERROR(ENOMEM); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1298 init_put_byte(&b, extradata, extradata_size, 1, |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1299 NULL, NULL, NULL, NULL); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1300 put_buffer(&b, "TTA1", 4); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1301 put_le16(&b, 1); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1302 put_le16(&b, track->audio.channels); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1303 put_le16(&b, track->audio.bitdepth); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1304 put_le32(&b, track->audio.out_samplerate); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1305 put_le32(&b, matroska->ctx->duration * track->audio.out_samplerate); |
3662 | 1306 } else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 || |
1307 codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) { | |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1308 extradata_offset = 26; |
3662 | 1309 } else if (codec_id == CODEC_ID_RA_144) { |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1310 track->audio.out_samplerate = 8000; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1311 track->audio.channels = 1; |
3662 | 1312 } else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK || |
1313 codec_id == CODEC_ID_ATRAC3) { | |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1314 init_put_byte(&b, track->codec_priv.data,track->codec_priv.size, |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1315 0, NULL, NULL, NULL, NULL); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1316 url_fskip(&b, 24); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1317 track->audio.coded_framesize = get_be32(&b); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1318 url_fskip(&b, 12); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1319 track->audio.sub_packet_h = get_be16(&b); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1320 track->audio.frame_size = get_be16(&b); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1321 track->audio.sub_packet_size = get_be16(&b); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1322 track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h); |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1323 if (codec_id == CODEC_ID_RA_288) { |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1324 st->codec->block_align = track->audio.coded_framesize; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1325 track->codec_priv.size = 0; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1326 } else { |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1327 st->codec->block_align = track->audio.sub_packet_size; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1328 extradata_offset = 78; |
1531 | 1329 } |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1330 } |
5141 | 1331 track->codec_priv.size -= extradata_offset; |
1531 | 1332 |
3655 | 1333 if (codec_id == CODEC_ID_NONE) |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1334 av_log(matroska->ctx, AV_LOG_INFO, |
3659 | 1335 "Unknown/unsupported CodecID %s.\n", track->codec_id); |
2144 | 1336 |
3912
32652a9c2624
matroskadec: sanitize track time_scale before using it
aurel
parents:
3899
diff
changeset
|
1337 if (track->time_scale < 0.01) |
32652a9c2624
matroskadec: sanitize track time_scale before using it
aurel
parents:
3899
diff
changeset
|
1338 track->time_scale = 1.0; |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1339 av_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000); /* 64 bit pts in ns */ |
2144 | 1340 |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1341 st->codec->codec_id = codec_id; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1342 st->start_time = 0; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1343 if (strcmp(track->language, "und")) |
4492
56ea2b1028fe
matroskadec: use new metadata API to export some simple information
aurel
parents:
4352
diff
changeset
|
1344 av_metadata_set(&st->metadata, "language", track->language); |
4493
40499405ef63
matroskadec: export track name through the metadata API
aurel
parents:
4492
diff
changeset
|
1345 av_metadata_set(&st->metadata, "description", track->name); |
2144 | 1346 |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1347 if (track->flag_default) |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1348 st->disposition |= AV_DISPOSITION_DEFAULT; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1349 |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1350 if (track->default_duration) |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1351 av_reduce(&st->codec->time_base.num, &st->codec->time_base.den, |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1352 track->default_duration, 1000000000, 30000); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1353 |
5251
75a5bf71fad3
matroskadec: don't overwrite extradata already read by ff_get_wav_header()
aurel
parents:
5250
diff
changeset
|
1354 if (!st->codec->extradata) { |
5252 | 1355 if(extradata){ |
1356 st->codec->extradata = extradata; | |
1357 st->codec->extradata_size = extradata_size; | |
1358 } else if(track->codec_priv.data && track->codec_priv.size > 0){ | |
1359 st->codec->extradata = av_mallocz(track->codec_priv.size + | |
1360 FF_INPUT_BUFFER_PADDING_SIZE); | |
1361 if(st->codec->extradata == NULL) | |
1362 return AVERROR(ENOMEM); | |
1363 st->codec->extradata_size = track->codec_priv.size; | |
1364 memcpy(st->codec->extradata, | |
1365 track->codec_priv.data + extradata_offset, | |
1366 track->codec_priv.size); | |
1367 } | |
5251
75a5bf71fad3
matroskadec: don't overwrite extradata already read by ff_get_wav_header()
aurel
parents:
5250
diff
changeset
|
1368 } |
692
b0144ebc71dd
H.264 and Vorbis support in matroska patch by (M«©ns Rullg«©rd |mru inprovide com)
michael
parents:
652
diff
changeset
|
1369 |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1370 if (track->type == MATROSKA_TRACK_TYPE_VIDEO) { |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1371 st->codec->codec_type = CODEC_TYPE_VIDEO; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1372 st->codec->codec_tag = track->video.fourcc; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1373 st->codec->width = track->video.pixel_width; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1374 st->codec->height = track->video.pixel_height; |
3759
27537074f2a9
convert every muxer/demuxer to write/read sample_aspect_ratio from/to
aurel
parents:
3748
diff
changeset
|
1375 av_reduce(&st->sample_aspect_ratio.num, |
27537074f2a9
convert every muxer/demuxer to write/read sample_aspect_ratio from/to
aurel
parents:
3748
diff
changeset
|
1376 &st->sample_aspect_ratio.den, |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1377 st->codec->height * track->video.display_width, |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1378 st->codec-> width * track->video.display_height, |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1379 255); |
5129
87e2b58a305a
matroskadec: disable h264 parser as long as it totally mess up frame type
aurel
parents:
5128
diff
changeset
|
1380 if (st->codec->codec_id != CODEC_ID_H264) |
3649
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1381 st->need_parsing = AVSTREAM_PARSE_HEADERS; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1382 } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) { |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1383 st->codec->codec_type = CODEC_TYPE_AUDIO; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1384 st->codec->sample_rate = track->audio.out_samplerate; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1385 st->codec->channels = track->audio.channels; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1386 } else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) { |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1387 st->codec->codec_type = CODEC_TYPE_SUBTITLE; |
71da9d010bae
matroskadec: cosmetics: indentation of matroska_read_header()
aurel
parents:
3648
diff
changeset
|
1388 } |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1389 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1390 |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1391 attachements = attachements_list->elem; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1392 for (j=0; j<attachements_list->nb_elem; j++) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1393 if (!(attachements[j].filename && attachements[j].mime && |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1394 attachements[j].bin.data && attachements[j].bin.size > 0)) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1395 av_log(matroska->ctx, AV_LOG_ERROR, "incomplete attachment\n"); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1396 } else { |
3691 | 1397 AVStream *st = av_new_stream(s, 0); |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1398 if (st == NULL) |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1399 break; |
4492
56ea2b1028fe
matroskadec: use new metadata API to export some simple information
aurel
parents:
4352
diff
changeset
|
1400 av_metadata_set(&st->metadata, "filename",attachements[j].filename); |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1401 st->codec->codec_id = CODEC_ID_NONE; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1402 st->codec->codec_type = CODEC_TYPE_ATTACHMENT; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1403 st->codec->extradata = av_malloc(attachements[j].bin.size); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1404 if(st->codec->extradata == NULL) |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1405 break; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1406 st->codec->extradata_size = attachements[j].bin.size; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1407 memcpy(st->codec->extradata, attachements[j].bin.data, attachements[j].bin.size); |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1408 |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1409 for (i=0; ff_mkv_mime_tags[i].id != CODEC_ID_NONE; i++) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1410 if (!strncmp(ff_mkv_mime_tags[i].str, attachements[j].mime, |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1411 strlen(ff_mkv_mime_tags[i].str))) { |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1412 st->codec->codec_id = ff_mkv_mime_tags[i].id; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1413 break; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1414 } |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1415 } |
4495 | 1416 attachements[j].stream = st; |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1417 } |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1418 } |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1419 |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1420 chapters = chapters_list->elem; |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1421 for (i=0; i<chapters_list->nb_elem; i++) |
4218
4162b8362ed6
matroskadec: ensure we only consider chapters which are properly ordered
aurel
parents:
4206
diff
changeset
|
1422 if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid |
4162b8362ed6
matroskadec: ensure we only consider chapters which are properly ordered
aurel
parents:
4206
diff
changeset
|
1423 && (max_start==0 || chapters[i].start > max_start)) { |
4492
56ea2b1028fe
matroskadec: use new metadata API to export some simple information
aurel
parents:
4352
diff
changeset
|
1424 chapters[i].chapter = |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1425 ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000}, |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1426 chapters[i].start, chapters[i].end, |
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1427 chapters[i].title); |
4492
56ea2b1028fe
matroskadec: use new metadata API to export some simple information
aurel
parents:
4352
diff
changeset
|
1428 av_metadata_set(&chapters[i].chapter->metadata, |
56ea2b1028fe
matroskadec: use new metadata API to export some simple information
aurel
parents:
4352
diff
changeset
|
1429 "title", chapters[i].title); |
4218
4162b8362ed6
matroskadec: ensure we only consider chapters which are properly ordered
aurel
parents:
4206
diff
changeset
|
1430 max_start = chapters[i].start; |
4162b8362ed6
matroskadec: ensure we only consider chapters which are properly ordered
aurel
parents:
4206
diff
changeset
|
1431 } |
3650
f31190f3d234
matroskadec: move context settings to matroska_read_header()
aurel
parents:
3649
diff
changeset
|
1432 |
3637 | 1433 index_list = &matroska->index; |
1434 index = index_list->elem; | |
4027
11fbf47f3e16
matroskadec: fix index timestamps for some broken files
aurel
parents:
4001
diff
changeset
|
1435 if (index_list->nb_elem |
11fbf47f3e16
matroskadec: fix index timestamps for some broken files
aurel
parents:
4001
diff
changeset
|
1436 && index[0].time > 100000000000000/matroska->time_scale) { |
11fbf47f3e16
matroskadec: fix index timestamps for some broken files
aurel
parents:
4001
diff
changeset
|
1437 av_log(matroska->ctx, AV_LOG_WARNING, "Working around broken index.\n"); |
11fbf47f3e16
matroskadec: fix index timestamps for some broken files
aurel
parents:
4001
diff
changeset
|
1438 index_scale = matroska->time_scale; |
11fbf47f3e16
matroskadec: fix index timestamps for some broken files
aurel
parents:
4001
diff
changeset
|
1439 } |
3637 | 1440 for (i=0; i<index_list->nb_elem; i++) { |
1441 EbmlList *pos_list = &index[i].pos; | |
1442 MatroskaIndexPos *pos = pos_list->elem; | |
1443 for (j=0; j<pos_list->nb_elem; j++) { | |
3636
1f8f906eb49e
matroskadec: return pointer instead of index in matroska_find_track_by_num()
aurel
parents:
3635
diff
changeset
|
1444 MatroskaTrack *track = matroska_find_track_by_num(matroska, |
3637 | 1445 pos[j].track); |
3636
1f8f906eb49e
matroskadec: return pointer instead of index in matroska_find_track_by_num()
aurel
parents:
3635
diff
changeset
|
1446 if (track && track->stream) |
1f8f906eb49e
matroskadec: return pointer instead of index in matroska_find_track_by_num()
aurel
parents:
3635
diff
changeset
|
1447 av_add_index_entry(track->stream, |
3637 | 1448 pos[j].pos + matroska->segment_start, |
4027
11fbf47f3e16
matroskadec: fix index timestamps for some broken files
aurel
parents:
4001
diff
changeset
|
1449 index[i].time/index_scale, 0, 0, |
11fbf47f3e16
matroskadec: fix index timestamps for some broken files
aurel
parents:
4001
diff
changeset
|
1450 AVINDEX_KEYFRAME); |
2012 | 1451 } |
1452 } | |
1453 | |
4495 | 1454 matroska_convert_tags(s); |
1455 | |
3651
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
1456 return 0; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1457 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1458 |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1459 /* |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1460 * Put one packet in an application-supplied AVPacket struct. |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1461 * Returns 0 on success or -1 on failure. |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1462 */ |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1463 static int matroska_deliver_packet(MatroskaDemuxContext *matroska, |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1464 AVPacket *pkt) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1465 { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1466 if (matroska->num_packets > 0) { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1467 memcpy(pkt, matroska->packets[0], sizeof(AVPacket)); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1468 av_free(matroska->packets[0]); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1469 if (matroska->num_packets > 1) { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1470 memmove(&matroska->packets[0], &matroska->packets[1], |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1471 (matroska->num_packets - 1) * sizeof(AVPacket *)); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1472 matroska->packets = |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1473 av_realloc(matroska->packets, (matroska->num_packets - 1) * |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1474 sizeof(AVPacket *)); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1475 } else { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1476 av_freep(&matroska->packets); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1477 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1478 matroska->num_packets--; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1479 return 0; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1480 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1481 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1482 return -1; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1483 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1484 |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1485 /* |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1486 * Free all packets in our internal queue. |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1487 */ |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1488 static void matroska_clear_queue(MatroskaDemuxContext *matroska) |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1489 { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1490 if (matroska->packets) { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1491 int n; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1492 for (n = 0; n < matroska->num_packets; n++) { |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1493 av_free_packet(matroska->packets[n]); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1494 av_free(matroska->packets[n]); |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1495 } |
3696
4aef467adb6b
matroskadec: use av_freep(&x) instead of av_free(x);x=NULL
aurel
parents:
3695
diff
changeset
|
1496 av_freep(&matroska->packets); |
3684
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1497 matroska->num_packets = 0; |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1498 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1499 } |
2350faade9fb
matroskadec: reorder some functions in a more logical order
aurel
parents:
3683
diff
changeset
|
1500 |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
1501 static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, |
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
1502 int size, int64_t pos, uint64_t cluster_time, |
3897
5aa1cbbd79e0
matroskadec: ensure that the timecode added to the index are is the one
aurel
parents:
3894
diff
changeset
|
1503 uint64_t duration, int is_keyframe, |
5aa1cbbd79e0
matroskadec: ensure that the timecode added to the index are is the one
aurel
parents:
3894
diff
changeset
|
1504 int64_t cluster_pos) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1505 { |
3913
253050919116
matroskadec: move timecode calculation a little earlier
aurel
parents:
3912
diff
changeset
|
1506 uint64_t timecode = AV_NOPTS_VALUE; |
3636
1f8f906eb49e
matroskadec: return pointer instead of index in matroska_find_track_by_num()
aurel
parents:
3635
diff
changeset
|
1507 MatroskaTrack *track; |
3899
5901b4ccda4a
matroskadec: remove now useless vstream and is_video_key_frame
aurel
parents:
3898
diff
changeset
|
1508 int res = 0; |
2013
fc0b19650faa
add an intermediate variable (prepare for next patch)
aurel
parents:
2012
diff
changeset
|
1509 AVStream *st; |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1510 AVPacket *pkt; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1511 int16_t block_time; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1512 uint32_t *lace_size = NULL; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1513 int n, flags, laces = 0; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1514 uint64_t num; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1515 |
3688
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
1516 if ((n = matroska_ebmlnum_uint(matroska, data, size, &num)) < 0) { |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1517 av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n"); |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1518 return res; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1519 } |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1520 data += n; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1521 size -= n; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1522 |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1523 track = matroska_find_track_by_num(matroska, num); |
3636
1f8f906eb49e
matroskadec: return pointer instead of index in matroska_find_track_by_num()
aurel
parents:
3635
diff
changeset
|
1524 if (size <= 3 || !track || !track->stream) { |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1525 av_log(matroska->ctx, AV_LOG_INFO, |
3636
1f8f906eb49e
matroskadec: return pointer instead of index in matroska_find_track_by_num()
aurel
parents:
3635
diff
changeset
|
1526 "Invalid stream %"PRIu64" or size %u\n", num, size); |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1527 return res; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1528 } |
3636
1f8f906eb49e
matroskadec: return pointer instead of index in matroska_find_track_by_num()
aurel
parents:
3635
diff
changeset
|
1529 st = track->stream; |
3655 | 1530 if (st->discard >= AVDISCARD_ALL) |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1531 return res; |
1914 | 1532 if (duration == AV_NOPTS_VALUE) |
3636
1f8f906eb49e
matroskadec: return pointer instead of index in matroska_find_track_by_num()
aurel
parents:
3635
diff
changeset
|
1533 duration = track->default_duration / matroska->time_scale; |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1534 |
2185 | 1535 block_time = AV_RB16(data); |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1536 data += 2; |
2188 | 1537 flags = *data++; |
1538 size -= 3; | |
1831 | 1539 if (is_keyframe == -1) |
2415
3aa642c08cde
SimpleBlock keyframe flag is the most significant bit
conrad
parents:
2390
diff
changeset
|
1540 is_keyframe = flags & 0x80 ? PKT_FLAG_KEY : 0; |
2014
de75a5a81f28
add support for seeking to a keyframe instead of a random frame
aurel
parents:
2013
diff
changeset
|
1541 |
3913
253050919116
matroskadec: move timecode calculation a little earlier
aurel
parents:
3912
diff
changeset
|
1542 if (cluster_time != (uint64_t)-1 |
253050919116
matroskadec: move timecode calculation a little earlier
aurel
parents:
3912
diff
changeset
|
1543 && (block_time >= 0 || cluster_time >= -block_time)) { |
253050919116
matroskadec: move timecode calculation a little earlier
aurel
parents:
3912
diff
changeset
|
1544 timecode = cluster_time + block_time; |
3915
7643d7c3fcf6
matroskadec: ensure that overlapping subtitles are not added to the index
aurel
parents:
3914
diff
changeset
|
1545 if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE |
7643d7c3fcf6
matroskadec: ensure that overlapping subtitles are not added to the index
aurel
parents:
3914
diff
changeset
|
1546 && timecode < track->end_timecode) |
7643d7c3fcf6
matroskadec: ensure that overlapping subtitles are not added to the index
aurel
parents:
3914
diff
changeset
|
1547 is_keyframe = 0; /* overlapping subtitles are not key frame */ |
3922
56dc585dcda4
matroskadec: simplify, first_timecode is already in the index
aurel
parents:
3921
diff
changeset
|
1548 if (is_keyframe) |
3913
253050919116
matroskadec: move timecode calculation a little earlier
aurel
parents:
3912
diff
changeset
|
1549 av_add_index_entry(st, cluster_pos, timecode, 0,0,AVINDEX_KEYFRAME); |
3915
7643d7c3fcf6
matroskadec: ensure that overlapping subtitles are not added to the index
aurel
parents:
3914
diff
changeset
|
1550 track->end_timecode = FFMAX(track->end_timecode, timecode+duration); |
3913
253050919116
matroskadec: move timecode calculation a little earlier
aurel
parents:
3912
diff
changeset
|
1551 } |
253050919116
matroskadec: move timecode calculation a little earlier
aurel
parents:
3912
diff
changeset
|
1552 |
3916
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1553 if (matroska->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) { |
3914
f7a20cf5438f
matroskadec: after seeking, skip up to the desired timestamp instead of
aurel
parents:
3913
diff
changeset
|
1554 if (!is_keyframe || timecode < matroska->skip_to_timecode) |
2014
de75a5a81f28
add support for seeking to a keyframe instead of a random frame
aurel
parents:
2013
diff
changeset
|
1555 return res; |
de75a5a81f28
add support for seeking to a keyframe instead of a random frame
aurel
parents:
2013
diff
changeset
|
1556 matroska->skip_to_keyframe = 0; |
de75a5a81f28
add support for seeking to a keyframe instead of a random frame
aurel
parents:
2013
diff
changeset
|
1557 } |
de75a5a81f28
add support for seeking to a keyframe instead of a random frame
aurel
parents:
2013
diff
changeset
|
1558 |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1559 switch ((flags & 0x06) >> 1) { |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1560 case 0x0: /* no lacing */ |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1561 laces = 1; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1562 lace_size = av_mallocz(sizeof(int)); |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1563 lace_size[0] = size; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1564 break; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1565 |
3692 | 1566 case 0x1: /* Xiph lacing */ |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1567 case 0x2: /* fixed-size lacing */ |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1568 case 0x3: /* EBML lacing */ |
3391 | 1569 assert(size>0); // size <=3 is checked before size-=3 above |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1570 laces = (*data) + 1; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1571 data += 1; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1572 size -= 1; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1573 lace_size = av_mallocz(laces * sizeof(int)); |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1574 |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1575 switch ((flags & 0x06) >> 1) { |
3692 | 1576 case 0x1: /* Xiph lacing */ { |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1577 uint8_t temp; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1578 uint32_t total = 0; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1579 for (n = 0; res == 0 && n < laces - 1; n++) { |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1580 while (1) { |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1581 if (size == 0) { |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1582 res = -1; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1583 break; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1584 } |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1585 temp = *data; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1586 lace_size[n] += temp; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1587 data += 1; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1588 size -= 1; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1589 if (temp != 0xff) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1590 break; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1591 } |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1592 total += lace_size[n]; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1593 } |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1594 lace_size[n] = size - total; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1595 break; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1596 } |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1597 |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1598 case 0x2: /* fixed-size lacing */ |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1599 for (n = 0; n < laces; n++) |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1600 lace_size[n] = size / laces; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1601 break; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1602 |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1603 case 0x3: /* EBML lacing */ { |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1604 uint32_t total; |
3688
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
1605 n = matroska_ebmlnum_uint(matroska, data, size, &num); |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1606 if (n < 0) { |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1607 av_log(matroska->ctx, AV_LOG_INFO, |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1608 "EBML block data error\n"); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1609 break; |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1610 } |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1611 data += n; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1612 size -= n; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1613 total = lace_size[0] = num; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1614 for (n = 1; res == 0 && n < laces - 1; n++) { |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1615 int64_t snum; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1616 int r; |
3688
eb4649280c36
matroskadec: implement matroska_ebmlnum_uint() using ebml_read_num()
aurel
parents:
3687
diff
changeset
|
1617 r = matroska_ebmlnum_sint(matroska, data, size, &snum); |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1618 if (r < 0) { |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1619 av_log(matroska->ctx, AV_LOG_INFO, |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1620 "EBML block data error\n"); |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1621 break; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1622 } |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1623 data += r; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1624 size -= r; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1625 lace_size[n] = lace_size[n - 1] + snum; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1626 total += lace_size[n]; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1627 } |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1628 lace_size[n] = size - total; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1629 break; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1630 } |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1631 } |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1632 break; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1633 } |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1634 |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1635 if (res == 0) { |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1636 for (n = 0; n < laces; n++) { |
5513
f4eceb1eb100
mkvdec: Avoid divide-by-zero crash on invalid real audio tracks
conrad
parents:
5252
diff
changeset
|
1637 if ((st->codec->codec_id == CODEC_ID_RA_288 || |
f4eceb1eb100
mkvdec: Avoid divide-by-zero crash on invalid real audio tracks
conrad
parents:
5252
diff
changeset
|
1638 st->codec->codec_id == CODEC_ID_COOK || |
f4eceb1eb100
mkvdec: Avoid divide-by-zero crash on invalid real audio tracks
conrad
parents:
5252
diff
changeset
|
1639 st->codec->codec_id == CODEC_ID_ATRAC3) && |
f4eceb1eb100
mkvdec: Avoid divide-by-zero crash on invalid real audio tracks
conrad
parents:
5252
diff
changeset
|
1640 st->codec->block_align && track->audio.sub_packet_size) { |
2657 | 1641 int a = st->codec->block_align; |
3642 | 1642 int sps = track->audio.sub_packet_size; |
1643 int cfs = track->audio.coded_framesize; | |
1644 int h = track->audio.sub_packet_h; | |
1645 int y = track->audio.sub_packet_cnt; | |
1646 int w = track->audio.frame_size; | |
2657 | 1647 int x; |
1648 | |
3642 | 1649 if (!track->audio.pkt_cnt) { |
2657 | 1650 if (st->codec->codec_id == CODEC_ID_RA_288) |
1651 for (x=0; x<h/2; x++) | |
3642 | 1652 memcpy(track->audio.buf+x*2*w+y*cfs, |
2657 | 1653 data+x*cfs, cfs); |
1654 else | |
1655 for (x=0; x<w/sps; x++) | |
3642 | 1656 memcpy(track->audio.buf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps); |
2657 | 1657 |
3642 | 1658 if (++track->audio.sub_packet_cnt >= h) { |
1659 track->audio.sub_packet_cnt = 0; | |
1660 track->audio.pkt_cnt = h*w / a; | |
2144 | 1661 } |
2657 | 1662 } |
3642 | 1663 while (track->audio.pkt_cnt) { |
2145 | 1664 pkt = av_mallocz(sizeof(AVPacket)); |
2657 | 1665 av_new_packet(pkt, a); |
3642 | 1666 memcpy(pkt->data, track->audio.buf |
1667 + a * (h*w / a - track->audio.pkt_cnt--), a); | |
2657 | 1668 pkt->pos = pos; |
3634
f206f746ff61
matroskadec: store an AVStream pointer instead of a stream index
aurel
parents:
3633
diff
changeset
|
1669 pkt->stream_index = st->index; |
3695
5825a6cfd3bd
matroskadec: replace matroska_queue_packet with a single call to dynarray_add
aurel
parents:
3692
diff
changeset
|
1670 dynarray_add(&matroska->packets,&matroska->num_packets,pkt); |
2144 | 1671 } |
2657 | 1672 } else { |
3642 | 1673 MatroskaTrackEncoding *encodings = track->encodings.elem; |
3494
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
1674 int offset = 0, pkt_size = lace_size[n]; |
3281 | 1675 uint8_t *pkt_data = data; |
1676 | |
3642 | 1677 if (encodings && encodings->scope & 1) { |
3659 | 1678 offset = matroska_decode_buffer(&pkt_data,&pkt_size, track); |
3494
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
1679 if (offset < 0) |
8bf1a8e12b43
matroskadec: move buffer decoding code to a separate function
aurel
parents:
3493
diff
changeset
|
1680 continue; |
3279 | 1681 } |
1682 | |
2657 | 1683 pkt = av_mallocz(sizeof(AVPacket)); |
1684 /* XXX: prevent data copy... */ | |
3281 | 1685 if (av_new_packet(pkt, pkt_size+offset) < 0) { |
3415 | 1686 av_free(pkt); |
2657 | 1687 res = AVERROR(ENOMEM); |
1688 break; | |
1689 } | |
3279 | 1690 if (offset) |
3642 | 1691 memcpy (pkt->data, encodings->compression.settings.data, offset); |
3281 | 1692 memcpy (pkt->data+offset, pkt_data, pkt_size); |
2657 | 1693 |
3493 | 1694 if (pkt_data != data) |
1695 av_free(pkt_data); | |
1696 | |
2657 | 1697 if (n == 0) |
1698 pkt->flags = is_keyframe; | |
3634
f206f746ff61
matroskadec: store an AVStream pointer instead of a stream index
aurel
parents:
3633
diff
changeset
|
1699 pkt->stream_index = st->index; |
2657 | 1700 |
1701 pkt->pts = timecode; | |
1702 pkt->pos = pos; | |
3952
9808dea139a1
matroskadec: set duration only for CODEC_ID_TEXT subtitles
aurel
parents:
3951
diff
changeset
|
1703 if (st->codec->codec_id == CODEC_ID_TEXT) |
3892
8f1928b41f45
matroska: subtitle display duration must be stored in pkt->convergence_duration
aurel
parents:
3786
diff
changeset
|
1704 pkt->convergence_duration = duration; |
3952
9808dea139a1
matroskadec: set duration only for CODEC_ID_TEXT subtitles
aurel
parents:
3951
diff
changeset
|
1705 else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE) |
3892
8f1928b41f45
matroska: subtitle display duration must be stored in pkt->convergence_duration
aurel
parents:
3786
diff
changeset
|
1706 pkt->duration = duration; |
2657 | 1707 |
3894
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
1708 if (st->codec->codec_id == CODEC_ID_SSA) |
3951
9315ab7b1c0d
matroskadec: pass duration as parameter of matroska_fix_ass_packet()
aurel
parents:
3922
diff
changeset
|
1709 matroska_fix_ass_packet(matroska, pkt, duration); |
3894
30c8c9f53b9d
matroskadec: fix ASS subtitle track packets before emitting them
aurel
parents:
3892
diff
changeset
|
1710 |
3954
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
1711 if (matroska->prev_pkt && |
3971
eed7b7cb02a9
matroskadec: don't merge packets which have no timestamp
aurel
parents:
3954
diff
changeset
|
1712 timecode != AV_NOPTS_VALUE && |
3954
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
1713 matroska->prev_pkt->pts == timecode && |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
1714 matroska->prev_pkt->stream_index == st->index) |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
1715 matroska_merge_packets(matroska->prev_pkt, pkt); |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
1716 else { |
3972 | 1717 dynarray_add(&matroska->packets,&matroska->num_packets,pkt); |
3954
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
1718 matroska->prev_pkt = pkt; |
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
1719 } |
2657 | 1720 } |
1721 | |
1722 if (timecode != AV_NOPTS_VALUE) | |
1723 timecode = duration ? timecode + duration : AV_NOPTS_VALUE; | |
1830
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1724 data += lace_size[n]; |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1725 } |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1726 } |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1727 |
ae69f36fe685
cosmetics: fix indentation of the new matroska_parse_block() function
aurel
parents:
1829
diff
changeset
|
1728 av_free(lace_size); |
3899
5901b4ccda4a
matroskadec: remove now useless vstream and is_video_key_frame
aurel
parents:
3898
diff
changeset
|
1729 return res; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1730 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1731 |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
1732 static int matroska_parse_cluster(MatroskaDemuxContext *matroska) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1733 { |
3653 | 1734 MatroskaCluster cluster = { 0 }; |
1735 EbmlList *blocks_list; | |
1736 MatroskaBlock *blocks; | |
3897
5aa1cbbd79e0
matroskadec: ensure that the timecode added to the index are is the one
aurel
parents:
3894
diff
changeset
|
1737 int i, res; |
3973
549a09cf23fe
Remove offset_t typedef and use int64_t directly instead.
diego
parents:
3972
diff
changeset
|
1738 int64_t pos = url_ftell(matroska->ctx->pb); |
3954
0ebebd2ba034
matroskadec: merge ASS events which share the same pts in the same AVPavket
aurel
parents:
3953
diff
changeset
|
1739 matroska->prev_pkt = NULL; |
3680
8aa88bbf5f01
matroskadec: don't try to re-read already parsed ID in matroska_parse_cluster()
aurel
parents:
3679
diff
changeset
|
1740 if (matroska->has_cluster_id){ |
3692 | 1741 /* For the first cluster we parse, its ID was already read as |
3680
8aa88bbf5f01
matroskadec: don't try to re-read already parsed ID in matroska_parse_cluster()
aurel
parents:
3679
diff
changeset
|
1742 part of matroska_read_header(), so don't read it again */ |
8aa88bbf5f01
matroskadec: don't try to re-read already parsed ID in matroska_parse_cluster()
aurel
parents:
3679
diff
changeset
|
1743 res = ebml_parse_id(matroska, matroska_clusters, |
8aa88bbf5f01
matroskadec: don't try to re-read already parsed ID in matroska_parse_cluster()
aurel
parents:
3679
diff
changeset
|
1744 MATROSKA_ID_CLUSTER, &cluster); |
3773
2533332ca752
matroskadec: on the fly index construction for index-less files
aurel
parents:
3772
diff
changeset
|
1745 pos -= 4; /* sizeof the ID which was already read */ |
3680
8aa88bbf5f01
matroskadec: don't try to re-read already parsed ID in matroska_parse_cluster()
aurel
parents:
3679
diff
changeset
|
1746 matroska->has_cluster_id = 0; |
8aa88bbf5f01
matroskadec: don't try to re-read already parsed ID in matroska_parse_cluster()
aurel
parents:
3679
diff
changeset
|
1747 } else |
8aa88bbf5f01
matroskadec: don't try to re-read already parsed ID in matroska_parse_cluster()
aurel
parents:
3679
diff
changeset
|
1748 res = ebml_parse(matroska, matroska_clusters, &cluster); |
3653 | 1749 blocks_list = &cluster.blocks; |
1750 blocks = blocks_list->elem; | |
3713
b337fe64a31f
matroskadec: parse available blocks even when cluster parsing failed
aurel
parents:
3702
diff
changeset
|
1751 for (i=0; i<blocks_list->nb_elem; i++) |
5128
2397bd089f70
matroskadec: correctly parse flags for simpleblock frames
aurel
parents:
5058
diff
changeset
|
1752 if (blocks[i].bin.size > 0) { |
2397bd089f70
matroskadec: correctly parse flags for simpleblock frames
aurel
parents:
5058
diff
changeset
|
1753 int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1; |
3653 | 1754 res=matroska_parse_block(matroska, |
1755 blocks[i].bin.data, blocks[i].bin.size, | |
1756 blocks[i].bin.pos, cluster.timecode, | |
5128
2397bd089f70
matroskadec: correctly parse flags for simpleblock frames
aurel
parents:
5058
diff
changeset
|
1757 blocks[i].duration, is_keyframe, |
3897
5aa1cbbd79e0
matroskadec: ensure that the timecode added to the index are is the one
aurel
parents:
3894
diff
changeset
|
1758 pos); |
5128
2397bd089f70
matroskadec: correctly parse flags for simpleblock frames
aurel
parents:
5058
diff
changeset
|
1759 } |
3653 | 1760 ebml_free(matroska_cluster, &cluster); |
3771
9e9dce9660e4
matroskadec: move setting of matroska->done inside matroska_parse_cluster()
aurel
parents:
3768
diff
changeset
|
1761 if (res < 0) matroska->done = 1; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1762 return res; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1763 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1764 |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
1765 static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1766 { |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1767 MatroskaDemuxContext *matroska = s->priv_data; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1768 |
1899 | 1769 while (matroska_deliver_packet(matroska, pkt)) { |
1900 | 1770 if (matroska->done) |
4543
e7e7b9f7edf4
matroskadec: return AVERROR_EOF upon detection of end of file
aurel
parents:
4497
diff
changeset
|
1771 return AVERROR_EOF; |
3771
9e9dce9660e4
matroskadec: move setting of matroska->done inside matroska_parse_cluster()
aurel
parents:
3768
diff
changeset
|
1772 matroska_parse_cluster(matroska); |
1899 | 1773 } |
1774 | |
1775 return 0; | |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1776 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1777 |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
1778 static int matroska_read_seek(AVFormatContext *s, int stream_index, |
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
1779 int64_t timestamp, int flags) |
2012 | 1780 { |
1781 MatroskaDemuxContext *matroska = s->priv_data; | |
3916
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1782 MatroskaTrack *tracks = matroska->tracks.elem; |
2012 | 1783 AVStream *st = s->streams[stream_index]; |
3916
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1784 int i, index, index_sub, index_min; |
2012 | 1785 |
3922
56dc585dcda4
matroskadec: simplify, first_timecode is already in the index
aurel
parents:
3921
diff
changeset
|
1786 if (!st->nb_index_entries) |
56dc585dcda4
matroskadec: simplify, first_timecode is already in the index
aurel
parents:
3921
diff
changeset
|
1787 return 0; |
56dc585dcda4
matroskadec: simplify, first_timecode is already in the index
aurel
parents:
3921
diff
changeset
|
1788 timestamp = FFMAX(timestamp, st->index_entries[0].timestamp); |
3772
7814581e98ff
matroskadec: don't try to seek to negative timestamp
aurel
parents:
3771
diff
changeset
|
1789 |
3785
fd49d42b918f
matroskadec: seek to the last position known in the index before resorting to
aurel
parents:
3782
diff
changeset
|
1790 if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) { |
3922
56dc585dcda4
matroskadec: simplify, first_timecode is already in the index
aurel
parents:
3921
diff
changeset
|
1791 url_fseek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET); |
3786 | 1792 while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) { |
1793 matroska_clear_queue(matroska); | |
1794 if (matroska_parse_cluster(matroska) < 0) | |
1795 break; | |
1796 } | |
3785
fd49d42b918f
matroskadec: seek to the last position known in the index before resorting to
aurel
parents:
3782
diff
changeset
|
1797 } |
3774
fa5cc40e0164
matroskadec: full seeking support in index-less files
aurel
parents:
3773
diff
changeset
|
1798 |
fa5cc40e0164
matroskadec: full seeking support in index-less files
aurel
parents:
3773
diff
changeset
|
1799 matroska_clear_queue(matroska); |
2012 | 1800 if (index < 0) |
1801 return 0; | |
1802 | |
3916
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1803 index_min = index; |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1804 for (i=0; i < matroska->tracks.nb_elem; i++) { |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1805 tracks[i].end_timecode = 0; |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1806 if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1807 && !tracks[i].stream->discard != AVDISCARD_ALL) { |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1808 index_sub = av_index_search_timestamp(tracks[i].stream, st->index_entries[index].timestamp, AVSEEK_FLAG_BACKWARD); |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1809 if (index_sub >= 0 |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1810 && st->index_entries[index_sub].pos < st->index_entries[index_min].pos |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1811 && st->index_entries[index].timestamp - st->index_entries[index_sub].timestamp < 30000000000/matroska->time_scale) |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1812 index_min = index_sub; |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1813 } |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1814 } |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1815 |
4a7174c2b34e
matroskadec: demux relevant subtitle packets after a seek
aurel
parents:
3915
diff
changeset
|
1816 url_fseek(s->pb, st->index_entries[index_min].pos, SEEK_SET); |
2014
de75a5a81f28
add support for seeking to a keyframe instead of a random frame
aurel
parents:
2013
diff
changeset
|
1817 matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY); |
3914
f7a20cf5438f
matroskadec: after seeking, skip up to the desired timestamp instead of
aurel
parents:
3913
diff
changeset
|
1818 matroska->skip_to_timecode = st->index_entries[index].timestamp; |
3775 | 1819 matroska->done = 0; |
3462 | 1820 av_update_cur_dts(s, st, st->index_entries[index].timestamp); |
2012 | 1821 return 0; |
1822 } | |
1823 | |
3673
b0188029f916
matroskadec: cosmetics: consistent style for function declarations
aurel
parents:
3672
diff
changeset
|
1824 static int matroska_read_close(AVFormatContext *s) |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1825 { |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1826 MatroskaDemuxContext *matroska = s->priv_data; |
3642 | 1827 MatroskaTrack *tracks = matroska->tracks.elem; |
3656 | 1828 int n; |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1829 |
2871
b2f261fccb0b
move internal queue freeing code in its own function
aurel
parents:
2870
diff
changeset
|
1830 matroska_clear_queue(matroska); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1831 |
3642 | 1832 for (n=0; n < matroska->tracks.nb_elem; n++) |
1833 if (tracks[n].type == MATROSKA_TRACK_TYPE_AUDIO) | |
1834 av_free(tracks[n].audio.buf); | |
3651
57c346e50442
matroskadec: use generic parser to parse matroska from toplevel
aurel
parents:
3650
diff
changeset
|
1835 ebml_free(matroska_segment, matroska); |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1836 |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1837 return 0; |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1838 } |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1839 |
1169 | 1840 AVInputFormat matroska_demuxer = { |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1841 "matroska", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3422
diff
changeset
|
1842 NULL_IF_CONFIG_SMALL("Matroska file format"), |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1843 sizeof(MatroskaDemuxContext), |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1844 matroska_probe, |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1845 matroska_read_header, |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1846 matroska_read_packet, |
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1847 matroska_read_close, |
2012 | 1848 matroska_read_seek, |
4618
5b9eddbee9c4
Add some basic metadata conversion tables for matroska and asf.
aurel
parents:
4543
diff
changeset
|
1849 .metadata_conv = ff_mkv_metadata_conv, |
380
9416dc106e06
matroska demuxer by ("Ronald S. Bultje" <R dot S dot Bultje at students dot uu dot nl>)
michael
parents:
diff
changeset
|
1850 }; |