Mercurial > mplayer.hg
annotate libmpdemux/demux_mkv.cpp @ 11553:656932ca58ab
vidix_get_image() fix
author | michael |
---|---|
date | Wed, 03 Dec 2003 17:44:15 +0000 |
parents | 3abf5b7cb308 |
children | 32411c15cebc |
rev | line source |
---|---|
10860
472c5531b695
Improved backwards seeking for small seek steps. Patch by matthieu <mat100@ifrance.com>.
mosu
parents:
10845
diff
changeset
|
1 // Matroska demuxer |
472c5531b695
Improved backwards seeking for small seek steps. Patch by matthieu <mat100@ifrance.com>.
mosu
parents:
10845
diff
changeset
|
2 // written by Moritz Bunkus <moritz@bunkus.org> |
472c5531b695
Improved backwards seeking for small seek steps. Patch by matthieu <mat100@ifrance.com>.
mosu
parents:
10845
diff
changeset
|
3 // License: GPL of course ;) |
472c5531b695
Improved backwards seeking for small seek steps. Patch by matthieu <mat100@ifrance.com>.
mosu
parents:
10845
diff
changeset
|
4 |
472c5531b695
Improved backwards seeking for small seek steps. Patch by matthieu <mat100@ifrance.com>.
mosu
parents:
10845
diff
changeset
|
5 // $Id$ |
472c5531b695
Improved backwards seeking for small seek steps. Patch by matthieu <mat100@ifrance.com>.
mosu
parents:
10845
diff
changeset
|
6 |
10024 | 7 extern "C" { |
8 #include "config.h" | |
9 } | |
10 | |
11 #ifdef HAVE_MATROSKA | |
12 | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
13 #include <vector> |
10024 | 14 |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
15 #include <ebml/EbmlHead.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
16 #include <ebml/EbmlSubHead.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
17 #include <ebml/EbmlStream.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
18 #include <ebml/EbmlContexts.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
19 #include <ebml/EbmlVersion.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
20 #include <ebml/StdIOCallback.h> |
10024 | 21 |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
22 #include <matroska/KaxVersion.h> |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
23 |
10437
3c7cd3196cf4
Fixed spelling mistakes that were present in libmatroska until now.
mosu
parents:
10434
diff
changeset
|
24 #include <matroska/KaxAttachments.h> |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
25 #include <matroska/KaxBlock.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
26 #include <matroska/KaxBlockData.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
27 #include <matroska/KaxChapters.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
28 #include <matroska/KaxCluster.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
29 #include <matroska/KaxClusterData.h> |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
30 #if LIBMATROSKA_VERSION >= 000503 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
31 #include <matroska/KaxContentEncoding.h> |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
32 #endif |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
33 #include <matroska/KaxContexts.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
34 #include <matroska/KaxCues.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
35 #include <matroska/KaxCuesData.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
36 #include <matroska/KaxInfo.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
37 #include <matroska/KaxInfoData.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
38 #include <matroska/KaxSeekHead.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
39 #include <matroska/KaxSegment.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
40 #include <matroska/KaxTracks.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
41 #include <matroska/KaxTrackAudio.h> |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
42 #include <matroska/KaxTrackVideo.h> |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
43 #include <matroska/KaxTrackEntryData.h> |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
44 #include <matroska/FileKax.h> |
10024 | 45 |
11139
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
46 extern "C" { |
11154 | 47 #include <ctype.h> |
11139
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
48 #include <stdlib.h> |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
49 #include <stdio.h> |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
50 #include <string.h> |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
51 |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
52 #ifdef HAVE_ZLIB |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
53 #include <zlib.h> |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
54 #endif |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
55 |
11139
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
56 #include "../mp_msg.h" |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
57 #include "../help_mp.h" |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
58 #include "stream.h" |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
59 #include "demuxer.h" |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
60 #include "stheader.h" |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
61 |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
62 #include "../subreader.h" |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
63 #include "../libvo/sub.h" |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
64 |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
65 } |
970e9c6471f4
Fix for compilation on mingw32/cygwin. Patch by Goodwu <goodwu@21cn.com>.
mosu
parents:
11114
diff
changeset
|
66 |
10024 | 67 #include "matroska.h" |
68 | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
69 using namespace libebml; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
70 using namespace libmatroska; |
10024 | 71 using namespace std; |
72 | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
73 #if LIBEBML_VERSION < 000500 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
74 #error libebml version too old - need at least 0.5.0 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
75 #endif |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
76 |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
77 // for e.g. "-slang ger" |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
78 extern char *dvdsub_lang; |
10167
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
79 extern char *audio_lang; |
11260 | 80 // for "-chapter x-y" |
81 extern int dvd_chapter; | |
82 extern int dvd_last_chapter; | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
83 |
10024 | 84 // default values for Matroska elements |
85 #define MKVD_TIMECODESCALE 1000000 // 1000000 = 1ms | |
86 | |
11154 | 87 #define MKV_SUBTYPE_TEXT 1 |
88 #define MKV_SUBTYPE_SSA 2 | |
89 #define MKV_SUBTYPE_VOBSUB 3 | |
90 | |
91 #define MKV_SUBCOMPRESSION_NONE 0 | |
92 #define MKV_SUBCOMPRESSION_ZLIB 1 | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
93 |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
94 #define safefree(m) { if (m != NULL) free(m); } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
95 void *safemalloc(int bytes) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
96 void *dst; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
97 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
98 dst = malloc(bytes); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
99 if (dst == NULL) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
100 mp_msg(MSGT_DEMUX, MSGL_FATAL, "[mkv] Could not allocate %d bytes of " |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
101 "memory.\n", bytes); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
102 exit(1); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
103 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
104 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
105 return dst; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
106 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
107 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
108 void *safememdup(const void *src, int bytes) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
109 void *dst; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
110 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
111 dst = safemalloc(bytes); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
112 memcpy(dst, src, bytes); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
113 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
114 return dst; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
115 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
116 |
10024 | 117 class mpstream_io_callback: public IOCallback { |
118 private: | |
119 stream_t *s; | |
120 public: | |
121 mpstream_io_callback(stream_t *stream); | |
122 | |
123 virtual uint32 read(void *buffer, size_t size); | |
124 virtual void setFilePointer(int64 offset, seek_mode mode = seek_beginning); | |
125 virtual size_t write(const void *buffer, size_t size); | |
126 virtual uint64 getFilePointer(); | |
127 virtual void close(); | |
128 }; | |
129 | |
130 mpstream_io_callback::mpstream_io_callback(stream_t *stream) { | |
131 s = stream; | |
132 } | |
133 | |
134 uint32 mpstream_io_callback::read(void *buffer, size_t size) { | |
135 uint32_t result; | |
136 | |
137 result = stream_read(s, (char *)buffer, size); | |
138 | |
139 return result; | |
140 } | |
141 | |
142 void mpstream_io_callback::setFilePointer(int64 offset, seek_mode mode) { | |
143 int64 new_pos; | |
144 | |
145 if (mode == seek_beginning) | |
146 new_pos = offset + s->start_pos; | |
147 else if (mode == seek_end) | |
148 new_pos = s->end_pos - offset; | |
149 else | |
150 new_pos = s->pos + offset; | |
151 | |
152 if (new_pos > s->end_pos) { | |
153 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek warning: new_pos %lld > end_pos " | |
154 "%lld\n", new_pos, s->end_pos); | |
155 return; | |
156 } | |
157 | |
158 stream_seek(s, new_pos); | |
159 } | |
160 | |
161 size_t mpstream_io_callback::write(const void */*buffer*/, size_t /*size*/) { | |
162 return 0; | |
163 } | |
164 | |
165 uint64 mpstream_io_callback::getFilePointer() { | |
166 return s->pos - s->buf_len + s->buf_pos; | |
167 } | |
168 | |
169 void mpstream_io_callback::close() { | |
170 } | |
171 | |
172 typedef struct mkv_index_entry { | |
173 uint64_t timecode, filepos; | |
174 int is_key; | |
175 } mkv_index_entry_t; | |
176 | |
177 typedef struct mkv_track_index { | |
178 uint32_t tnum; | |
179 int num_entries; | |
180 mkv_index_entry_t *entries; | |
181 } mkv_track_index_t; | |
182 | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
183 typedef struct { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
184 uint32_t order, type, scope; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
185 uint32_t comp_algo; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
186 unsigned char *comp_settings; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
187 uint32_t comp_settings_len; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
188 uint32_t enc_algo, sig_algo, sig_hash_algo; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
189 unsigned char *enc_keyid, *sig_keyid, *signature; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
190 uint32_t enc_keyid_len, sig_keyid_len, signature_len; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
191 } mkv_content_encoding_t; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
192 |
11260 | 193 typedef struct { |
194 int64_t start, end; | |
195 } mkv_chapter_t; | |
196 | |
10024 | 197 typedef struct mkv_track { |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
198 uint32_t tnum, xid; |
10024 | 199 |
200 char *codec_id; | |
201 int ms_compat; | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
202 char *language; |
10024 | 203 |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
204 char type; // 'v' = video, 'a' = audio, 's' = subs |
10024 | 205 |
206 char v_fourcc[5]; | |
10081
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
207 uint32_t v_width, v_height, v_dwidth, v_dheight; |
10024 | 208 float v_frate; |
209 | |
10125 | 210 uint32_t a_formattag; |
10024 | 211 uint32_t a_channels, a_bps; |
212 float a_sfreq; | |
213 | |
214 int default_track; | |
215 | |
216 void *private_data; | |
217 unsigned int private_size; | |
218 | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
219 // For Vorbis audio |
10024 | 220 unsigned char *headers[3]; |
221 uint32_t header_sizes[3]; | |
222 | |
223 int ok; | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
224 |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
225 // Stuff for RealMedia |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
226 bool realmedia; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
227 demux_packet_t *rm_dp; |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
228 int rm_seqnum, rv_kf_base, rv_kf_pts; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
229 float rv_pts; // previous video timestamp |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
230 float ra_pts; // previous audio timestamp |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
231 |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
232 // Stuff for QuickTime |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
233 bool fix_i_bps; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
234 float qt_last_a_pts; |
11154 | 235 |
236 // Stuff for VobSubs | |
237 mkv_sh_sub_t sh_sub; | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
238 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
239 // Generic content encoding support. |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
240 vector<mkv_content_encoding_t> *c_encodings; |
10024 | 241 } mkv_track_t; |
242 | |
243 typedef struct mkv_demuxer { | |
244 float duration, last_pts; | |
245 uint64_t last_filepos; | |
246 | |
247 mkv_track_t **tracks; | |
248 int num_tracks; | |
249 mkv_track_t *video, *audio, *subs_track; | |
250 | |
10283
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
251 uint64_t tc_scale, cluster_tc, first_tc; |
10024 | 252 |
253 mpstream_io_callback *in; | |
254 | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
255 uint64_t clear_subs_at[SUB_MAX_TEXT]; |
10024 | 256 |
257 subtitle subs; | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
258 int subtitle_type; |
10024 | 259 |
260 EbmlStream *es; | |
261 EbmlElement *saved_l1, *saved_l2; | |
262 KaxSegment *segment; | |
263 KaxCluster *cluster; | |
264 | |
265 mkv_track_index_t *index; | |
266 int num_indexes, cues_found, cues_searched; | |
267 int64_t *cluster_positions; | |
268 int num_cluster_pos; | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
269 vector<uint64_t> *parsed_seekheads; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
270 vector<uint64_t> *parsed_cues; |
10024 | 271 |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
272 int64_t skip_to_timecode; |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
273 bool v_skip_to_keyframe, a_skip_to_keyframe; |
11260 | 274 |
275 vector<mkv_chapter_t> *chapters; // No support for nested chapters atm. | |
276 uint64_t stop_timecode; | |
10024 | 277 } mkv_demuxer_t; |
278 | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
279 typedef struct { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
280 uint32_t chunks; // number of chunks |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
281 uint32_t timestamp; // timestamp from packet header |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
282 uint32_t len; // length of actual data |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
283 uint32_t chunktab; // offset to chunk offset array |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
284 } dp_hdr_t; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
285 |
10438
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
286 #if __GNUC__ == 2 |
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
287 #pragma pack(2) |
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
288 #else |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
289 #pragma pack(push,2) |
10438
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
290 #endif |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
291 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
292 typedef struct { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
293 uint32_t size; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
294 uint32_t fourcc1; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
295 uint32_t fourcc2; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
296 uint16_t width; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
297 uint16_t height; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
298 uint16_t bpp; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
299 uint32_t unknown1; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
300 uint32_t fps; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
301 uint32_t type1; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
302 uint32_t type2; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
303 } real_video_props_t; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
304 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
305 typedef struct { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
306 uint32_t fourcc1; // '.', 'r', 'a', 0xfd |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
307 uint16_t version1; // 4 or 5 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
308 uint16_t unknown1; // 00 000 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
309 uint32_t fourcc2; // .ra4 or .ra5 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
310 uint32_t unknown2; // ??? |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
311 uint16_t version2; // 4 or 5 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
312 uint32_t header_size; // == 0x4e |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
313 uint16_t flavor; // codec flavor id |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
314 uint32_t coded_frame_size; // coded frame size |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
315 uint32_t unknown3; // big number |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
316 uint32_t unknown4; // bigger number |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
317 uint32_t unknown5; // yet another number |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
318 uint16_t sub_packet_h; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
319 uint16_t frame_size; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
320 uint16_t sub_packet_size; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
321 uint16_t unknown6; // 00 00 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
322 uint16_t sample_rate; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
323 uint16_t unknown8; // 0 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
324 uint16_t sample_size; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
325 uint16_t channels; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
326 } real_audio_v4_props_t; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
327 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
328 typedef struct { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
329 uint32_t fourcc1; // '.', 'r', 'a', 0xfd |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
330 uint16_t version1; // 4 or 5 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
331 uint16_t unknown1; // 00 000 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
332 uint32_t fourcc2; // .ra4 or .ra5 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
333 uint32_t unknown2; // ??? |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
334 uint16_t version2; // 4 or 5 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
335 uint32_t header_size; // == 0x4e |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
336 uint16_t flavor; // codec flavor id |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
337 uint32_t coded_frame_size; // coded frame size |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
338 uint32_t unknown3; // big number |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
339 uint32_t unknown4; // bigger number |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
340 uint32_t unknown5; // yet another number |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
341 uint16_t sub_packet_h; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
342 uint16_t frame_size; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
343 uint16_t sub_packet_size; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
344 uint16_t unknown6; // 00 00 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
345 uint8_t unknown7[6]; // 0, srate, 0 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
346 uint16_t sample_rate; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
347 uint16_t unknown8; // 0 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
348 uint16_t sample_size; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
349 uint16_t channels; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
350 uint32_t genr; // "genr" |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
351 uint32_t fourcc3; // fourcc |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
352 } real_audio_v5_props_t; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
353 |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
354 // I have to (re)define this struct here because g++ will not compile |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
355 // components.h from the qtsdk if I include it. |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
356 typedef struct { |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
357 uint32_t id_size; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
358 uint32_t codec_type; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
359 uint32_t reserved1; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
360 uint16_t reserved2; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
361 uint16_t data_reference_index; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
362 uint16_t version; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
363 uint16_t revision; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
364 uint32_t vendor; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
365 uint32_t temporal_quality; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
366 uint32_t spatial_quality; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
367 uint16_t width; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
368 uint16_t height; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
369 uint32_t horizontal_resolution; // 32bit fixed-point number |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
370 uint32_t vertical_resolution; // 32bit fixed-point number |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
371 uint32_t data_size; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
372 uint16_t frame_count; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
373 char compressor_name[32]; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
374 uint16_t depth; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
375 uint16_t color_table_id; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
376 } qt_image_description_t; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
377 |
10438
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
378 #if __GNUC__ == 2 |
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
379 #pragma pack() |
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
380 #else |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
381 #pragma pack(pop) |
10438
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
382 #endif |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
383 |
10024 | 384 static uint16_t get_uint16(const void *buf) { |
385 uint16_t ret; | |
386 unsigned char *tmp; | |
387 | |
388 tmp = (unsigned char *) buf; | |
389 | |
390 ret = tmp[1] & 0xff; | |
391 ret = (ret << 8) + (tmp[0] & 0xff); | |
392 | |
393 return ret; | |
394 } | |
395 | |
396 static uint32_t get_uint32(const void *buf) { | |
397 uint32_t ret; | |
398 unsigned char *tmp; | |
399 | |
400 tmp = (unsigned char *) buf; | |
401 | |
402 ret = tmp[3] & 0xff; | |
403 ret = (ret << 8) + (tmp[2] & 0xff); | |
404 ret = (ret << 8) + (tmp[1] & 0xff); | |
405 ret = (ret << 8) + (tmp[0] & 0xff); | |
406 | |
407 return ret; | |
408 } | |
409 | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
410 static uint16_t get_uint16_be(const void *buf) { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
411 uint16_t ret; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
412 unsigned char *tmp; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
413 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
414 tmp = (unsigned char *) buf; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
415 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
416 ret = tmp[0] & 0xff; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
417 ret = (ret << 8) + (tmp[1] & 0xff); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
418 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
419 return ret; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
420 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
421 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
422 static uint32_t get_uint32_be(const void *buf) { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
423 uint32_t ret; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
424 unsigned char *tmp; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
425 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
426 tmp = (unsigned char *) buf; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
427 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
428 ret = tmp[0] & 0xff; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
429 ret = (ret << 8) + (tmp[1] & 0xff); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
430 ret = (ret << 8) + (tmp[2] & 0xff); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
431 ret = (ret << 8) + (tmp[3] & 0xff); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
432 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
433 return ret; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
434 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
435 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
436 unsigned char read_char(unsigned char *p, int &pos, int size) { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
437 if ((pos + 1) > size) |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
438 throw exception(); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
439 pos++; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
440 return p[pos - 1]; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
441 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
442 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
443 unsigned short read_word(unsigned char *p, int &pos, int size) { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
444 unsigned short v; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
445 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
446 if ((pos + 2) > size) |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
447 throw exception(); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
448 v = p[pos]; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
449 v = (v << 8) | (p[pos + 1] & 0xff); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
450 pos += 2; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
451 return v; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
452 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
453 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
454 unsigned int read_dword(unsigned char *p, int &pos, int size) { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
455 unsigned int v; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
456 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
457 if ((pos + 4) > size) |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
458 throw exception(); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
459 v = p[pos]; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
460 v = (v << 8) | (p[pos + 1] & 0xff); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
461 v = (v << 8) | (p[pos + 2] & 0xff); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
462 v = (v << 8) | (p[pos + 3] & 0xff); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
463 pos += 4; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
464 return v; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
465 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
466 |
10024 | 467 static void handle_subtitles(demuxer_t *d, KaxBlock *block, int64_t duration) { |
468 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *)d->priv; | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
469 int len, line, state, i; |
10024 | 470 char *s1, *s2, *buffer; |
471 | |
472 if (duration == -1) { | |
473 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Warning: No KaxBlockDuration " | |
474 "element for subtitle track found.\n"); | |
475 return; | |
476 } | |
477 | |
478 DataBuffer &data = block->GetBuffer(0); | |
479 len = data.Size(); | |
480 | |
481 buffer = (char *)data.Buffer(); | |
482 s1 = buffer; | |
483 | |
484 while (((*s1 == '\n') || (*s1 == '\r')) && | |
485 ((unsigned int)(s1 - buffer) <= data.Size())) | |
486 s1++; | |
487 | |
488 line = 0; | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
489 mkv_d->subs.lines++; |
11276 | 490 if (mkv_d->subs.lines> SUB_MAX_TEXT - 1 ) |
491 { | |
492 mp_msg(MSGT_DEMUX, MSGL_WARN,"[mkv] Warning: too many sublines to render, skipping\n"); | |
493 mkv_d->subs.lines--; | |
494 return; | |
495 } | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
496 s2 = mkv_d->subs.text[mkv_d->subs.lines - 1]; |
10024 | 497 state = 0; |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
498 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
499 if (mkv_d->subtitle_type == MKV_SUBTYPE_SSA) { |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
500 /* Matroska's SSA format does not have timecodes embedded into |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
501 the SAA line. Timescodes are encoded into the blocks timecode |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
502 and duration. */ |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
503 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
504 /* Find text section. */ |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
505 for (i = 0; (i < 8) && (*s1 != 0); s1++) |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
506 if (*s1 == ',') |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
507 i++; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
508 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
509 if (*s1 == 0) { // Broken line? |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
510 mkv_d->subs.lines--; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
511 return; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
512 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
513 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
514 /* Load text. */ |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
515 while ((unsigned int)(s1 - buffer) < data.Size()) { |
10861
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
516 if (*s1 == '{') |
10024 | 517 state = 1; |
10861
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
518 else if ((*s1 == '}') && (state == 1)) |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
519 state = 2; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
520 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
521 if (state == 0) { |
10024 | 522 *s2 = *s1; |
523 s2++; | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
524 if ((s2 - mkv_d->subs.text[mkv_d->subs.lines - 1]) >= 255) |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
525 break; |
10024 | 526 } |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
527 s1++; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
528 |
10861
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
529 /* Newline */ |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
530 if ((*s1 == '\\') && ((unsigned int)(s1 + 1 - buffer) < data.Size()) && |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
531 ((*(s1 + 1) == 'N') || (*(s1 + 1) == 'n'))) { |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
532 mkv_d->clear_subs_at[mkv_d->subs.lines - 1] = |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
533 block->GlobalTimecode() / 1000000 - mkv_d->first_tc + duration; |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
534 |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
535 mkv_d->subs.lines++; |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
536 *s2 = 0; |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
537 s2 = mkv_d->subs.text[mkv_d->subs.lines - 1]; |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
538 s1 += 2; |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
539 } |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
540 |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
541 if (state == 2) |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
542 state = 0; |
10024 | 543 } |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
544 *s2 = 0; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
545 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
546 } else { |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
547 while ((unsigned int)(s1 - buffer) != data.Size()) { |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
548 if ((*s1 == '\n') || (*s1 == '\r')) { |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
549 if (state == 0) { // normal char --> newline |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
550 if (mkv_d->subs.lines == SUB_MAX_TEXT) |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
551 break; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
552 *s2 = 0; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
553 mkv_d->clear_subs_at[mkv_d->subs.lines - 1]= |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
554 block->GlobalTimecode() / 1000000 - mkv_d->first_tc + duration; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
555 s2 = mkv_d->subs.text[mkv_d->subs.lines]; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
556 mkv_d->subs.lines++; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
557 state = 1; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
558 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
559 } else if (*s1 == '<') // skip HTML tags |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
560 state = 2; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
561 else if (*s1 == '>') |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
562 state = 0; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
563 else if (state != 2) { // normal character |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
564 state = 0; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
565 if ((s2 - mkv_d->subs.text[mkv_d->subs.lines - 1]) < 255) { |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
566 *s2 = *s1; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
567 s2++; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
568 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
569 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
570 s1++; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
571 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
572 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
573 *s2 = 0; |
10024 | 574 } |
575 | |
576 #ifdef USE_ICONV | |
577 subcp_recode1(&mkv_d->subs); | |
578 #endif | |
579 | |
580 vo_sub = &mkv_d->subs; | |
581 vo_osd_changed(OSDTYPE_SUBTITLE); | |
582 | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
583 mkv_d->clear_subs_at[mkv_d->subs.lines - 1] = |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
584 block->GlobalTimecode() / 1000000 - mkv_d->first_tc + duration; |
10024 | 585 } |
586 | |
587 static mkv_track_t *new_mkv_track(mkv_demuxer_t *d) { | |
588 mkv_track_t *t; | |
589 | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
590 t = (mkv_track_t *)safemalloc(sizeof(mkv_track_t)); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
591 memset(t, 0, sizeof(mkv_track_t)); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
592 d->tracks = (mkv_track_t **)realloc(d->tracks, (d->num_tracks + 1) * |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
593 sizeof(mkv_track_t *)); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
594 if (d->tracks == NULL) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
595 return NULL; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
596 d->tracks[d->num_tracks] = t; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
597 d->num_tracks++; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
598 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
599 // Set default values. |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
600 t->default_track = 1; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
601 t->a_sfreq = 8000.0; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
602 t->a_channels = 1; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
603 t->language = strdup("eng"); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
604 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
605 t->c_encodings = new vector<mkv_content_encoding_t>; |
10024 | 606 |
607 return t; | |
608 } | |
609 | |
610 static mkv_track_t *find_track_by_num(mkv_demuxer_t *d, uint32_t n, | |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
611 char track_type) { |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
612 int i; |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
613 |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
614 for (i = 0; i < d->num_tracks; i++) |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
615 if ((d->tracks[i] != NULL) && (d->tracks[i]->type == track_type) && |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
616 (d->tracks[i]->xid == n)) |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
617 return d->tracks[i]; |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
618 |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
619 return NULL; |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
620 } |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
621 |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
622 static mkv_track_t *find_duplicate_track_by_num(mkv_demuxer_t *d, uint32_t n, |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
623 mkv_track_t *c) { |
10024 | 624 int i; |
625 | |
626 for (i = 0; i < d->num_tracks; i++) | |
627 if ((d->tracks[i] != NULL) && (d->tracks[i]->tnum == n) && | |
628 (d->tracks[i] != c)) | |
629 return d->tracks[i]; | |
630 | |
631 return NULL; | |
632 } | |
633 | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
634 static mkv_track_t *find_track_by_language(mkv_demuxer_t *d, char *language, |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
635 mkv_track_t *c, char type = 's') { |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
636 int i; |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
637 |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
638 for (i = 0; i < d->num_tracks; i++) |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
639 if ((d->tracks[i] != NULL) && (d->tracks[i] != c) && |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
640 (d->tracks[i]->language != NULL) && |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
641 !strcmp(d->tracks[i]->language, language) && |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
642 (d->tracks[i]->type == type)) |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
643 return d->tracks[i]; |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
644 |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
645 return NULL; |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
646 } |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
647 |
11154 | 648 static bool mkv_parse_idx(mkv_track_t *t) { |
649 uint32_t i, p, things_found; | |
650 int idx; | |
651 string line, s1, s2; | |
652 char *src; | |
653 | |
654 if ((t->private_data == NULL) || (t->private_size < 1)) | |
655 return false; | |
656 | |
657 things_found = 0; | |
658 i = 0; | |
659 src = (char *)t->private_data; | |
660 do { | |
661 line = ""; | |
662 while ((i < t->private_size) && (src[i] != '\n') && (src[i] != '\r')) { | |
663 if (!isspace(src[i])) | |
664 line += src[i]; | |
665 i++; | |
666 } | |
667 while ((i < t->private_size) && ((src[i] == '\n') || (src[i] == '\r'))) | |
668 i++; | |
669 | |
670 if (!strncasecmp(line.c_str(), "size:", 5)) { | |
671 s1 = line.substr(5); | |
672 idx = s1.find('x'); | |
673 if (idx >= 0) { | |
674 s2 = s1.substr(idx + 1); | |
675 s1.erase(idx); | |
676 t->sh_sub.width = strtol(s1.c_str(), NULL, 10); | |
677 t->sh_sub.height = strtol(s2.c_str(), NULL, 10); | |
678 things_found |= 1; | |
679 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub IDX parser: size: %d x %d\n", | |
680 t->sh_sub.width, t->sh_sub.height); | |
681 } | |
682 | |
683 } else if (!strncasecmp(line.c_str(), "palette:", 8)) { | |
684 s1 = line.substr(8); | |
685 for (p = 0; p < 15; p++) { | |
686 idx = s1.find(','); | |
687 if (idx < 0) | |
688 break; | |
689 s2 = s1.substr(0, idx); | |
690 s1.erase(0, idx + 1); | |
691 t->sh_sub.palette[p] = (unsigned int)strtol(s2.c_str(), NULL, 16); | |
692 } | |
693 if (idx >= 0) { | |
694 t->sh_sub.palette[15] = (unsigned int)strtol(s1.c_str(), NULL, 16); | |
695 things_found |= 2; | |
696 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub IDX parser: palette: 0x%06x " | |
697 "0x%06x 0x%06x 0x%06x 0x%06x 0x%06x 0x%06x 0x%06x 0x%06x " | |
698 "0x%06x 0x%06x 0x%06x 0x%06x 0x%06x 0x%06x 0x%06x\n", | |
699 t->sh_sub.palette[0], t->sh_sub.palette[1], | |
700 t->sh_sub.palette[2], t->sh_sub.palette[3], | |
701 t->sh_sub.palette[4], t->sh_sub.palette[5], | |
702 t->sh_sub.palette[6], t->sh_sub.palette[7], | |
703 t->sh_sub.palette[8], t->sh_sub.palette[9], | |
704 t->sh_sub.palette[10], t->sh_sub.palette[11], | |
705 t->sh_sub.palette[12], t->sh_sub.palette[13], | |
706 t->sh_sub.palette[14], t->sh_sub.palette[15]); | |
707 } | |
708 } | |
709 | |
710 } while ((i != t->private_size) && (things_found != 3)); | |
711 t->sh_sub.type = 'v'; | |
712 | |
713 return (things_found == 3); | |
714 } | |
715 | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
716 static bool reverse_encodings(mkv_track_t *track, unsigned char *&data, |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
717 uint32_t &size, uint32_t type) { |
11393 | 718 int new_size, n; |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
719 unsigned char *new_data, *old_data; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
720 bool modified; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
721 vector<mkv_content_encoding_t>::iterator ce; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
722 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
723 if (track->c_encodings->size() == 0) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
724 return false; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
725 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
726 new_data = data; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
727 new_size = size; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
728 modified = false; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
729 for (ce = track->c_encodings->begin(); ce < track->c_encodings->end(); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
730 ce++) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
731 if ((ce->scope & type) == 0) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
732 continue; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
733 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
734 #ifdef HAVE_ZLIB |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
735 if (ce->comp_algo == 0) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
736 int result; |
11393 | 737 z_stream zstream; |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
738 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
739 old_data = new_data; |
11393 | 740 |
741 zstream.zalloc = (alloc_func)0; | |
742 zstream.zfree = (free_func)0; | |
743 zstream.opaque = (voidpf)0; | |
744 result = inflateInit(&zstream); | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
745 if (result != Z_OK) { |
11393 | 746 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Zlib initialization failed. " |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
747 "Result: %d\n", result); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
748 safefree(new_data); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
749 data = old_data; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
750 size = new_size; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
751 return modified; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
752 } |
11393 | 753 zstream.next_in = (Bytef *)old_data; |
754 zstream.avail_in = new_size; | |
755 | |
756 n = 0; | |
757 new_data = NULL; | |
758 do { | |
759 n++; | |
760 new_data = (unsigned char *)realloc(new_data, n * 4000); | |
761 zstream.next_out = (Bytef *)&new_data[(n - 1) * 4000]; | |
762 zstream.avail_out = 4000; | |
763 result = inflate(&zstream, Z_NO_FLUSH); | |
764 if ((result != Z_OK) && (result != Z_STREAM_END)) { | |
765 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Zlib decompression failed. " | |
766 "Result: %d \n", result); | |
767 safefree(new_data); | |
768 data = old_data; | |
769 size = new_size; | |
770 inflateEnd(&zstream); | |
771 return modified; | |
772 } | |
773 } while ((zstream.avail_out == 0) && | |
774 (zstream.avail_in != 0) && (result != Z_STREAM_END)); | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
775 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
776 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] zlib decompression: from %d to " |
11478 | 777 "%d \n", (int)new_size, (int)zstream.total_out); |
11393 | 778 new_size = zstream.total_out; |
779 inflateEnd(&zstream); | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
780 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
781 if (modified) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
782 safefree(old_data); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
783 modified = true; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
784 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
785 #endif |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
786 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
787 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
788 data = new_data; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
789 size = new_size; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
790 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
791 return modified; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
792 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
793 |
10024 | 794 static int check_track_information(mkv_demuxer_t *d) { |
10028
7ca8b302032f
Loop counter was used inside for another loop as well.
mosu
parents:
10024
diff
changeset
|
795 int i, track_num; |
10024 | 796 unsigned char *c; |
797 uint32_t u, offset, length; | |
798 mkv_track_t *t; | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
799 mkv_content_encoding_t *ce; |
10024 | 800 BITMAPINFOHEADER *bih; |
801 WAVEFORMATEX *wfe; | |
802 | |
10028
7ca8b302032f
Loop counter was used inside for another loop as well.
mosu
parents:
10024
diff
changeset
|
803 for (track_num = 0; track_num < d->num_tracks; track_num++) { |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
804 t = d->tracks[track_num]; |
10028
7ca8b302032f
Loop counter was used inside for another loop as well.
mosu
parents:
10024
diff
changeset
|
805 |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
806 t->ok = 1; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
807 for (i = 0; i < (int)t->c_encodings->size(); i++) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
808 ce = &(*t->c_encodings)[i]; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
809 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
810 if (ce->type == 1) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
811 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Track number %u has been " |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
812 "encrypted and decryption has not yet been implemented. " |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
813 "Skipping track.\n", t->tnum); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
814 t->ok = 0; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
815 break; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
816 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
817 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
818 if (ce->type != 0) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
819 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Unknown content encoding type %u " |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
820 "for track %u. Skipping track.\n", ce->type, t->tnum); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
821 t->ok = 0; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
822 break; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
823 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
824 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
825 if (ce->comp_algo == 0) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
826 #if !defined(HAVE_ZLIB) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
827 mp_msg(MSGT_DEMUX, MSGL_WARN, "Track %u was compressed with zlib but " |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
828 "mplayer has not been compiled with support for zlib " |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
829 "compression. Skipping track.\n", t->tnum); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
830 t->ok = 0; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
831 break; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
832 #endif |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
833 } else { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
834 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Track %u has been compressed " |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
835 "with an unknown/unsupported compression algorithm (%u). " |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
836 "Skipping track.\n", t->tnum, ce->comp_algo); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
837 t->ok = 0; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
838 break; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
839 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
840 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
841 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
842 if (!t->ok) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
843 continue; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
844 t->ok = 0; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
845 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
846 if (t->private_data != NULL) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
847 c = (unsigned char *)t->private_data; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
848 length = t->private_size; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
849 if (reverse_encodings(t, c, length, 2)) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
850 safefree(t->private_data); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
851 t->private_data = c; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
852 t->private_size = length; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
853 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
854 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
855 |
10024 | 856 switch (t->type) { |
857 case 'v': // video track | |
858 if (t->codec_id == NULL) | |
859 continue; | |
860 if (!strcmp(t->codec_id, MKV_V_MSCOMP)) { | |
861 if ((t->private_data == NULL) || | |
862 (t->private_size < sizeof(BITMAPINFOHEADER))) { | |
863 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: CodecID for track " | |
864 "%u is '" MKV_V_MSCOMP "', but there was no " | |
865 "BITMAPINFOHEADER struct present. Therefore we don't have " | |
866 "a FourCC to identify the video codec used.\n", t->tnum); | |
867 continue; | |
868 } else { | |
869 t->ms_compat = 1; | |
870 | |
871 bih = (BITMAPINFOHEADER *)t->private_data; | |
872 | |
873 u = get_uint32(&bih->biWidth); | |
874 if (t->v_width != u) { | |
875 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: (MS " | |
876 "compatibility mode, track %u) " | |
877 "Matrosa says video width is %u, but the " | |
878 "BITMAPINFOHEADER says %u.\n", t->tnum, t->v_width, u); | |
879 if (t->v_width == 0) | |
880 t->v_width = u; | |
881 } | |
882 | |
883 u = get_uint32(&bih->biHeight); | |
884 if (t->v_height != u) { | |
885 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: (MS compatibility " | |
886 "mode, track %u) " | |
887 "Matrosa video height is %u, but the BITMAPINFOHEADER " | |
888 "says %u.\n", t->tnum, t->v_height, u); | |
889 if (t->v_height == 0) | |
890 t->v_height = u; | |
891 } | |
892 | |
893 memcpy(t->v_fourcc, &bih->biCompression, 4); | |
894 } | |
895 } | |
896 | |
897 if (t->v_width == 0) { | |
898 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] The width for track %u was " | |
899 "not set.\n", t->tnum); | |
900 continue; | |
901 } | |
902 if (t->v_height == 0) { | |
903 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] The height for track %u was " | |
904 "not set.\n", t->tnum); | |
905 continue; | |
906 } | |
907 | |
10081
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
908 if (t->v_dwidth == 0) |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
909 t->v_dwidth = t->v_width; |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
910 if (t->v_dheight == 0) |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
911 t->v_dheight = t->v_height; |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
912 |
10024 | 913 // This track seems to be ok. |
914 t->ok = 1; | |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
915 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Track ID %u: video (%s), " |
10706
ede87804e4e6
Removed some ":" in the track output for easier cut&paste.
mosu
parents:
10705
diff
changeset
|
916 "-vid %u\n", t->tnum, t->codec_id, t->xid); |
10024 | 917 |
918 break; | |
919 | |
920 case 'a': // audio track | |
921 if (t->codec_id == NULL) | |
922 continue; | |
923 if (!strcmp(t->codec_id, MKV_A_ACM)) { | |
924 if ((t->private_data == NULL) || | |
925 (t->private_size < sizeof(WAVEFORMATEX))) { | |
926 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: CodecID for track " | |
927 "%u is '" MKV_A_ACM "', " | |
928 "but there was no WAVEFORMATEX struct present. " | |
929 "Therefore we don't have a format ID to identify the audio " | |
930 "codec used.\n", t->tnum); | |
931 continue; | |
932 } else { | |
933 t->ms_compat = 1; | |
934 | |
935 wfe = (WAVEFORMATEX *)t->private_data; | |
936 u = get_uint32(&wfe->nSamplesPerSec); | |
937 if (((uint32_t)t->a_sfreq) != u) { | |
938 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: (MS compatibility " | |
939 "mode for track %u) " | |
940 "Matroska says that there are %u samples per second, " | |
941 "but WAVEFORMATEX says that there are %u.\n", t->tnum, | |
942 (uint32_t)t->a_sfreq, u); | |
943 if (t->a_sfreq == 0.0) | |
944 t->a_sfreq = (float)u; | |
945 } | |
946 | |
947 u = get_uint16(&wfe->nChannels); | |
948 if (t->a_channels != u) { | |
949 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: (MS " | |
950 "compatibility mode for track %u) " | |
951 "Matroska says that there are %u channels, but the " | |
952 "WAVEFORMATEX says that there are %u.\n", t->tnum, | |
953 t->a_channels, u); | |
954 if (t->a_channels == 0) | |
955 t->a_channels = u; | |
956 } | |
957 | |
958 u = get_uint16(&wfe->wBitsPerSample); | |
10098 | 959 if (t->a_bps != u) { |
10024 | 960 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: (MS " |
961 "compatibility mode for track %u) " | |
962 "Matroska says that there are %u bits per sample, " | |
963 "but the WAVEFORMATEX says that there are %u.\n", t->tnum, | |
964 t->a_bps, u); | |
965 if (t->a_bps == 0) | |
966 t->a_bps = u; | |
967 } | |
968 | |
969 t->a_formattag = get_uint16(&wfe->wFormatTag); | |
970 } | |
971 } else { | |
11155 | 972 if (!strcmp(t->codec_id, MKV_A_MP3) || |
973 !strcmp(t->codec_id, MKV_A_MP2)) | |
10024 | 974 t->a_formattag = 0x0055; |
11114
d8ddd7727084
More liberal codec id recognition for AC3 codecs (needed for transcoded DNET from RM).
mosu
parents:
10984
diff
changeset
|
975 else if (!strncmp(t->codec_id, MKV_A_AC3, strlen(MKV_A_AC3))) |
10024 | 976 t->a_formattag = 0x2000; |
10105
dc4f1b768062
Support for DTS tracks (only with -hwac3 of course).
mosu
parents:
10099
diff
changeset
|
977 else if (!strcmp(t->codec_id, MKV_A_DTS)) |
dc4f1b768062
Support for DTS tracks (only with -hwac3 of course).
mosu
parents:
10099
diff
changeset
|
978 // uses same format tag as AC3, only supported with -hwac3 |
dc4f1b768062
Support for DTS tracks (only with -hwac3 of course).
mosu
parents:
10099
diff
changeset
|
979 t->a_formattag = 0x2000; |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
980 else if (!strcmp(t->codec_id, MKV_A_PCM) || |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
981 !strcmp(t->codec_id, MKV_A_PCM_BE)) |
10024 | 982 t->a_formattag = 0x0001; |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
983 else if (!strcmp(t->codec_id, MKV_A_AAC_2MAIN) || |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
984 !strcmp(t->codec_id, MKV_A_AAC_2LC) || |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
985 !strcmp(t->codec_id, MKV_A_AAC_2SSR) || |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
986 !strcmp(t->codec_id, MKV_A_AAC_4MAIN) || |
10125 | 987 !strcmp(t->codec_id, MKV_A_AAC_4LC) || |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
988 !strcmp(t->codec_id, MKV_A_AAC_4SSR) || |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
989 !strcmp(t->codec_id, MKV_A_AAC_4LTP) || |
10125 | 990 !strcmp(t->codec_id, MKV_A_AAC_4SBR)) |
991 t->a_formattag = mmioFOURCC('M', 'P', '4', 'A'); | |
10024 | 992 else if (!strcmp(t->codec_id, MKV_A_VORBIS)) { |
993 if (t->private_data == NULL) { | |
994 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: CodecID for " | |
995 "track %u is '" MKV_A_VORBIS | |
996 "', but there are no header packets present.", t->tnum); | |
997 continue; | |
998 } | |
999 | |
1000 c = (unsigned char *)t->private_data; | |
1001 if (c[0] != 2) { | |
1002 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Vorbis track does not " | |
1003 "contain valid headers.\n"); | |
1004 continue; | |
1005 } | |
1006 | |
1007 offset = 1; | |
1008 for (i = 0; i < 2; i++) { | |
1009 length = 0; | |
1010 while ((c[offset] == (unsigned char )255) && | |
1011 (length < t->private_size)) { | |
1012 length += 255; | |
1013 offset++; | |
1014 } | |
1015 if (offset >= (t->private_size - 1)) { | |
1016 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Vorbis track does not " | |
1017 "contain valid headers.\n"); | |
1018 continue; | |
1019 } | |
1020 length += c[offset]; | |
1021 offset++; | |
1022 t->header_sizes[i] = length; | |
1023 } | |
1024 | |
1025 t->headers[0] = &c[offset]; | |
1026 t->headers[1] = &c[offset + t->header_sizes[0]]; | |
1027 t->headers[2] = &c[offset + t->header_sizes[0] + | |
1028 t->header_sizes[1]]; | |
10079
7c13793dbfa0
Vorbis header packet lengths were calculated incorrectly.
mosu
parents:
10073
diff
changeset
|
1029 t->header_sizes[2] = t->private_size - offset - |
7c13793dbfa0
Vorbis header packet lengths were calculated incorrectly.
mosu
parents:
10073
diff
changeset
|
1030 t->header_sizes[0] - t->header_sizes[1]; |
10024 | 1031 |
1032 t->a_formattag = 0xFFFE; | |
11478 | 1033 } else if (!strcmp(t->codec_id, MKV_A_QDMC) || |
1034 !strcmp(t->codec_id, MKV_A_QDMC2)) { | |
1035 ; | |
1036 } else if (!strcmp(t->codec_id, MKV_A_FLAC)) { | |
1037 if ((t->private_data == NULL) || (t->private_size == 0)) { | |
1038 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] FLAC track does not " | |
1039 "contain valid headers.\n"); | |
1040 continue; | |
1041 } | |
1042 t->a_formattag = mmioFOURCC('f', 'L', 'a', 'C'); | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1043 } else if (t->private_size >= sizeof(real_audio_v4_props_t)) { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1044 if (!strcmp(t->codec_id, MKV_A_REAL28)) |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1045 t->a_formattag = mmioFOURCC('2', '8', '_', '8'); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1046 else if (!strcmp(t->codec_id, MKV_A_REALATRC)) |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1047 t->a_formattag = mmioFOURCC('a', 't', 'r', 'c'); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1048 else if (!strcmp(t->codec_id, MKV_A_REALCOOK)) |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1049 t->a_formattag = mmioFOURCC('c', 'o', 'o', 'k'); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1050 else if (!strcmp(t->codec_id, MKV_A_REALDNET)) |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1051 t->a_formattag = mmioFOURCC('d', 'n', 'e', 't'); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1052 else if (!strcmp(t->codec_id, MKV_A_REALSIPR)) |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1053 t->a_formattag = mmioFOURCC('s', 'i', 'p', 'r'); |
10024 | 1054 } else { |
1055 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Unknown/unsupported audio " | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1056 "codec ID '%s' for track %u or missing/faulty private " |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1057 "codec data.\n", t->codec_id, t->tnum); |
10024 | 1058 continue; |
1059 } | |
1060 } | |
1061 | |
1062 if (t->a_sfreq == 0.0) { | |
1063 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] The sampling frequency was not " | |
1064 "set for track %u.\n", t->tnum); | |
1065 continue; | |
1066 } | |
1067 | |
1068 if (t->a_channels == 0) { | |
1069 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] The number of channels was not " | |
1070 "set for track %u.\n", t->tnum); | |
1071 continue; | |
1072 } | |
1073 | |
1074 // This track seems to be ok. | |
1075 t->ok = 1; | |
10706
ede87804e4e6
Removed some ":" in the track output for easier cut&paste.
mosu
parents:
10705
diff
changeset
|
1076 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Track ID %u: audio (%s), -aid " |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1077 "%u%s%s\n", t->tnum, t->codec_id, t->xid, |
10706
ede87804e4e6
Removed some ":" in the track output for easier cut&paste.
mosu
parents:
10705
diff
changeset
|
1078 t->language != NULL ? ", -alang " : "", |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1079 t->language != NULL ? t->language : ""); |
10024 | 1080 break; |
1081 | |
11154 | 1082 case 's': |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1083 if (!strcmp(t->codec_id, MKV_S_VOBSUB)) { |
11154 | 1084 if (mkv_parse_idx(t)) { |
1085 t->ok = 1; | |
1086 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Track ID %u: subtitles (%s), " | |
1087 "-sid %u%s%s\n", t->tnum, t->codec_id, | |
1088 t->xid, t->language != NULL ? ", -slang " : "", | |
1089 t->language != NULL ? t->language : ""); | |
1090 } | |
1091 | |
1092 } else { // Text subtitles do not need any data | |
1093 t->ok = 1; // except the CodecID. | |
1094 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Track ID %u: subtitles (%s), " | |
1095 "-sid %u%s%s\n", t->tnum, t->codec_id, t->xid, | |
1096 t->language != NULL ? ", -slang " : "", | |
1097 t->language != NULL ? t->language : ""); | |
1098 } | |
10024 | 1099 break; |
1100 | |
1101 default: // unknown track type!? error in demuxer... | |
1102 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] Error in demux_mkv.cpp: unknown " | |
1103 "demuxer type for track %u: '%c'\n", t->tnum, t->type); | |
1104 continue; | |
1105 } | |
1106 | |
1107 if (t->ok) | |
1108 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Track %u seems to be ok.\n", t->tnum); | |
1109 } | |
1110 | |
1111 return 1; | |
1112 } | |
1113 | |
1114 static void free_mkv_demuxer(mkv_demuxer_t *d) { | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1115 int i, k; |
10024 | 1116 |
1117 if (d == NULL) | |
1118 return; | |
1119 | |
1120 for (i = 0; i < d->num_tracks; i++) | |
1121 if (d->tracks[i] != NULL) { | |
1122 if (d->tracks[i]->private_data != NULL) | |
1123 free(d->tracks[i]->private_data); | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
1124 if (d->tracks[i]->language != NULL) |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
1125 free(d->tracks[i]->language); |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1126 for (k = 0; k < (int)d->tracks[i]->c_encodings->size(); k++) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1127 safefree((*d->tracks[i]->c_encodings)[k].comp_settings); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1128 safefree((*d->tracks[i]->c_encodings)[k].enc_keyid); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1129 safefree((*d->tracks[i]->c_encodings)[k].sig_keyid); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1130 safefree((*d->tracks[i]->c_encodings)[k].signature); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1131 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1132 delete d->tracks[i]->c_encodings; |
10024 | 1133 free(d->tracks[i]); |
1134 } | |
1135 | |
1136 for (i = 0; i < d->num_indexes; i++) | |
1137 free(d->index[i].entries); | |
1138 free(d->index); | |
1139 | |
1140 if (d->es != NULL) | |
1141 delete d->es; | |
1142 if (d->saved_l1 != NULL) | |
1143 delete d->saved_l1; | |
1144 if (d->in != NULL) | |
1145 delete d->in; | |
1146 if (d->segment != NULL) | |
1147 delete d->segment; | |
11260 | 1148 if (d->chapters != NULL) |
1149 delete d->chapters; | |
10024 | 1150 |
1151 free(d); | |
1152 } | |
1153 | |
1154 static void add_index_entry(mkv_demuxer_t *d, uint32_t tnum, uint64_t filepos, | |
1155 uint64_t timecode, int is_key) { | |
1156 int i, found; | |
1157 mkv_index_entry_t *entry; | |
1158 | |
1159 for (i = 0, found = 0; i < d->num_indexes; i++) | |
1160 if (d->index[i].tnum == tnum) { | |
1161 found = 1; | |
1162 break; | |
1163 } | |
1164 | |
1165 if (!found) { | |
1166 d->index = (mkv_track_index_t *)realloc(d->index, (d->num_indexes + 1) * | |
1167 sizeof(mkv_track_index_t)); | |
1168 if (d->index == NULL) | |
1169 return; | |
1170 i = d->num_indexes; | |
1171 memset(&d->index[i], 0, sizeof(mkv_track_index_t)); | |
1172 d->index[i].tnum = tnum; | |
1173 d->num_indexes++; | |
1174 } | |
1175 | |
1176 d->index[i].entries = | |
1177 (mkv_index_entry_t *)realloc(d->index[i].entries, | |
1178 (d->index[i].num_entries + 1) * | |
1179 sizeof(mkv_index_entry_t)); | |
1180 if (d->index[i].entries == NULL) | |
1181 return; | |
1182 entry = &d->index[i].entries[d->index[i].num_entries]; | |
1183 entry->filepos = filepos; | |
1184 entry->timecode = timecode; | |
1185 entry->is_key = is_key; | |
1186 d->index[i].num_entries++; | |
1187 } | |
1188 | |
1189 static void add_cluster_position(mkv_demuxer_t *mkv_d, int64_t position) { | |
1190 mkv_d->cluster_positions = (int64_t *)realloc(mkv_d->cluster_positions, | |
1191 (mkv_d->num_cluster_pos + 1) * | |
1192 sizeof(int64_t)); | |
1193 if (mkv_d->cluster_positions != NULL) { | |
1194 mkv_d->cluster_positions[mkv_d->num_cluster_pos] = position; | |
1195 mkv_d->num_cluster_pos++; | |
1196 } else | |
1197 mkv_d->num_cluster_pos = 0; | |
1198 } | |
1199 | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1200 static int find_in_vector(vector<uint64_t> &vec, uint64_t value) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1201 unsigned int i; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1202 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1203 for (i = 0; i < vec.size(); i++) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1204 if (vec[i] == value) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1205 return 1; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1206 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1207 return 0; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1208 } |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1209 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1210 #define in_parent(p) (mkv_d->in->getFilePointer() < \ |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1211 (p->GetElementPosition() + p->ElementSize())) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1212 #define FINDFIRST(p, c) (static_cast<c *> \ |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1213 (((EbmlMaster *)p)->FindFirstElt(c::ClassInfos, false))) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1214 #define FINDNEXT(p, c, e) (static_cast<c *> \ |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1215 (((EbmlMaster *)p)->FindNextElt(*e, false))) |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1216 |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1217 static void parse_cues(mkv_demuxer_t *mkv_d, uint64_t pos) { |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1218 EbmlElement *l2 = NULL; |
10024 | 1219 EbmlStream *es; |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1220 KaxCues *cues; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1221 KaxCuePoint *cpoint; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1222 KaxCueTime *ctime; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1223 KaxCueClusterPosition *ccpos; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1224 KaxCueTrack *ctrack; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1225 KaxCueTrackPositions *ctrackpos; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1226 KaxCueReference *cref; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1227 int upper_lvl_el, i, k; |
10024 | 1228 uint64_t tc_scale, filepos = 0, timecode = 0; |
1229 uint32_t tnum = 0; | |
1230 mkv_index_entry_t *entry; | |
1231 | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1232 if (find_in_vector(*mkv_d->parsed_cues, pos)) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1233 return; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1234 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1235 mkv_d->parsed_cues->push_back(pos); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1236 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1237 mkv_d->in->setFilePointer(pos); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1238 |
10024 | 1239 es = mkv_d->es; |
1240 tc_scale = mkv_d->tc_scale; | |
1241 upper_lvl_el = 0; | |
1242 | |
1243 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing cues ] -----------\n"); | |
1244 | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1245 cues = (KaxCues *)es->FindNextElement(mkv_d->segment->Generic().Context, |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1246 upper_lvl_el, 0xFFFFFFFFL, true, 1); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1247 if (cues == NULL) |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1248 return; |
10024 | 1249 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1250 if (!(EbmlId(*cues) == KaxCues::ClassInfos.GlobalId)) { |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1251 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] No KaxCues element found but %s.\n" |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1252 "[mkv] \\---- [ parsing cues ] -----------\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1253 cues->Generic().DebugName); |
10024 | 1254 |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1255 return; |
10024 | 1256 } |
1257 | |
1258 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |+ found cues\n"); | |
1259 | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1260 cues->Read(*es, KaxCues::ClassInfos.Context, upper_lvl_el, l2, true); |
10024 | 1261 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1262 cpoint = FINDFIRST(cues, KaxCuePoint); |
10024 | 1263 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1264 while (cpoint != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1265 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] | + found cue point\n"); |
10024 | 1266 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1267 ctime = FINDFIRST(cpoint, KaxCueTime); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1268 if (ctime == NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1269 cpoint = FINDNEXT(cues, KaxCuePoint, cpoint); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1270 continue; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1271 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1272 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1273 timecode = uint64(*ctime) * tc_scale / 1000000 - mkv_d->first_tc; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1274 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] | + found cue time: %.3fs\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1275 (float)timecode / 1000.0); |
10024 | 1276 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1277 ctrackpos = FINDFIRST(cpoint, KaxCueTrackPositions); |
10024 | 1278 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1279 while (ctrackpos != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1280 ctrack = FINDFIRST(ctrackpos, KaxCueTrack); |
10024 | 1281 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1282 if (ctrack == NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1283 ctrackpos = FINDNEXT(cpoint, KaxCueTrackPositions, ctrackpos); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1284 continue; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1285 } |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1286 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1287 tnum = uint32(*ctrack); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1288 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] | + found cue track: %u\n", tnum); |
10024 | 1289 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1290 ccpos = FINDFIRST(ctrackpos, KaxCueClusterPosition); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1291 if (ccpos == NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1292 ctrackpos = FINDNEXT(cpoint, KaxCueTrackPositions, ctrackpos); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1293 continue; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1294 } |
10024 | 1295 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1296 filepos = mkv_d->segment->GetGlobalPosition(uint64_t(*ccpos)); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1297 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] | + found cue cluster " |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1298 "position: %llu\n", filepos); |
10024 | 1299 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1300 cref = FINDFIRST(ctrackpos, KaxCueReference); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1301 add_index_entry(mkv_d, tnum, filepos, timecode, |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1302 cref == NULL ? 1 : 0); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1303 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1304 ctrackpos = FINDNEXT(cpoint, KaxCueTrackPositions, ctrackpos); |
10024 | 1305 } |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1306 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1307 cpoint = FINDNEXT(cues, KaxCuePoint, cpoint); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1308 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1309 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1310 delete cues; |
10024 | 1311 |
1312 // Debug: dump the index | |
1313 for (i = 0; i < mkv_d->num_indexes; i++) { | |
1314 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] Index for track %u contains %u " | |
1315 "entries.\n", mkv_d->index[i].tnum, mkv_d->index[i].num_entries); | |
1316 for (k = 0; k < mkv_d->index[i].num_entries; k++) { | |
1317 entry = &mkv_d->index[i].entries[k]; | |
1318 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] %d: timecode %llu, filepos %llu, " | |
1319 "is key: %s\n", k, entry->timecode, entry->filepos, | |
1320 entry->is_key ? "yes" : "no"); | |
1321 } | |
1322 } | |
1323 | |
1324 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing cues ] -----------\n"); | |
1325 | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1326 mkv_d->cues_found = 1; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1327 } |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1328 |
11260 | 1329 static void parse_chapters(mkv_demuxer_t *mkv_d, uint64_t pos) { |
1330 EbmlElement *l2 = NULL; | |
1331 EbmlStream *es; | |
1332 KaxChapters *kchapters; | |
1333 KaxEditionEntry *keentry; | |
1334 KaxChapterAtom *kcatom; | |
1335 KaxChapterTimeStart *kctstart; | |
1336 KaxChapterTimeEnd *kctend; | |
1337 int upper_lvl_el, i, k; | |
1338 mkv_chapter_t chapter; | |
1339 | |
1340 if (mkv_d->chapters != NULL) | |
1341 return; | |
1342 | |
1343 es = mkv_d->es; | |
1344 upper_lvl_el = 0; | |
1345 | |
1346 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing chapters ] ---------\n"); | |
1347 | |
1348 mkv_d->in->setFilePointer(pos); | |
1349 | |
1350 kchapters = | |
1351 (KaxChapters *)es->FindNextElement(mkv_d->segment->Generic().Context, | |
1352 upper_lvl_el, 0xFFFFFFFFL, true, 1); | |
1353 if (kchapters == NULL) | |
1354 return; | |
1355 | |
1356 if (!(EbmlId(*kchapters) == KaxChapters::ClassInfos.GlobalId)) { | |
1357 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] No KaxChapters element found but %s.\n" | |
1358 "[mkv] \\---- [ parsing chapters ] ---------\n", | |
1359 kchapters->Generic().DebugName); | |
1360 | |
1361 return; | |
1362 } | |
1363 | |
1364 mkv_d->chapters = new vector<mkv_chapter_t>; | |
1365 kchapters->Read(*es, KaxChapters::ClassInfos.Context, upper_lvl_el, l2, | |
1366 true); | |
1367 | |
1368 for (i = 0; i < (int)kchapters->ListSize(); i++) { | |
1369 keentry = (KaxEditionEntry *)(*kchapters)[i]; | |
1370 if (EbmlId(*keentry) == KaxEditionEntry::ClassInfos.GlobalId) { | |
1371 for (k = 0; k < (int)keentry->ListSize(); k++) { | |
1372 kcatom = (KaxChapterAtom *)(*keentry)[k]; | |
1373 if (EbmlId(*kcatom) == KaxChapterAtom::ClassInfos.GlobalId) { | |
1374 chapter.start = 0; | |
1375 chapter.end = 0; | |
1376 kctstart = FINDFIRST(kcatom, KaxChapterTimeStart); | |
1377 if (kctstart != NULL) | |
1378 chapter.start = uint64(*kctstart) / 1000000; | |
1379 kctend = FINDFIRST(kcatom, KaxChapterTimeEnd); | |
1380 if (kctend != NULL) | |
1381 chapter.end = uint64(*kctend) / 1000000; | |
1382 mkv_d->chapters->push_back(chapter); | |
1383 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Chapter %u from %02d:%02d:%02d." | |
1384 "%03d to %02d:%02d:%02d.%03d\n", mkv_d->chapters->size(), | |
1385 (int)(chapter.start / 60 / 60 / 1000), | |
1386 (int)((chapter.start / 60 / 1000) % 60), | |
1387 (int)((chapter.start / 1000) % 60), | |
1388 (int)(chapter.start % 1000), | |
1389 (int)(chapter.end / 60 / 60 / 1000), | |
1390 (int)((chapter.end / 60 / 1000) % 60), | |
1391 (int)((chapter.end / 1000) % 60), | |
1392 (int)(chapter.end % 1000)); | |
1393 } | |
1394 } | |
1395 } | |
1396 } | |
1397 | |
1398 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing chapters ] ---------\n"); | |
1399 delete kchapters; | |
1400 } | |
1401 | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1402 static void parse_seekhead(mkv_demuxer_t *mkv_d, uint64_t pos) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1403 EbmlElement *l2 = NULL; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1404 EbmlStream *es; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1405 KaxSeekHead *kseekhead; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1406 KaxSeek *kseek; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1407 KaxSeekID *ksid; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1408 KaxSeekPosition *kspos; |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1409 int upper_lvl_el, i, k, s; |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1410 uint64_t seek_pos; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1411 EbmlId *id; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1412 EbmlElement *e; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1413 binary *b; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1414 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1415 if (find_in_vector(*mkv_d->parsed_seekheads, pos)) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1416 return; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1417 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1418 mkv_d->parsed_seekheads->push_back(pos); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1419 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1420 es = mkv_d->es; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1421 upper_lvl_el = 0; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1422 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1423 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing seek head ] ---------\n"); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1424 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1425 mkv_d->in->setFilePointer(pos); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1426 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1427 kseekhead = |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1428 (KaxSeekHead *)es->FindNextElement(mkv_d->segment->Generic().Context, |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1429 upper_lvl_el, 0xFFFFFFFFL, true, 1); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1430 if (kseekhead == NULL) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1431 return; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1432 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1433 if (!(EbmlId(*kseekhead) == KaxSeekHead::ClassInfos.GlobalId)) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1434 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] No KaxSeekead element found but %s.\n" |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1435 "[mkv] \\---- [ parsing seek head ] ---------\n", |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1436 kseekhead->Generic().DebugName); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1437 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1438 return; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1439 } |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1440 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1441 kseekhead->Read(*es, KaxSeekHead::ClassInfos.Context, upper_lvl_el, l2, |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1442 true); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1443 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1444 for (i = 0; i < (int)kseekhead->ListSize(); i++) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1445 kseek = (KaxSeek *)(*kseekhead)[i]; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1446 if (!(EbmlId(*kseek) == KaxSeek::ClassInfos.GlobalId)) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1447 continue; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1448 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1449 seek_pos = 0; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1450 id = NULL; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1451 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1452 for (k = 0; k < (int)kseek->ListSize(); k++) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1453 e = (*kseek)[k]; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1454 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1455 if (EbmlId(*e) == KaxSeekID::ClassInfos.GlobalId) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1456 ksid = (KaxSeekID *)e; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1457 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1458 b = ksid->GetBuffer(); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1459 s = ksid->GetSize(); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1460 if (id != NULL) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1461 delete id; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1462 id = new EbmlId(b, s); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1463 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1464 } else if (EbmlId(*e) == KaxSeekPosition::ClassInfos.GlobalId) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1465 kspos = (KaxSeekPosition *)e; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1466 seek_pos = mkv_d->segment->GetGlobalPosition(uint64(*kspos)); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1467 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1468 } |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1469 } |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1470 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1471 if ((seek_pos != 0) && (id != NULL)) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1472 if (*id == KaxSeekHead::ClassInfos.GlobalId) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1473 parse_seekhead(mkv_d, seek_pos); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1474 else if (*id == KaxCues::ClassInfos.GlobalId) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1475 parse_cues(mkv_d, seek_pos); |
11260 | 1476 else if (*id == KaxChapters::ClassInfos.GlobalId) |
1477 parse_chapters(mkv_d, seek_pos); | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1478 } |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1479 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1480 if (id != NULL) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1481 delete id; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1482 } |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1483 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1484 delete kseekhead; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1485 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1486 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing seek head ] ---------\n"); |
10024 | 1487 } |
1488 | |
11260 | 1489 extern "C" void demux_mkv_seek(demuxer_t *demuxer, float rel_seek_secs, |
1490 int flags); | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1491 |
10024 | 1492 extern "C" int demux_mkv_open(demuxer_t *demuxer) { |
1493 unsigned char signature[4]; | |
1494 stream_t *s; | |
1495 demux_packet_t *dp; | |
1496 mkv_demuxer_t *mkv_d; | |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1497 int upper_lvl_el, exit_loop, i, vid, sid, aid; |
10024 | 1498 // Elements for different levels |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1499 EbmlElement *l0 = NULL, *l1 = NULL, *l2 = NULL; |
10024 | 1500 EbmlStream *es; |
1501 mkv_track_t *track; | |
1502 sh_audio_t *sh_a; | |
1503 sh_video_t *sh_v; | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1504 vector<uint64_t> seekheads_to_parse; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1505 vector<uint64_t> cues_to_parse; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1506 int64_t current_pos; |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
1507 qt_image_description_t *idesc; |
10024 | 1508 |
1509 #ifdef USE_ICONV | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1510 subcp_open(); |
10024 | 1511 #endif |
1512 | |
1513 s = demuxer->stream; | |
1514 stream_seek(s, s->start_pos); | |
1515 memset(signature, 0, 4); | |
1516 stream_read(s, (char *)signature, 4); | |
1517 if ((signature[0] != 0x1A) || (signature[1] != 0x45) || | |
1518 (signature[2] != 0xDF) || (signature[3] != 0xA3)) | |
1519 return 0; | |
1520 stream_seek(s, s->start_pos); | |
1521 | |
1522 try { | |
1523 // structure for storing the demuxer's private data | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1524 mkv_d = (mkv_demuxer_t *)safemalloc(sizeof(mkv_demuxer_t)); |
10024 | 1525 memset(mkv_d, 0, sizeof(mkv_demuxer_t)); |
1526 mkv_d->duration = -1.0; | |
1527 | |
1528 // Create the interface between MPlayer's IO system and | |
1529 // libmatroska's IO system. | |
1530 mkv_d->in = new mpstream_io_callback(demuxer->stream); | |
1531 if (mkv_d->in == NULL) { | |
1532 free_mkv_demuxer(mkv_d); | |
1533 return 0; | |
1534 } | |
1535 mpstream_io_callback &io = *static_cast<mpstream_io_callback *>(mkv_d->in); | |
1536 mkv_d->es = new EbmlStream(io); | |
1537 if (mkv_d->es == NULL) { | |
1538 free_mkv_demuxer(mkv_d); | |
1539 return 0; | |
1540 } | |
1541 es = mkv_d->es; | |
1542 | |
1543 // Find the EbmlHead element. Must be the first one. | |
10638 | 1544 l0 = es->FindNextID(EbmlHead::ClassInfos, 0xFFFFFFFFFFFFFFFFULL); |
10024 | 1545 if (l0 == NULL) { |
1546 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] no head found\n"); | |
1547 free_mkv_demuxer(mkv_d); | |
1548 return 0; | |
1549 } | |
1550 // Don't verify its data for now. | |
1551 l0->SkipData(static_cast<EbmlStream &>(*es), l0->Generic().Context); | |
1552 delete l0; | |
1553 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Found the head...\n"); | |
1554 | |
1555 // Next element must be a segment | |
10638 | 1556 l0 = es->FindNextID(KaxSegment::ClassInfos, 0xFFFFFFFFFFFFFFFFULL); |
10024 | 1557 if (l0 == NULL) { |
1558 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] but no segment :(\n"); | |
1559 free_mkv_demuxer(mkv_d); | |
1560 return 0; | |
1561 } | |
1562 if (!(EbmlId(*l0) == KaxSegment::ClassInfos.GlobalId)) { | |
1563 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] but no segment :(\n"); | |
1564 free_mkv_demuxer(mkv_d); | |
1565 return 0; | |
1566 } | |
1567 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] + a segment...\n"); | |
1568 | |
1569 mkv_d->segment = (KaxSegment *)l0; | |
10149
bb1d5c054148
Delayed the parsing of the cues for the case that the KaxInfos (and therefore the timecode scale) is located after the meta seek stuff.
mosu
parents:
10133
diff
changeset
|
1570 mkv_d->tc_scale = MKVD_TIMECODESCALE; |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1571 mkv_d->parsed_seekheads = new vector<uint64_t>; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1572 mkv_d->parsed_cues = new vector<uint64_t>; |
10024 | 1573 |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1574 vid = 0; |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1575 aid = 0; |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1576 sid = 0; |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1577 |
10024 | 1578 upper_lvl_el = 0; |
1579 exit_loop = 0; | |
1580 // We've got our segment, so let's find the tracks | |
1581 l1 = es->FindNextElement(l0->Generic().Context, upper_lvl_el, 0xFFFFFFFFL, | |
1582 true, 1); | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1583 while ((l1 != NULL) && (upper_lvl_el <= 0)) { |
10024 | 1584 |
1585 if (EbmlId(*l1) == KaxInfo::ClassInfos.GlobalId) { | |
1586 // General info about this Matroska file | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1587 KaxTimecodeScale *ktc_scale; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1588 KaxDuration *kduration; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1589 |
10024 | 1590 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |+ segment information...\n"); |
1591 | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1592 l1->Read(*es, KaxInfo::ClassInfos.Context, upper_lvl_el, l2, true); |
10024 | 1593 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1594 ktc_scale = FINDFIRST(l1, KaxTimecodeScale); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1595 if (ktc_scale != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1596 mkv_d->tc_scale = uint64(*ktc_scale); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1597 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + timecode scale: %llu\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1598 mkv_d->tc_scale); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1599 } else |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1600 mkv_d->tc_scale = MKVD_TIMECODESCALE; |
10024 | 1601 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1602 kduration = FINDFIRST(l1, KaxDuration); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1603 if (kduration != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1604 mkv_d->duration = float(*kduration) * mkv_d->tc_scale / 1000000000.0; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1605 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + duration: %.3fs\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1606 mkv_d->duration); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1607 } |
10024 | 1608 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1609 l1->SkipData(*es, l1->Generic().Context); |
10024 | 1610 |
1611 } else if (EbmlId(*l1) == KaxTracks::ClassInfos.GlobalId) { | |
1612 // Yep, we've found our KaxTracks element. Now find all tracks | |
1613 // contained in this segment. | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1614 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1615 KaxTrackEntry *ktentry; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1616 |
10024 | 1617 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |+ segment tracks...\n"); |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1618 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1619 l1->Read(*es, KaxTracks::ClassInfos.Context, upper_lvl_el, l2, true); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1620 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1621 ktentry = FINDFIRST(l1, KaxTrackEntry); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1622 while (ktentry != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1623 // We actually found a track entry :) We're happy now. |
10024 | 1624 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1625 KaxTrackNumber *ktnum; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1626 KaxTrackDefaultDuration *kdefdur; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1627 KaxTrackType *kttype; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1628 KaxTrackAudio *ktaudio; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1629 KaxTrackVideo *ktvideo; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1630 KaxCodecID *kcodecid; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1631 KaxCodecPrivate *kcodecpriv; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1632 KaxTrackFlagDefault *ktfdefault; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1633 KaxTrackLanguage *ktlanguage; |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1634 #if LIBMATROSKA_VERSION >= 000503 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1635 KaxContentEncodings *kcencodings; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1636 int kcenc_idx; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1637 vector<mkv_content_encoding_t>::iterator ce_ins_it; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1638 #endif |
10024 | 1639 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1640 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + a track...\n"); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1641 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1642 track = new_mkv_track(mkv_d); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1643 if (track == NULL) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1644 return 0; |
10024 | 1645 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1646 ktnum = FINDFIRST(ktentry, KaxTrackNumber); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1647 if (ktnum != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1648 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Track number: %u\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1649 uint32(*ktnum)); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1650 track->tnum = uint32(*ktnum); |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1651 if (find_duplicate_track_by_num(mkv_d, track->tnum, track) != NULL) |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1652 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] | + WARNING: There's " |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1653 "more than one track with the number %u.\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1654 track->tnum); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1655 } |
10024 | 1656 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1657 kdefdur = FINDFIRST(ktentry, KaxTrackDefaultDuration); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1658 if (kdefdur != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1659 if (uint64(*kdefdur) == 0) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1660 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Default duration: 0"); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1661 else { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1662 track->v_frate = 1000000000.0 / (float)uint64(*kdefdur); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1663 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Default duration: " |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1664 "%.3fms ( = %.3f fps)\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1665 (float)uint64(*kdefdur) / 1000000.0, track->v_frate); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1666 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1667 } |
10024 | 1668 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1669 kttype = FINDFIRST(ktentry, KaxTrackType); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1670 if (kttype != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1671 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Track type: "); |
10081
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
1672 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1673 switch (uint8(*kttype)) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1674 case track_audio: |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1675 mp_msg(MSGT_DEMUX, MSGL_V, "Audio\n"); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1676 track->type = 'a'; |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1677 track->xid = aid; |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1678 aid++; |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1679 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1680 case track_video: |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1681 mp_msg(MSGT_DEMUX, MSGL_V, "Video\n"); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1682 track->type = 'v'; |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1683 track->xid = vid; |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1684 vid++; |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1685 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1686 case track_subtitle: |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1687 mp_msg(MSGT_DEMUX, MSGL_V, "Subtitle\n"); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1688 track->type = 's'; |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1689 track->xid = sid; |
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
1690 sid++; |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1691 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1692 default: |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1693 mp_msg(MSGT_DEMUX, MSGL_V, "unknown\n"); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1694 track->type = '?'; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1695 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1696 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1697 } |
10024 | 1698 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1699 ktaudio = FINDFIRST(ktentry, KaxTrackAudio); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1700 if (ktaudio != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1701 KaxAudioSamplingFreq *ka_sfreq; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1702 KaxAudioChannels *ka_channels; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1703 KaxAudioBitDepth *ka_bitdepth; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1704 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1705 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Audio track\n"); |
10024 | 1706 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1707 ka_sfreq = FINDFIRST(ktaudio, KaxAudioSamplingFreq); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1708 if (ka_sfreq != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1709 track->a_sfreq = float(*ka_sfreq); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1710 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Sampling " |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1711 "frequency: %f\n", track->a_sfreq); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1712 } else |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1713 track->a_sfreq = 8000.0; |
10024 | 1714 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1715 ka_channels = FINDFIRST(ktaudio, KaxAudioChannels); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1716 if (ka_channels != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1717 track->a_channels = uint8(*ka_channels); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1718 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Channels: %u\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1719 track->a_channels); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1720 } else |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1721 track->a_channels = 1; |
10024 | 1722 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1723 ka_bitdepth = FINDFIRST(ktaudio, KaxAudioBitDepth); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1724 if (ka_bitdepth != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1725 track->a_bps = uint8(*ka_bitdepth); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1726 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Bit depth: %u\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1727 track->a_bps); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1728 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1729 |
10024 | 1730 } |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1731 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1732 ktvideo = FINDFIRST(ktentry, KaxTrackVideo); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1733 if (ktvideo != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1734 KaxVideoPixelWidth *kv_pwidth; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1735 KaxVideoPixelHeight *kv_pheight; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1736 KaxVideoDisplayWidth *kv_dwidth; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1737 KaxVideoDisplayHeight *kv_dheight; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1738 KaxVideoFrameRate *kv_frate; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1739 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1740 kv_pwidth = FINDFIRST(ktvideo, KaxVideoPixelWidth); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1741 if (kv_pwidth != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1742 track->v_width = uint16(*kv_pwidth); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1743 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel width: %u\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1744 track->v_width); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1745 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1746 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1747 kv_pheight = FINDFIRST(ktvideo, KaxVideoPixelHeight); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1748 if (kv_pheight != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1749 track->v_height = uint16(*kv_pheight); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1750 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel height: %u\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1751 track->v_height); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1752 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1753 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1754 kv_dwidth = FINDFIRST(ktvideo, KaxVideoDisplayWidth); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1755 if (kv_dwidth != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1756 track->v_dwidth = uint16(*kv_dwidth); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1757 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Display width: %u\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1758 track->v_dwidth); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1759 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1760 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1761 kv_dheight = FINDFIRST(ktvideo, KaxVideoDisplayHeight); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1762 if (kv_dheight != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1763 track->v_dheight = uint16(*kv_dheight); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1764 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Display height: %u\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1765 track->v_dheight); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1766 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1767 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1768 // For older files. |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1769 kv_frate = FINDFIRST(ktvideo, KaxVideoFrameRate); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1770 if (kv_frate != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1771 track->v_frate = float(*kv_frate); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1772 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Frame rate: %f\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1773 track->v_frate); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1774 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1775 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1776 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1777 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1778 kcodecid = FINDFIRST(ktentry, KaxCodecID); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1779 if (kcodecid != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1780 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Codec ID: %s\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1781 string(*kcodecid).c_str()); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1782 track->codec_id = strdup(string(*kcodecid).c_str()); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1783 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1784 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1785 kcodecpriv = FINDFIRST(ktentry, KaxCodecPrivate); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1786 if (kcodecpriv != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1787 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + CodecPrivate, length " |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1788 "%llu\n", kcodecpriv->GetSize()); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1789 track->private_size = kcodecpriv->GetSize(); |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1790 if (track->private_size > 0) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1791 track->private_data = safememdup(kcodecpriv->GetBuffer(), |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1792 track->private_size); |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1793 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1794 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1795 ktfdefault = FINDFIRST(ktentry, KaxTrackFlagDefault); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1796 if (ktfdefault != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1797 track->default_track = uint32(*ktfdefault); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1798 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Default flag: %u\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1799 track->default_track); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1800 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1801 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1802 ktlanguage = FINDFIRST(ktentry, KaxTrackLanguage); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1803 if (ktlanguage != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1804 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Language: %s\n", |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1805 string(*ktlanguage).c_str()); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1806 if (track->language != NULL) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1807 free(track->language); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1808 track->language = strdup(string(*ktlanguage).c_str()); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1809 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1810 |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1811 #if LIBMATROSKA_VERSION >= 000503 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1812 kcencodings = FINDFIRST(ktentry, KaxContentEncodings); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1813 if (kcencodings != NULL) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1814 for (kcenc_idx = 0; kcenc_idx < (int)kcencodings->ListSize(); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1815 kcenc_idx++) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1816 EbmlElement *l3; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1817 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1818 l3 = (*kcencodings)[kcenc_idx]; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1819 if (EbmlId(*l3) == KaxContentEncoding::ClassInfos.GlobalId) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1820 KaxContentEncoding *kcenc; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1821 KaxContentEncodingOrder *ce_order; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1822 KaxContentEncodingType *ce_type; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1823 KaxContentEncodingScope *ce_scope; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1824 KaxContentCompression *ce_comp; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1825 KaxContentEncryption *ce_enc; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1826 mkv_content_encoding_t enc; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1827 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1828 memset(&enc, 0, sizeof(mkv_content_encoding_t)); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1829 kcenc = static_cast<KaxContentEncoding *>(l3); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1830 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1831 ce_order = FINDFIRST(kcenc, KaxContentEncodingOrder); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1832 if (ce_order != NULL) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1833 enc.order = uint32(*ce_order); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1834 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1835 ce_type = FINDFIRST(kcenc, KaxContentEncodingType); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1836 if (ce_type != NULL) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1837 enc.type = uint32(*ce_type); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1838 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1839 ce_scope = FINDFIRST(kcenc, KaxContentEncodingScope); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1840 if (ce_scope != NULL) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1841 enc.scope = uint32(*ce_scope); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1842 else |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1843 enc.scope = 1; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1844 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1845 ce_comp = FINDFIRST(kcenc, KaxContentCompression); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1846 if (ce_comp != NULL) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1847 KaxContentCompAlgo *cc_algo; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1848 KaxContentCompSettings *cc_settings; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1849 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1850 cc_algo = FINDFIRST(ce_comp, KaxContentCompAlgo); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1851 if (cc_algo != NULL) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1852 enc.comp_algo = uint32(*cc_algo); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1853 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1854 cc_settings = FINDFIRST(ce_comp, KaxContentCompSettings); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1855 if (cc_settings != NULL) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1856 enc.comp_settings = |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1857 (unsigned char *)safememdup(&binary(*cc_settings), |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1858 cc_settings->GetSize()); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1859 enc.comp_settings_len = cc_settings->GetSize(); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1860 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1861 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1862 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1863 ce_enc = FINDFIRST(kcenc, KaxContentEncryption); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1864 if (ce_enc != NULL) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1865 KaxContentEncAlgo *ce_ealgo; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1866 KaxContentEncKeyID *ce_ekeyid; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1867 KaxContentSigAlgo *ce_salgo; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1868 KaxContentSigHashAlgo *ce_shalgo; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1869 KaxContentSigKeyID *ce_skeyid; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1870 KaxContentSignature *ce_signature; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1871 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1872 ce_ealgo = FINDFIRST(ce_enc, KaxContentEncAlgo); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1873 if (ce_ealgo != NULL) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1874 enc.enc_algo = uint32(*ce_ealgo); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1875 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1876 ce_ekeyid = FINDFIRST(ce_enc, KaxContentEncKeyID); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1877 if (ce_ekeyid != NULL) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1878 enc.enc_keyid = |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1879 (unsigned char *)safememdup(&binary(*ce_ekeyid), |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1880 ce_ekeyid->GetSize()); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1881 enc.enc_keyid_len = ce_ekeyid->GetSize(); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1882 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1883 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1884 ce_salgo = FINDFIRST(ce_enc, KaxContentSigAlgo); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1885 if (ce_salgo != NULL) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1886 enc.enc_algo = uint32(*ce_salgo); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1887 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1888 ce_shalgo = FINDFIRST(ce_enc, KaxContentSigHashAlgo); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1889 if (ce_shalgo != NULL) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1890 enc.enc_algo = uint32(*ce_shalgo); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1891 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1892 ce_skeyid = FINDFIRST(ce_enc, KaxContentSigKeyID); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1893 if (ce_skeyid != NULL) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1894 enc.sig_keyid = |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1895 (unsigned char *)safememdup(&binary(*ce_skeyid), |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1896 ce_skeyid->GetSize()); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1897 enc.sig_keyid_len = ce_skeyid->GetSize(); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1898 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1899 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1900 ce_signature = FINDFIRST(ce_enc, KaxContentSignature); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1901 if (ce_signature != NULL) { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1902 enc.signature = |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1903 (unsigned char *)safememdup(&binary(*ce_signature), |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1904 ce_signature->GetSize()); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1905 enc.signature_len = ce_signature->GetSize(); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1906 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1907 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1908 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1909 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1910 ce_ins_it = track->c_encodings->begin(); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1911 while ((ce_ins_it != track->c_encodings->end()) && |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1912 (enc.order <= (*ce_ins_it).order)) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1913 ce_ins_it++; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1914 track->c_encodings->insert(ce_ins_it, enc); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1915 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1916 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1917 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1918 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1919 #endif |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1920 ktentry = FINDNEXT(l1, KaxTrackEntry, ktentry); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1921 } // while (ktentry != NULL) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1922 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1923 l1->SkipData(*es, l1->Generic().Context); |
10024 | 1924 |
1925 } else if (EbmlId(*l1) == KaxSeekHead::ClassInfos.GlobalId) { | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1926 if (!find_in_vector(seekheads_to_parse, l1->GetElementPosition())) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1927 seekheads_to_parse.push_back(l1->GetElementPosition()); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1928 l1->SkipData(*es, l1->Generic().Context); |
10024 | 1929 |
1930 } else if ((EbmlId(*l1) == KaxCues::ClassInfos.GlobalId) && | |
1931 !mkv_d->cues_found) { | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1932 if (!find_in_vector(cues_to_parse, l1->GetElementPosition())) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1933 cues_to_parse.push_back(l1->GetElementPosition()); |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1934 l1->SkipData(*es, l1->Generic().Context); |
10024 | 1935 |
11260 | 1936 } else if (EbmlId(*l1) == KaxChapters::ClassInfos.GlobalId) { |
1937 parse_chapters(mkv_d, l1->GetElementPosition()); | |
1938 l1->SkipData(*es, l1->Generic().Context); | |
1939 | |
10024 | 1940 } else if (EbmlId(*l1) == KaxCluster::ClassInfos.GlobalId) { |
1941 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |+ found cluster, headers are " | |
1942 "parsed completely :)\n"); | |
1943 add_cluster_position(mkv_d, l1->GetElementPosition()); | |
1944 mkv_d->saved_l1 = l1; | |
1945 exit_loop = 1; | |
1946 | |
1947 } else | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1948 l1->SkipData(*es, l1->Generic().Context); |
10024 | 1949 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1950 if (!in_parent(l0)) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1951 delete l1; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1952 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1953 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1954 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1955 if (upper_lvl_el > 0) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1956 upper_lvl_el--; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1957 if (upper_lvl_el > 0) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1958 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1959 delete l1; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1960 l1 = l2; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1961 continue; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1962 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1963 } else if (upper_lvl_el < 0) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1964 upper_lvl_el++; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1965 if (upper_lvl_el < 0) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1966 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1967 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1968 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1969 |
10024 | 1970 if (exit_loop) // we've found the first cluster, so get out |
1971 break; | |
1972 | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1973 l1->SkipData(*es, l1->Generic().Context); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1974 delete l1; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1975 l1 = es->FindNextElement(l0->Generic().Context, upper_lvl_el, |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1976 0xFFFFFFFFL, true); |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
1977 |
10024 | 1978 } // while (l1 != NULL) |
1979 | |
1980 if (!exit_loop) { | |
1981 free_mkv_demuxer(mkv_d); | |
1982 return 0; | |
1983 } | |
1984 | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1985 current_pos = io.getFilePointer(); |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1986 |
10283
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1987 // Try to find the very first timecode (cluster timecode). |
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1988 l2 = es->FindNextElement(l1->Generic().Context, upper_lvl_el, |
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1989 0xFFFFFFFFL, true, 1); |
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1990 if ((l2 != NULL) && !upper_lvl_el && |
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1991 (EbmlId(*l2) == KaxClusterTimecode::ClassInfos.GlobalId)) { |
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1992 KaxClusterTimecode &ctc = *static_cast<KaxClusterTimecode *>(l2); |
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1993 ctc.ReadData(es->I_O()); |
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1994 mkv_d->first_tc = uint64(ctc) * mkv_d->tc_scale / 1000000; |
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1995 delete l2; |
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1996 } else |
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1997 mkv_d->first_tc = 0; |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1998 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1999 // Parse all cues and seek heads |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
2000 for (i = 0; i < (int)cues_to_parse.size(); i++) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
2001 parse_cues(mkv_d, cues_to_parse[i]); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
2002 for (i = 0; i < (int)seekheads_to_parse.size(); i++) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
2003 parse_seekhead(mkv_d, seekheads_to_parse[i]); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
2004 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2005 io.setFilePointer(current_pos); |
10149
bb1d5c054148
Delayed the parsing of the cues for the case that the KaxInfos (and therefore the timecode scale) is located after the meta seek stuff.
mosu
parents:
10133
diff
changeset
|
2006 |
10024 | 2007 } catch (exception &ex) { |
2008 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] caught exception\n"); | |
2009 return 0; | |
2010 } | |
2011 | |
2012 if (!check_track_information(mkv_d)) { | |
2013 free_mkv_demuxer(mkv_d); | |
2014 return 0; | |
2015 } | |
2016 | |
2017 track = NULL; | |
2018 if (demuxer->video->id == -1) { // Automatically select a video track. | |
2019 // Search for a video track that has the 'default' flag set. | |
2020 for (i = 0; i < mkv_d->num_tracks; i++) | |
2021 if ((mkv_d->tracks[i]->type == 'v') && mkv_d->tracks[i]->ok && | |
2022 mkv_d->tracks[i]->default_track) { | |
2023 track = mkv_d->tracks[i]; | |
2024 break; | |
2025 } | |
2026 | |
2027 if (track == NULL) | |
2028 // No track has the 'default' flag set - let's take the first video | |
2029 // track. | |
2030 for (i = 0; i < mkv_d->num_tracks; i++) | |
2031 if ((mkv_d->tracks[i]->type == 'v') && mkv_d->tracks[i]->ok) { | |
2032 track = mkv_d->tracks[i]; | |
2033 break; | |
2034 } | |
2035 } else if (demuxer->video->id != -2) // -2 = no video at all | |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
2036 track = find_track_by_num(mkv_d, demuxer->video->id, 'v'); |
10024 | 2037 |
2038 if (track) { | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2039 BITMAPINFOHEADER *bih; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2040 |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2041 idesc = NULL; |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2042 |
10024 | 2043 if (track->ms_compat) { // MS compatibility mode |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2044 BITMAPINFOHEADER *src; |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2045 src = (BITMAPINFOHEADER *)track->private_data; |
11329
9165908f87d3
Fixed wrong allocation of the BITMAPINFOHEADER structure which would crash mplayer in some cases.
mosu
parents:
11321
diff
changeset
|
2046 bih = (BITMAPINFOHEADER *)safemalloc(track->private_size); |
9165908f87d3
Fixed wrong allocation of the BITMAPINFOHEADER structure which would crash mplayer in some cases.
mosu
parents:
11321
diff
changeset
|
2047 memset(bih, 0, track->private_size); |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2048 bih->biSize = get_uint32(&src->biSize); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2049 bih->biWidth = get_uint32(&src->biWidth); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2050 bih->biHeight = get_uint32(&src->biHeight); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2051 bih->biPlanes = get_uint16(&src->biPlanes); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2052 bih->biBitCount = get_uint16(&src->biBitCount); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2053 bih->biCompression = get_uint32(&src->biCompression); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2054 bih->biSizeImage = get_uint32(&src->biSizeImage); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2055 bih->biXPelsPerMeter = get_uint32(&src->biXPelsPerMeter); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2056 bih->biYPelsPerMeter = get_uint32(&src->biYPelsPerMeter); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2057 bih->biClrUsed = get_uint32(&src->biClrUsed); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2058 bih->biClrImportant = get_uint32(&src->biClrImportant); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2059 memcpy((char *)bih + sizeof(BITMAPINFOHEADER), |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2060 (char *)src + sizeof(BITMAPINFOHEADER), |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2061 track->private_size - sizeof(BITMAPINFOHEADER)); |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2062 |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2063 } else { |
11329
9165908f87d3
Fixed wrong allocation of the BITMAPINFOHEADER structure which would crash mplayer in some cases.
mosu
parents:
11321
diff
changeset
|
2064 bih = (BITMAPINFOHEADER *)safemalloc(sizeof(BITMAPINFOHEADER)); |
9165908f87d3
Fixed wrong allocation of the BITMAPINFOHEADER structure which would crash mplayer in some cases.
mosu
parents:
11321
diff
changeset
|
2065 memset(bih, 0, sizeof(BITMAPINFOHEADER)); |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2066 bih->biSize = sizeof(BITMAPINFOHEADER); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2067 bih->biWidth = track->v_width; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2068 bih->biHeight = track->v_height; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2069 bih->biBitCount = 24; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2070 bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount / 8; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2071 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2072 if ((track->private_size >= sizeof(real_video_props_t)) && |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2073 (!strcmp(track->codec_id, MKV_V_REALV10) || |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2074 !strcmp(track->codec_id, MKV_V_REALV20) || |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2075 !strcmp(track->codec_id, MKV_V_REALV30) || |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2076 !strcmp(track->codec_id, MKV_V_REALV40))) { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2077 unsigned char *dst, *src; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2078 real_video_props_t *rvp; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2079 uint32_t type2; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2080 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2081 rvp = (real_video_props_t *)track->private_data; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2082 src = (unsigned char *)(rvp + 1); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2083 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2084 bih = (BITMAPINFOHEADER *)realloc(bih, sizeof(BITMAPINFOHEADER) + 12); |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2085 bih->biSize = 48; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2086 bih->biPlanes = 1; |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2087 type2 = get_uint32_be(&rvp->type2); |
10438
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
2088 if ((type2 == 0x10003000) || (type2 == 0x10003001)) |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2089 bih->biCompression = mmioFOURCC('R', 'V', '1', '3'); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2090 else |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2091 bih->biCompression = mmioFOURCC('R', 'V', track->codec_id[9], '0'); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2092 dst = (unsigned char *)(bih + 1); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2093 ((unsigned int *)dst)[0] = get_uint32_be(&rvp->type1); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2094 ((unsigned int *)dst)[1] = type2; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2095 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2096 if ((bih->biCompression <= 0x30335652) && |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2097 (type2 >= 0x20200002)) { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2098 // read secondary WxH for the cmsg24[] (see vd_realvid.c) |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2099 ((unsigned short *)(bih + 1))[4] = 4 * (unsigned short)src[0]; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2100 ((unsigned short *)(bih + 1))[5] = 4 * (unsigned short)src[1]; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2101 } else |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2102 memset(&dst[8], 0, 4); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2103 track->realmedia = true; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2104 |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2105 #if defined(USE_QTX_CODECS) |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2106 } else if ((track->private_size >= sizeof(qt_image_description_t)) && |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2107 (!strcmp(track->codec_id, MKV_V_QUICKTIME))) { |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2108 idesc = (qt_image_description_t *)track->private_data; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2109 idesc->id_size = get_uint32_be(&idesc->id_size); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2110 idesc->codec_type = get_uint32(&idesc->codec_type); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2111 idesc->version = get_uint16_be(&idesc->version); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2112 idesc->revision = get_uint16_be(&idesc->revision); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2113 idesc->vendor = get_uint32_be(&idesc->vendor); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2114 idesc->temporal_quality = get_uint32_be(&idesc->temporal_quality); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2115 idesc->spatial_quality = get_uint32_be(&idesc->spatial_quality); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2116 idesc->width = get_uint16_be(&idesc->width); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2117 idesc->height = get_uint16_be(&idesc->height); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2118 idesc->horizontal_resolution = |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2119 get_uint32_be(&idesc->horizontal_resolution); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2120 idesc->vertical_resolution = |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2121 get_uint32_be(&idesc->vertical_resolution); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2122 idesc->data_size = get_uint32_be(&idesc->data_size); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2123 idesc->frame_count = get_uint16_be(&idesc->frame_count); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2124 idesc->depth = get_uint16_be(&idesc->depth); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2125 idesc->color_table_id = get_uint16_be(&idesc->color_table_id); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2126 bih->biPlanes = 1; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2127 bih->biCompression = idesc->codec_type; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2128 #endif // defined(USE_QTX_CODECS) |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2129 |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2130 } else { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2131 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Unknown/unsupported CodecID " |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2132 "(%s) or missing/bad CodecPrivate data (track %u).\n", |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2133 track->codec_id, track->tnum); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2134 demuxer->video->id = -2; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2135 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2136 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2137 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2138 if (demuxer->video->id != -2) { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2139 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Will play video track %u\n", |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2140 track->tnum); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2141 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2142 sh_v = new_sh_video(demuxer, track->tnum); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2143 sh_v->bih = bih; |
10024 | 2144 sh_v->format = sh_v->bih->biCompression; |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2145 if (track->v_frate == 0.0) |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2146 track->v_frate = 25.0; |
10024 | 2147 sh_v->fps = track->v_frate; |
2148 sh_v->frametime = 1 / track->v_frate; | |
10081
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
2149 sh_v->disp_w = track->v_width; |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
2150 sh_v->disp_h = track->v_height; |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
2151 sh_v->aspect = (float)track->v_dwidth / (float)track->v_dheight; |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2152 if (idesc != NULL) |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2153 sh_v->ImageDesc = idesc; |
10081
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
2154 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Aspect: %f\n", sh_v->aspect); |
10024 | 2155 |
2156 demuxer->video->id = track->tnum; | |
2157 demuxer->video->sh = sh_v; | |
2158 sh_v->ds = demuxer->video; | |
2159 | |
2160 mkv_d->video = track; | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2161 } else |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2162 free(bih); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2163 |
10024 | 2164 } else { |
2165 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] No video track found/wanted.\n"); | |
2166 demuxer->video->id = -2; | |
2167 } | |
2168 | |
2169 track = NULL; | |
2170 if (demuxer->audio->id == -1) { // Automatically select an audio track. | |
10167
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2171 // check if the user specified an audio language |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2172 if (audio_lang != NULL) { |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2173 track = find_track_by_language(mkv_d, audio_lang, NULL, 'a'); |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2174 } |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2175 if (track == NULL) |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2176 // no audio language specified, or language not found |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2177 // Search for an audio track that has the 'default' flag set. |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2178 for (i = 0; i < mkv_d->num_tracks; i++) |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2179 if ((mkv_d->tracks[i]->type == 'a') && mkv_d->tracks[i]->ok && |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2180 mkv_d->tracks[i]->default_track) { |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2181 track = mkv_d->tracks[i]; |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2182 break; |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2183 } |
10024 | 2184 |
2185 if (track == NULL) | |
2186 // No track has the 'default' flag set - let's take the first audio | |
2187 // track. | |
2188 for (i = 0; i < mkv_d->num_tracks; i++) | |
2189 if ((mkv_d->tracks[i]->type == 'a') && mkv_d->tracks[i]->ok) { | |
2190 track = mkv_d->tracks[i]; | |
2191 break; | |
2192 } | |
2193 } else if (demuxer->audio->id != -2) // -2 = no audio at all | |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
2194 track = find_track_by_num(mkv_d, demuxer->audio->id, 'a'); |
10024 | 2195 |
2196 if (track) { | |
2197 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Will play audio track %u\n", | |
2198 track->tnum); | |
2199 sh_a = new_sh_audio(demuxer, track->tnum); | |
2200 | |
2201 demuxer->audio->id = track->tnum; | |
2202 demuxer->audio->sh = sh_a; | |
2203 sh_a->ds = demuxer->audio; | |
2204 | |
2205 mkv_d->audio = track; | |
2206 | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2207 if (track->ms_compat) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2208 sh_a->wf = (WAVEFORMATEX *)safememdup(track->private_data, |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2209 track->private_size); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2210 else { |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2211 sh_a->wf = (WAVEFORMATEX *)safemalloc(sizeof(WAVEFORMATEX)); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2212 memset(sh_a->wf, 0, sizeof(WAVEFORMATEX)); |
10024 | 2213 } |
10125 | 2214 sh_a->format = track->a_formattag; |
2215 sh_a->wf->wFormatTag = track->a_formattag; | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2216 sh_a->channels = track->a_channels; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2217 sh_a->wf->nChannels = track->a_channels; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2218 sh_a->samplerate = (uint32_t)track->a_sfreq; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2219 sh_a->wf->nSamplesPerSec = (uint32_t)track->a_sfreq; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2220 sh_a->samplesize = track->a_bps / 8; |
11155 | 2221 if (!strcmp(track->codec_id, MKV_A_MP3) || |
2222 !strcmp(track->codec_id, MKV_A_MP2)) { | |
10024 | 2223 sh_a->wf->nAvgBytesPerSec = 16000; |
2224 sh_a->wf->nBlockAlign = 1152; | |
2225 sh_a->wf->wBitsPerSample = 0; | |
2226 sh_a->samplesize = 0; | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2227 |
11114
d8ddd7727084
More liberal codec id recognition for AC3 codecs (needed for transcoded DNET from RM).
mosu
parents:
10984
diff
changeset
|
2228 } else if (!strncmp(track->codec_id, MKV_A_AC3, strlen(MKV_A_AC3))) { |
10024 | 2229 sh_a->wf->nAvgBytesPerSec = 16000; |
2230 sh_a->wf->nBlockAlign = 1536; | |
2231 sh_a->wf->wBitsPerSample = 0; | |
2232 sh_a->samplesize = 0; | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2233 |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2234 } else if (!strcmp(track->codec_id, MKV_A_PCM) || |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2235 !strcmp(track->codec_id, MKV_A_PCM_BE)) { |
10024 | 2236 sh_a->wf->nAvgBytesPerSec = sh_a->channels * sh_a->samplerate * 2; |
2237 sh_a->wf->nBlockAlign = sh_a->wf->nAvgBytesPerSec; | |
2238 sh_a->wf->wBitsPerSample = track->a_bps; | |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2239 if (!strcmp(track->codec_id, MKV_A_PCM_BE)) |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2240 sh_a->format = mmioFOURCC('t', 'w', 'o', 's'); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2241 |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2242 } else if (!strcmp(track->codec_id, MKV_A_QDMC) || |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2243 !strcmp(track->codec_id, MKV_A_QDMC2)) { |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2244 sh_a->wf->wBitsPerSample = track->a_bps; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2245 sh_a->wf->nAvgBytesPerSec = 16000; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2246 sh_a->wf->nBlockAlign = 1486; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2247 track->fix_i_bps = true; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2248 track->qt_last_a_pts = 0.0; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2249 if (track->private_data != NULL) { |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2250 sh_a->codecdata = (unsigned char *)safememdup(track->private_data, |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2251 track->private_size); |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2252 sh_a->codecdata_len = track->private_size; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2253 } |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2254 if (!strcmp(track->codec_id, MKV_A_QDMC)) |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2255 sh_a->format = mmioFOURCC('Q', 'D', 'M', 'C'); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2256 else |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2257 sh_a->format = mmioFOURCC('Q', 'D', 'M', '2'); |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2258 |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2259 } else if (track->a_formattag == mmioFOURCC('M', 'P', '4', 'A')) { |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2260 int profile, srate_idx; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2261 |
10125 | 2262 sh_a->wf->nAvgBytesPerSec = 16000; |
2263 sh_a->wf->nBlockAlign = 1024; | |
2264 sh_a->wf->wBitsPerSample = 0; | |
2265 sh_a->samplesize = 0; | |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2266 |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2267 // Recreate the 'private data' which faad2 uses in its initialization. |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2268 // A_AAC/MPEG2/MAIN |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2269 // 0123456789012345 |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2270 if (!strcmp(&track->codec_id[12], "MAIN")) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2271 profile = 0; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2272 else if (!strcmp(&track->codec_id[12], "LC")) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2273 profile = 1; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2274 else if (!strcmp(&track->codec_id[12], "SSR")) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2275 profile = 2; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2276 else |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2277 profile = 3; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2278 if (92017 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2279 srate_idx = 0; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2280 else if (75132 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2281 srate_idx = 1; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2282 else if (55426 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2283 srate_idx = 2; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2284 else if (46009 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2285 srate_idx = 3; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2286 else if (37566 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2287 srate_idx = 4; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2288 else if (27713 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2289 srate_idx = 5; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2290 else if (23004 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2291 srate_idx = 6; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2292 else if (18783 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2293 srate_idx = 7; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2294 else if (13856 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2295 srate_idx = 8; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2296 else if (11502 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2297 srate_idx = 9; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2298 else if (9391 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2299 srate_idx = 10; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2300 else |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2301 srate_idx = 11; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2302 |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2303 sh_a->codecdata = (unsigned char *)safemalloc(2); |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2304 sh_a->codecdata_len = 2; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2305 sh_a->codecdata[0] = ((profile + 1) << 3) | ((srate_idx & 0xe) >> 1); |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2306 sh_a->codecdata[1] = ((srate_idx & 0x1) << 7) | (track->a_channels << 3); |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2307 |
10024 | 2308 } else if (!strcmp(track->codec_id, MKV_A_VORBIS)) { |
2309 for (i = 0; i < 3; i++) { | |
2310 dp = new_demux_packet(track->header_sizes[i]); | |
2311 memcpy(dp->buffer, track->headers[i], track->header_sizes[i]); | |
2312 dp->pts = 0; | |
2313 dp->flags = 0; | |
2314 ds_add_packet(demuxer->audio, dp); | |
2315 } | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2316 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2317 } else if ((track->private_size >= sizeof(real_audio_v4_props_t)) && |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2318 !strncmp(track->codec_id, MKV_A_REALATRC, 7)) { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2319 // Common initialization for all RealAudio codecs |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2320 real_audio_v4_props_t *ra4p; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2321 real_audio_v5_props_t *ra5p; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2322 unsigned char *src; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2323 int codecdata_length, version; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2324 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2325 ra4p = (real_audio_v4_props_t *)track->private_data; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2326 ra5p = (real_audio_v5_props_t *)track->private_data; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2327 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2328 sh_a->wf->wBitsPerSample = sh_a->samplesize * 8; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2329 sh_a->wf->nAvgBytesPerSec = 0; // FIXME !? |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2330 sh_a->wf->nBlockAlign = get_uint16_be(&ra4p->frame_size); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2331 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2332 version = get_uint16_be(&ra4p->version1); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2333 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2334 if (version == 4) { |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2335 src = (unsigned char *)(ra4p + 1); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2336 src += src[0] + 1; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2337 src += src[0] + 1; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2338 } else |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2339 src = (unsigned char *)(ra5p + 1); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2340 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2341 src += 3; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2342 if (version == 5) |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2343 src++; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2344 codecdata_length = get_uint32_be(src); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2345 src += 4; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2346 sh_a->wf->cbSize = 10 + codecdata_length; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2347 sh_a->wf = (WAVEFORMATEX *)realloc(sh_a->wf, sizeof(WAVEFORMATEX) + |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2348 sh_a->wf->cbSize); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2349 ((short *)(sh_a->wf + 1))[0] = get_uint16_be(&ra4p->sub_packet_size); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2350 ((short *)(sh_a->wf + 1))[1] = get_uint16_be(&ra4p->sub_packet_h); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2351 ((short *)(sh_a->wf + 1))[2] = get_uint16_be(&ra4p->flavor); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2352 ((short *)(sh_a->wf + 1))[3] = get_uint32_be(&ra4p->coded_frame_size); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2353 ((short *)(sh_a->wf + 1))[4] = codecdata_length; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2354 memcpy(((char *)(sh_a->wf + 1)) + 10, src, codecdata_length); |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2355 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2356 track->realmedia = true; |
11478 | 2357 |
11482
a6b69309a791
Support for FLAC in Matroska written in the MS compatibility mode.
mosu
parents:
11478
diff
changeset
|
2358 } else if (!strcmp(track->codec_id, MKV_A_FLAC) || |
a6b69309a791
Support for FLAC in Matroska written in the MS compatibility mode.
mosu
parents:
11478
diff
changeset
|
2359 (track->a_formattag == 0xf1ac)) { |
11484
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2360 unsigned char *ptr; |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2361 int size; |
11478 | 2362 free(sh_a->wf); |
2363 sh_a->wf = NULL; | |
2364 | |
11482
a6b69309a791
Support for FLAC in Matroska written in the MS compatibility mode.
mosu
parents:
11478
diff
changeset
|
2365 if (track->a_formattag == mmioFOURCC('f', 'L', 'a', 'C')) { |
11484
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2366 ptr = (unsigned char *)track->private_data; |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2367 size = track->private_size; |
11482
a6b69309a791
Support for FLAC in Matroska written in the MS compatibility mode.
mosu
parents:
11478
diff
changeset
|
2368 } else { |
a6b69309a791
Support for FLAC in Matroska written in the MS compatibility mode.
mosu
parents:
11478
diff
changeset
|
2369 sh_a->format = mmioFOURCC('f', 'L', 'a', 'C'); |
11484
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2370 ptr = (unsigned char *)track->private_data + sizeof(WAVEFORMATEX); |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2371 size = track->private_size - sizeof(WAVEFORMATEX); |
11482
a6b69309a791
Support for FLAC in Matroska written in the MS compatibility mode.
mosu
parents:
11478
diff
changeset
|
2372 } |
11484
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2373 if ((size < 4) || (ptr[0] != 'f') || (ptr[1] != 'L') || |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2374 (ptr[2] != 'a') || (ptr[3] != 'C')) { |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2375 dp = new_demux_packet(4); |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2376 memcpy(dp->buffer, "fLaC", 4); |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2377 dp->pts = 0; |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2378 dp->flags = 0; |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2379 ds_add_packet(demuxer->audio, dp); |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2380 } |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2381 dp = new_demux_packet(size); |
3abf5b7cb308
Support for FLAC tracks that already contain the "fLaC" header.
mosu
parents:
11482
diff
changeset
|
2382 memcpy(dp->buffer, ptr, size); |
11478 | 2383 dp->pts = 0; |
2384 dp->flags = 0; | |
2385 ds_add_packet(demuxer->audio, dp); | |
10024 | 2386 } |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2387 |
10024 | 2388 } else { |
2389 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] No audio track found/wanted.\n"); | |
2390 demuxer->audio->id = -2; | |
2391 } | |
2392 | |
2393 // DO NOT automatically select a subtitle track and behave like DVD | |
2394 // playback: only show subtitles if the user explicitely wants them. | |
10073
4c4c2761643c
Proper key frame reporting. Proper handling of "no subtitles wanted".
mosu
parents:
10060
diff
changeset
|
2395 track = NULL; |
4c4c2761643c
Proper key frame reporting. Proper handling of "no subtitles wanted".
mosu
parents:
10060
diff
changeset
|
2396 if (demuxer->sub->id >= 0) |
10705
4079bc9b15f9
Track selection uses the n-th audio/subtitle/video track as the ID, not the n-th track overall. All tracks are listed upon opening of the file along with their -aid/-sid etc.
mosu
parents:
10685
diff
changeset
|
2397 track = find_track_by_num(mkv_d, demuxer->sub->id, 's'); |
10073
4c4c2761643c
Proper key frame reporting. Proper handling of "no subtitles wanted".
mosu
parents:
10060
diff
changeset
|
2398 else if (dvdsub_lang != NULL) |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2399 track = find_track_by_language(mkv_d, dvdsub_lang, NULL); |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2400 if (track) { |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2401 if (!strcmp(track->codec_id, MKV_S_VOBSUB)) { |
11154 | 2402 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Will display subtitle track %u\n", |
2403 track->tnum); | |
2404 mkv_d->subs_track = track; | |
2405 mkv_d->subtitle_type = MKV_SUBTYPE_VOBSUB; | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2406 demuxer->sub->sh = (mkv_sh_sub_t *)safememdup(&track->sh_sub, |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2407 sizeof(mkv_sh_sub_t)); |
11154 | 2408 demuxer->sub->id = track->xid; |
2409 | |
11276 | 2410 } else if (strcmp(track->codec_id, MKV_S_TEXTASCII) && |
11154 | 2411 strcmp(track->codec_id, MKV_S_TEXTUTF8) && |
2412 strcmp(track->codec_id, MKV_S_TEXTSSA) && | |
11276 | 2413 strcmp(track->codec_id, "S_SSA") && |
2414 strcmp(track->codec_id, "S_TEXT/ASS")) | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2415 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] Subtitle type '%s' is not " |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2416 "supported. Track will not be displayed.\n", track->codec_id); |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2417 else { |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2418 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Will display subtitle track %u\n", |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2419 track->tnum); |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2420 mkv_d->subs_track = track; |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2421 if (!mkv_d->subs.text[0]) { |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2422 for (i = 0; i < SUB_MAX_TEXT; i++) |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2423 mkv_d->subs.text[i] = (char *)safemalloc(256); |
10024 | 2424 |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2425 if (!strcmp(track->codec_id, MKV_S_TEXTUTF8)) |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2426 sub_utf8 = 1; // Force UTF-8 conversion. |
10984 | 2427 if (!strcmp(track->codec_id, MKV_S_TEXTSSA) || |
11276 | 2428 !strcmp(track->codec_id, "S_SSA") || |
2429 !strcmp(track->codec_id, "S_TEXT/ASS")) { | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2430 mkv_d->subtitle_type = MKV_SUBTYPE_SSA; |
10861
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
2431 sub_utf8 = 1; |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
2432 } else |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2433 mkv_d->subtitle_type = MKV_SUBTYPE_TEXT; |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2434 } else |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2435 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] File does not contain a " |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2436 "subtitle track with the id %u.\n", demuxer->sub->id); |
11154 | 2437 demuxer->sub->sh = NULL; |
10024 | 2438 } |
2439 } | |
2440 | |
11260 | 2441 demuxer->priv = mkv_d; |
2442 | |
2443 if (mkv_d->chapters != NULL) { | |
2444 for (i = 0; i < (int)mkv_d->chapters->size(); i++) { | |
2445 (*mkv_d->chapters)[i].start -= mkv_d->first_tc; | |
2446 (*mkv_d->chapters)[i].end -= mkv_d->first_tc; | |
2447 } | |
2448 if ((dvd_last_chapter > 0) && | |
2449 (dvd_last_chapter <= (int)mkv_d->chapters->size())) { | |
2450 if ((*mkv_d->chapters)[dvd_last_chapter - 1].end != 0) | |
2451 mkv_d->stop_timecode = (*mkv_d->chapters)[dvd_last_chapter - 1].end; | |
2452 else if ((dvd_last_chapter + 1) <= (int)mkv_d->chapters->size()) | |
2453 mkv_d->stop_timecode = (*mkv_d->chapters)[dvd_last_chapter].start; | |
2454 } | |
2455 } | |
2456 | |
10024 | 2457 if (s->end_pos == 0) |
2458 demuxer->seekable = 0; | |
2459 else { | |
2460 demuxer->movi_start = s->start_pos; | |
2461 demuxer->movi_end = s->end_pos; | |
2462 demuxer->seekable = 1; | |
11260 | 2463 if ((dvd_chapter != 1) && (mkv_d->chapters != NULL) && |
2464 (dvd_chapter <= (int)mkv_d->chapters->size())) | |
2465 demux_mkv_seek(demuxer, (float)(*mkv_d->chapters)[dvd_chapter - 1].start | |
2466 / 1000.0, 1); | |
10024 | 2467 } |
2468 | |
2469 return 1; | |
2470 } | |
2471 | |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2472 // Taken from demux_real.c. Thanks to the original developpers :) |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2473 #define SKIP_BITS(n) buffer <<= n |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2474 #define SHOW_BITS(n) ((buffer) >> (32 - (n))) |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2475 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2476 static float real_fix_timestamp(mkv_track_t *track, unsigned char *s, |
10438
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
2477 int timestamp) { |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2478 float v_pts; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2479 uint32_t buffer = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3]; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2480 int kf = timestamp; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2481 int pict_type; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2482 int orig_kf; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2483 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2484 if (!strcmp(track->codec_id, MKV_V_REALV30) || |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2485 !strcmp(track->codec_id, MKV_V_REALV40)) { |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2486 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2487 if (!strcmp(track->codec_id, MKV_V_REALV30)) { |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2488 SKIP_BITS(3); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2489 pict_type = SHOW_BITS(2); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2490 SKIP_BITS(2 + 7); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2491 }else{ |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2492 SKIP_BITS(1); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2493 pict_type = SHOW_BITS(2); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2494 SKIP_BITS(2 + 7 + 3); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2495 } |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2496 kf = SHOW_BITS(13); // kf= 2*SHOW_BITS(12); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2497 orig_kf = kf; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2498 if (pict_type <= 1) { |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2499 // I frame, sync timestamps: |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2500 track->rv_kf_base = timestamp - kf; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2501 mp_msg(MSGT_DEMUX, MSGL_V, "\nTS: base=%08X\n", track->rv_kf_base); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2502 kf = timestamp; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2503 } else { |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2504 // P/B frame, merge timestamps: |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2505 int tmp = timestamp - track->rv_kf_base; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2506 kf |= tmp & (~0x1fff); // combine with packet timestamp |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2507 if (kf < (tmp - 4096)) // workaround wrap-around problems |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2508 kf += 8192; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2509 else if (kf > (tmp + 4096)) |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2510 kf -= 8192; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2511 kf += track->rv_kf_base; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2512 } |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2513 if (pict_type != 3) { // P || I frame -> swap timestamps |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2514 int tmp = kf; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2515 kf = track->rv_kf_pts; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2516 track->rv_kf_pts = tmp; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2517 } |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2518 mp_msg(MSGT_DEMUX, MSGL_V, "\nTS: %08X -> %08X (%04X) %d %02X %02X %02X " |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2519 "%02X %5d\n", timestamp, kf, orig_kf, pict_type, s[0], s[1], s[2], |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2520 s[3], kf - (int)(1000.0 * track->rv_pts)); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2521 } |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2522 v_pts = kf * 0.001f; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2523 track->rv_pts = v_pts; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2524 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2525 return v_pts; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2526 } |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2527 |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2528 static void handle_realvideo(demuxer_t *demuxer, unsigned char *data, |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2529 uint32_t size, bool keyframe, int &found_data) { |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2530 dp_hdr_t *hdr; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2531 int chunks, isize; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2532 mkv_demuxer_t *mkv_d; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2533 demux_stream_t *ds; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2534 demux_packet_t *dp; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2535 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2536 mkv_d = (mkv_demuxer_t *)demuxer->priv; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2537 ds = demuxer->video; |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2538 chunks = data[0]; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2539 isize = size - 1 - (chunks + 1) * 8; |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2540 dp = new_demux_packet(sizeof(dp_hdr_t) + isize + 8 * (chunks + 1)); |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2541 memcpy(&dp->buffer[sizeof(dp_hdr_t)], &data[1 + (chunks + 1) * 8], isize); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2542 memcpy(&dp->buffer[sizeof(dp_hdr_t) + isize], &data[1], (chunks + 1) * 8); |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2543 hdr = (dp_hdr_t *)dp->buffer; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2544 hdr->len = isize; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2545 hdr->chunks = chunks; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2546 hdr->timestamp = (int)(mkv_d->last_pts * 1000); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2547 hdr->chunktab = sizeof(dp_hdr_t) + isize; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2548 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2549 dp->len = sizeof(dp_hdr_t) + isize + 8 * (chunks + 1); |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2550 if (mkv_d->v_skip_to_keyframe) { |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2551 dp->pts = mkv_d->last_pts; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2552 mkv_d->video->rv_kf_base = 0; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2553 mkv_d->video->rv_kf_pts = hdr->timestamp; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2554 } else |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2555 dp->pts = real_fix_timestamp(mkv_d->video, &dp->buffer[sizeof(dp_hdr_t)], |
10438
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
2556 hdr->timestamp); |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2557 dp->pos = demuxer->filepos; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2558 dp->flags = keyframe ? 0x10 : 0; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2559 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2560 ds_add_packet(ds, dp); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2561 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2562 found_data++; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2563 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2564 |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2565 static void handle_realaudio(demuxer_t *demuxer, unsigned char *data, |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2566 uint32_t size, bool keyframe, int &found_data) { |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2567 mkv_demuxer_t *mkv_d; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2568 demux_packet_t *dp; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2569 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2570 mkv_d = (mkv_demuxer_t *)demuxer->priv; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2571 |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2572 dp = new_demux_packet(size); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2573 memcpy(dp->buffer, data, size); |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2574 if ((mkv_d->audio->ra_pts == mkv_d->last_pts) && |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2575 !mkv_d->a_skip_to_keyframe) |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2576 dp->pts = 0; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2577 else |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2578 dp->pts = mkv_d->last_pts; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2579 mkv_d->audio->ra_pts = mkv_d->last_pts; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2580 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2581 dp->pos = demuxer->filepos; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2582 dp->flags = keyframe ? 0x10 : 0; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2583 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2584 ds_add_packet(demuxer->audio, dp); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2585 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2586 found_data++; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2587 } |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2588 |
10024 | 2589 extern "C" int demux_mkv_fill_buffer(demuxer_t *d) { |
2590 demux_packet_t *dp; | |
2591 demux_stream_t *ds; | |
2592 mkv_demuxer_t *mkv_d; | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2593 mkv_track_t *t; |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2594 int upper_lvl_el, exit_loop, found_data, i, linei, sl; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2595 char *texttmp; |
10024 | 2596 // Elements for different levels |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2597 EbmlElement *l0 = NULL, *l1 = NULL, *l2 = NULL, *l3 = NULL; |
10024 | 2598 EbmlStream *es; |
2599 KaxBlock *block; | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2600 int64_t block_duration, block_bref, block_fref; |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2601 bool use_this_block, lines_cut; |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2602 float current_pts; |
10024 | 2603 |
2604 mkv_d = (mkv_demuxer_t *)d->priv; | |
2605 es = mkv_d->es; | |
2606 l0 = mkv_d->segment; | |
2607 | |
2608 // End of stream | |
2609 if (mkv_d->saved_l1 == NULL) | |
2610 return 0; | |
2611 | |
2612 exit_loop = 0; | |
2613 upper_lvl_el = 0; | |
2614 l1 = mkv_d->saved_l1; | |
2615 mkv_d->saved_l1 = NULL; | |
2616 found_data = 0; | |
2617 try { | |
2618 // The idea is not to handle a complete KaxCluster with each call to | |
2619 // demux_mkv_fill_buffer because those might be rather big. | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2620 while ((l1 != NULL) && (upper_lvl_el <= 0)) { |
10024 | 2621 |
2622 if (EbmlId(*l1) == KaxCluster::ClassInfos.GlobalId) { | |
2623 mkv_d->cluster = (KaxCluster *)l1; | |
2624 if (found_data) { | |
2625 mkv_d->saved_l1 = l1; | |
2626 break; | |
2627 } | |
2628 | |
2629 if (mkv_d->saved_l2 != NULL) { | |
2630 l2 = mkv_d->saved_l2; | |
2631 mkv_d->saved_l2 = NULL; | |
2632 } else | |
2633 l2 = es->FindNextElement(l1->Generic().Context, upper_lvl_el, | |
2634 0xFFFFFFFFL, true, 1); | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2635 while ((l2 != NULL) && (upper_lvl_el <= 0)) { |
10024 | 2636 |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2637 // Handle at least one data packets in one call to |
10024 | 2638 // demux_mkv_fill_buffer - but abort if we have found that. |
2639 if (found_data >= 1) { | |
2640 mkv_d->saved_l2 = l2; | |
2641 mkv_d->saved_l1 = l1; | |
2642 exit_loop = 1; | |
2643 break; | |
2644 } | |
2645 | |
2646 if (EbmlId(*l2) == KaxClusterTimecode::ClassInfos.GlobalId) { | |
2647 KaxClusterTimecode &ctc = *static_cast<KaxClusterTimecode *>(l2); | |
2648 ctc.ReadData(es->I_O()); | |
2649 mkv_d->cluster_tc = uint64(ctc); | |
10273 | 2650 #if LIBEBML_VERSION >= 000404 |
2651 mkv_d->cluster->InitTimecode(mkv_d->cluster_tc, mkv_d->tc_scale); | |
2652 #else | |
10024 | 2653 mkv_d->cluster->InitTimecode(mkv_d->cluster_tc); |
10273 | 2654 #endif // LIBEBML_VERSION |
10024 | 2655 |
2656 } else if (EbmlId(*l2) == KaxBlockGroup::ClassInfos.GlobalId) { | |
2657 | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2658 KaxBlockDuration *kbdur; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2659 KaxReferenceBlock *krefblock; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2660 KaxBlock *kblock; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2661 |
10024 | 2662 block = NULL; |
2663 block_duration = -1; | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2664 block_bref = 0; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2665 block_fref = 0; |
10024 | 2666 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2667 l2->Read(*es, KaxBlockGroup::ClassInfos.Context, upper_lvl_el, l3, |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2668 true); |
10024 | 2669 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2670 kbdur = FINDFIRST(l2, KaxBlockDuration); |
10684
99eb26749a14
Re-added block duration parsing, needed for subtitles. Got lost in the last update. Patch by Bruno Lecointre.
mosu
parents:
10638
diff
changeset
|
2671 if (kbdur != NULL) |
99eb26749a14
Re-added block duration parsing, needed for subtitles. Got lost in the last update. Patch by Bruno Lecointre.
mosu
parents:
10638
diff
changeset
|
2672 block_duration = uint64(*kbdur); |
99eb26749a14
Re-added block duration parsing, needed for subtitles. Got lost in the last update. Patch by Bruno Lecointre.
mosu
parents:
10638
diff
changeset
|
2673 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2674 kblock = FINDFIRST(l2, KaxBlock); |
11260 | 2675 if (kblock != NULL) { |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2676 kblock->SetParent(*mkv_d->cluster); |
11260 | 2677 if ((mkv_d->stop_timecode > 0) && |
2678 ((kblock->GlobalTimecode() / 1000000 - mkv_d->first_tc) >= | |
2679 mkv_d->stop_timecode)) { | |
2680 delete l2; | |
2681 return 0; | |
2682 } | |
2683 } | |
10024 | 2684 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2685 krefblock = FINDFIRST(l2, KaxReferenceBlock); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2686 while (krefblock != NULL) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2687 if (int64(*krefblock) < 0) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2688 block_bref = int64(*krefblock); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2689 else |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2690 block_fref = int64(*krefblock); |
10024 | 2691 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2692 krefblock = FINDNEXT(l2, KaxReferenceBlock, krefblock); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2693 } |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2694 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2695 if (kblock != NULL) { |
10024 | 2696 // Clear the subtitles if they're obsolete now. |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2697 lines_cut = false; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2698 for (linei = 0; linei < mkv_d->subs.lines; linei++) { |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2699 if (mkv_d->clear_subs_at[linei] <= |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2700 (kblock->GlobalTimecode() / 1000000 - mkv_d->first_tc)) { |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2701 sl = linei; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2702 texttmp = mkv_d->subs.text[sl]; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2703 while (sl < mkv_d->subs.lines) { |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2704 mkv_d->subs.text[sl] = mkv_d->subs.text[sl + 1]; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2705 mkv_d->clear_subs_at[sl] = mkv_d->clear_subs_at[sl + 1]; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2706 sl++; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2707 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2708 mkv_d->subs.text[sl] = texttmp; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2709 mkv_d->subs.lines--; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2710 linei--; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2711 lines_cut = true; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2712 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2713 if (lines_cut) { |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2714 vo_sub = &mkv_d->subs; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2715 vo_osd_changed(OSDTYPE_SUBTITLE); |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2716 } |
10024 | 2717 } |
2718 | |
2719 ds = NULL; | |
2720 if ((mkv_d->video != NULL) && | |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2721 (mkv_d->video->tnum == kblock->TrackNum())) { |
10024 | 2722 ds = d->video; |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2723 t = mkv_d->video; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2724 } else if ((mkv_d->audio != NULL) && |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2725 (mkv_d->audio->tnum == kblock->TrackNum())) { |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2726 ds = d->audio; |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2727 t = mkv_d->audio; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2728 } else if ((mkv_d->subs_track != NULL) && |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2729 (mkv_d->subs_track->tnum == kblock->TrackNum())) { |
11154 | 2730 ds = d->sub; |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2731 t = mkv_d->subs_track; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2732 } |
10024 | 2733 |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2734 use_this_block = true; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2735 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2736 current_pts = (float)(kblock->GlobalTimecode() / 1000000.0 - |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2737 mkv_d->first_tc) / 1000.0; |
10930 | 2738 if (current_pts < 0.0) |
2739 current_pts = 0.0; | |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2740 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2741 if (ds == d->audio) { |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2742 if (mkv_d->a_skip_to_keyframe && |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2743 (block_bref != 0)) |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2744 use_this_block = false; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2745 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2746 else if (mkv_d->v_skip_to_keyframe) |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2747 use_this_block = false; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2748 |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2749 if (mkv_d->audio->fix_i_bps && use_this_block) { |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2750 uint32_t i, sum; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2751 sh_audio_t *sh; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2752 |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2753 for (i = 0, sum = 0; i < kblock->NumberFrames(); i++) { |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2754 DataBuffer &data = kblock->GetBuffer(i); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2755 sum += data.Size(); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2756 } |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2757 sh = (sh_audio_t *)ds->sh; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2758 if (block_duration != -1) { |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2759 sh->i_bps = sum * 1000 / block_duration; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2760 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Changed i_bps to %d.\n", |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2761 sh->i_bps); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2762 mkv_d->audio->fix_i_bps = false; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2763 } else if (mkv_d->audio->qt_last_a_pts == 0.0) |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2764 mkv_d->audio->qt_last_a_pts = current_pts; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2765 else if (mkv_d->audio->qt_last_a_pts != current_pts) { |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2766 sh->i_bps = (int)(sum / (current_pts - |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2767 mkv_d->audio->qt_last_a_pts)); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2768 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Changed i_bps to %d.\n", |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2769 sh->i_bps); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2770 mkv_d->audio->fix_i_bps = false; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2771 } |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2772 } |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2773 |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2774 } else if ((current_pts * 1000) < mkv_d->skip_to_timecode) |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2775 use_this_block = false; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2776 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2777 else if (ds == d->video) { |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2778 if (mkv_d->v_skip_to_keyframe && |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2779 (block_bref != 0)) |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2780 use_this_block = false; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2781 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2782 } else if ((mkv_d->subs_track != NULL) && |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2783 (mkv_d->subs_track->tnum == kblock->TrackNum())) { |
11154 | 2784 if (mkv_d->subtitle_type != MKV_SUBTYPE_VOBSUB) { |
2785 if (!mkv_d->v_skip_to_keyframe) | |
2786 handle_subtitles(d, kblock, block_duration); | |
2787 use_this_block = false; | |
2788 } | |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2789 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2790 } else |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2791 use_this_block = false; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2792 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2793 if (use_this_block) { |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2794 mkv_d->last_pts = current_pts; |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2795 d->filepos = mkv_d->in->getFilePointer(); |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2796 mkv_d->last_filepos = d->filepos; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2797 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2798 for (i = 0; i < (int)kblock->NumberFrames(); i++) { |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2799 unsigned char *re_buffer; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2800 uint32_t re_size; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2801 bool re_modified; |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2802 DataBuffer &data = kblock->GetBuffer(i); |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2803 |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2804 re_buffer = data.Buffer(); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2805 re_size = data.Size(); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2806 re_modified = reverse_encodings(t, re_buffer, re_size, 1); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2807 |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2808 if ((ds == d->video) && mkv_d->video->realmedia) |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2809 handle_realvideo(d, re_buffer, re_size, block_bref == 0, |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2810 found_data); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2811 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2812 else if ((ds == d->audio) && mkv_d->audio->realmedia) |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2813 handle_realaudio(d, re_buffer, re_size, block_bref == 0, |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2814 found_data); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2815 |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2816 else { |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2817 dp = new_demux_packet(re_size); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2818 memcpy(dp->buffer, re_buffer, re_size); |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2819 dp->flags = block_bref == 0 ? 1 : 0; |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2820 dp->pts = mkv_d->last_pts; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2821 ds_add_packet(ds, dp); |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2822 found_data++; |
10024 | 2823 } |
11229
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2824 if (re_modified) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
2825 safefree(re_buffer); |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2826 } |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2827 if (ds == d->video) { |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2828 mkv_d->v_skip_to_keyframe = false; |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2829 mkv_d->skip_to_timecode = 0; |
11154 | 2830 } else if (ds == d->audio) |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
2831 mkv_d->a_skip_to_keyframe = false; |
10024 | 2832 } |
2833 | |
2834 delete block; | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2835 } // kblock != NULL |
10024 | 2836 |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2837 } else |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2838 l2->SkipData(*es, l2->Generic().Context); |
10024 | 2839 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2840 if (!in_parent(l1)) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2841 delete l2; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2842 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2843 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2844 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2845 if (upper_lvl_el > 0) { |
10024 | 2846 upper_lvl_el--; |
2847 if (upper_lvl_el > 0) | |
2848 break; | |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2849 delete l2; |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2850 l2 = l3; |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2851 continue; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2852 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2853 } else if (upper_lvl_el < 0) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2854 upper_lvl_el++; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2855 if (upper_lvl_el < 0) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2856 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2857 |
10024 | 2858 } |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2859 |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2860 l2->SkipData(*es, l2->Generic().Context); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2861 delete l2; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2862 l2 = es->FindNextElement(l1->Generic().Context, upper_lvl_el, |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2863 0xFFFFFFFFL, true); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2864 |
10024 | 2865 } // while (l2 != NULL) |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2866 |
10024 | 2867 } else if (EbmlId(*l1) == KaxCues::ClassInfos.GlobalId) |
2868 return 0; | |
2869 else | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2870 l1->SkipData(*es, l1->Generic().Context); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2871 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2872 if (!in_parent(l0)) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2873 delete l1; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2874 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2875 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2876 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2877 if (upper_lvl_el > 0) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2878 upper_lvl_el--; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2879 if (upper_lvl_el > 0) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2880 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2881 delete l1; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2882 l1 = l2; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2883 continue; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2884 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2885 } else if (upper_lvl_el < 0) { |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2886 upper_lvl_el++; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2887 if (upper_lvl_el < 0) |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2888 break; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2889 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2890 } |
10024 | 2891 |
2892 if (exit_loop) | |
2893 break; | |
2894 | |
10637
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2895 l1->SkipData(*es, l1->Generic().Context); |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2896 delete l1; |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2897 l1 = es->FindNextElement(l0->Generic().Context, upper_lvl_el, |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
2898 0xFFFFFFFFL, true); |
10410
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2899 |
10024 | 2900 } // while (l1 != NULL) |
2901 } catch (exception ex) { | |
2902 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] exception caught\n"); | |
2903 return 0; | |
2904 } | |
2905 | |
2906 if (found_data) | |
2907 return 1; | |
2908 | |
2909 return 0; | |
2910 } | |
2911 | |
2912 extern "C" void resync_audio_stream(sh_audio_t *sh_audio); | |
2913 | |
2914 extern "C" void demux_mkv_seek(demuxer_t *demuxer, float rel_seek_secs, | |
2915 int flags) { | |
2916 int i, k, upper_lvl_el; | |
2917 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *)demuxer->priv; | |
2918 int64_t target_timecode, target_filepos = 0, min_diff, diff, current_pos; | |
2919 int64_t cluster_pos; | |
2920 mkv_track_index_t *index; | |
2921 mkv_index_entry_t *entry; | |
2922 EbmlElement *l1; | |
2923 | |
2924 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] SEEK, relss: %.3f, flags: %d\n", | |
2925 rel_seek_secs, flags); | |
2926 | |
2927 if (!mkv_d->cues_found && !mkv_d->cues_searched) { | |
2928 // We've not found an index so far. So let's skip over all level 1 | |
2929 // elements until we either hit another segment, the end of the file | |
2930 // or - suprise - some cues. | |
2931 current_pos = mkv_d->in->getFilePointer(); | |
2932 | |
2933 // Skip the data but do not delete the element! This is our current | |
2934 // cluster, and we need it later on in demux_mkv_fill_buffer. | |
2935 l1 = mkv_d->saved_l1; | |
2936 l1->SkipData(static_cast<EbmlStream &>(*mkv_d->es), l1->Generic().Context); | |
2937 l1 = mkv_d->es->FindNextElement(mkv_d->segment->Generic().Context, | |
2938 upper_lvl_el, 0xFFFFFFFFL, true, 1); | |
2939 while (l1 != NULL) { | |
2940 if (upper_lvl_el) | |
2941 break; | |
2942 | |
2943 if (EbmlId(*l1) == KaxCues::ClassInfos.GlobalId) { | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
2944 parse_cues(mkv_d, l1->GetElementPosition()); |
10024 | 2945 delete l1; |
2946 break; | |
2947 } else { | |
2948 if (EbmlId(*l1) == KaxCluster::ClassInfos.GlobalId) | |
2949 add_cluster_position(mkv_d, l1->GetElementPosition()); | |
2950 l1->SkipData(static_cast<EbmlStream &>(*mkv_d->es), | |
2951 l1->Generic().Context); | |
2952 delete l1; | |
2953 l1 = mkv_d->es->FindNextElement(mkv_d->segment->Generic().Context, | |
2954 upper_lvl_el, 0xFFFFFFFFL, true, 1); | |
2955 } | |
2956 } | |
2957 | |
2958 if (demuxer->stream->eof) | |
2959 stream_reset(demuxer->stream); | |
2960 mkv_d->in->setFilePointer(current_pos); | |
2961 | |
2962 mkv_d->cues_searched = 1; | |
2963 } | |
2964 | |
2965 if (!(flags & 2)) { // Time in secs | |
2966 if (flags & 1) // Absolute seek | |
2967 target_timecode = 0; | |
2968 else // Relative seek | |
2969 target_timecode = (int64_t)(mkv_d->last_pts * 1000.0); | |
2970 target_timecode += (int64_t)(rel_seek_secs * 1000.0); | |
2971 if (target_timecode < 0) | |
2972 target_timecode = 0; | |
2973 | |
2974 min_diff = 0xFFFFFFFL; | |
2975 | |
2976 // Let's find the entry in the index with the smallest difference | |
2977 // to the wanted timecode. | |
2978 entry = NULL; | |
2979 for (i = 0; i < mkv_d->num_indexes; i++) | |
2980 if (mkv_d->index[i].tnum == mkv_d->video->tnum) { | |
2981 index = &mkv_d->index[i]; | |
2982 for (k = 0; k < index->num_entries; k++) { | |
2983 if (!index->entries[k].is_key) | |
2984 continue; | |
2985 diff = target_timecode - (int64_t)index->entries[k].timecode; | |
11260 | 2986 if (((flags & 1) || (target_timecode <= (mkv_d->last_pts * 1000))) && |
10874
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2987 (diff >= 0) && (diff < min_diff)) { |
10024 | 2988 min_diff = diff; |
10874
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2989 entry = &index->entries[k]; |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2990 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek BACK, solution: last_pts: " |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2991 "%d, target: %d, diff: %d, entry->timecode: %d, PREV diff: " |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2992 "%d, k: %d\n", (int)(mkv_d->last_pts * 1000), |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2993 (int)target_timecode, (int)diff, (int)entry->timecode, |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2994 k > 0 ? (int)(index->entries[k - 1].timecode - |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2995 target_timecode) : 0, k); |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2996 |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2997 } else if ((target_timecode > (mkv_d->last_pts * 1000)) && |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2998 (diff < 0) && (-diff < min_diff)) { |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
2999 min_diff = -diff; |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3000 entry = &index->entries[k]; |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3001 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek FORW, solution: last_pts: " |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3002 "%d, target: %d, diff: %d, entry->timecode: %d, NEXT diff: " |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3003 "%d, k: %d\n", (int)(mkv_d->last_pts * 1000), |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3004 (int)target_timecode, (int)diff, (int)entry->timecode, |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3005 k < index->num_entries ? |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3006 (int)(index->entries[k + 1].timecode - target_timecode) : |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3007 0, k); |
10024 | 3008 } |
3009 } | |
3010 break; | |
3011 } | |
3012 | |
3013 if (mkv_d->saved_l1 != NULL) | |
3014 delete mkv_d->saved_l1; | |
3015 | |
3016 if (mkv_d->saved_l2 != NULL) { | |
3017 delete mkv_d->saved_l2; | |
3018 mkv_d->saved_l2 = NULL; | |
3019 } | |
3020 | |
3021 if (entry != NULL) { // We've found an entry. | |
3022 mkv_d->in->setFilePointer(entry->filepos); | |
3023 upper_lvl_el = 0; | |
3024 mkv_d->saved_l1 = | |
3025 mkv_d->es->FindNextElement(mkv_d->segment->Generic().Context, | |
3026 upper_lvl_el, 0xFFFFFFFFL, true, 1); | |
3027 } else { // We've not found an entry --> no index? | |
3028 target_filepos = (int64_t)(target_timecode * mkv_d->last_filepos / | |
3029 (mkv_d->last_pts * 1000.0)); | |
3030 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] No index entry found. Calculated " | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3031 "filepos %lld. Old timecode %lld.\n", target_filepos, |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3032 (int64_t)(mkv_d->last_pts * 1000.0)); |
10024 | 3033 // Let's find the nearest cluster so that libebml does not have to |
3034 // do so much work. | |
3035 cluster_pos = 0; | |
3036 min_diff = 0x0FFFFFFFL; | |
3037 for (i = 0; i < mkv_d->num_cluster_pos; i++) { | |
3038 diff = mkv_d->cluster_positions[i] - target_filepos; | |
3039 if (rel_seek_secs < 0) { | |
3040 if ((diff > 0) && (diff < min_diff)) { | |
3041 cluster_pos = mkv_d->cluster_positions[i]; | |
3042 min_diff = diff; | |
3043 } | |
10099
71d703e35ff3
Removed the abs function as someone reported compilation problems under MacOS.
mosu
parents:
10098
diff
changeset
|
3044 } else if ((diff < 0 ? -1 * diff : diff) < min_diff) { |
10024 | 3045 cluster_pos = mkv_d->cluster_positions[i]; |
10099
71d703e35ff3
Removed the abs function as someone reported compilation problems under MacOS.
mosu
parents:
10098
diff
changeset
|
3046 min_diff = diff < 0 ? -1 * diff : diff; |
10024 | 3047 } |
3048 } | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3049 if (min_diff != 0x0FFFFFFFL) { |
10024 | 3050 target_filepos = cluster_pos; |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3051 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] New target_filepos because of " |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3052 "cluster: %lld.\n", target_filepos); |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3053 } |
10024 | 3054 if (target_filepos >= demuxer->movi_end) |
3055 return; | |
3056 mkv_d->in->setFilePointer(target_filepos); | |
3057 upper_lvl_el = 0; | |
3058 mkv_d->saved_l1 = | |
3059 mkv_d->es->FindNextElement(mkv_d->segment->Generic().Context, | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3060 upper_lvl_el, 0xFFFFFFFFL, true, 1); |
10024 | 3061 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek result: target_timecode %lld, " |
3062 "did not find an entry. Calculated target_filspos: %lld\n", | |
3063 target_timecode, target_filepos); | |
3064 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek found %p (%s).\n", | |
3065 mkv_d->saved_l1, mkv_d->saved_l1 == NULL ? "null" : | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
3066 mkv_d->saved_l1->Generic().DebugName); |
10024 | 3067 } |
3068 | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3069 if (mkv_d->video != NULL) |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
3070 mkv_d->v_skip_to_keyframe = true; |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3071 if (rel_seek_secs > 0.0) |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3072 mkv_d->skip_to_timecode = target_timecode; |
10024 | 3073 |
10434
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
3074 mkv_d->a_skip_to_keyframe = true; |
dd64e1fe919d
Better support for RealVideo/RealAudio in Matroska. Includes the timestamp fixes from demux_real.c. Seeking is working. Added Matroska to the formats with variable FPS in video.c.
mosu
parents:
10410
diff
changeset
|
3075 |
10024 | 3076 demux_mkv_fill_buffer(demuxer); |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3077 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] New timecode: %lld\n", |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3078 (int64_t)(mkv_d->last_pts * 1000.0)); |
10024 | 3079 |
3080 mkv_d->subs.lines = 0; | |
3081 vo_sub = &mkv_d->subs; | |
3082 vo_osd_changed(OSDTYPE_SUBTITLE); | |
3083 | |
3084 if(demuxer->audio->sh != NULL) | |
3085 resync_audio_stream((sh_audio_t *)demuxer->audio->sh); | |
3086 | |
3087 } else | |
3088 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek unsupported flags\n"); | |
3089 | |
3090 } | |
3091 | |
3092 extern "C" void demux_close_mkv(demuxer_t *demuxer) { | |
3093 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *)demuxer->priv; | |
3094 | |
3095 free_mkv_demuxer(mkv_d); | |
3096 | |
3097 #ifdef USE_ICONV | |
3098 subcp_close(); | |
3099 #endif | |
3100 } | |
3101 | |
3102 extern "C" int demux_mkv_control(demuxer_t *demuxer, int cmd, void *arg) { | |
3103 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *)demuxer->priv; | |
3104 | |
3105 switch (cmd) { | |
3106 case DEMUXER_CTRL_GET_TIME_LENGTH: | |
3107 if (mkv_d->duration == -1.0) | |
3108 return DEMUXER_CTRL_DONTKNOW; | |
3109 | |
3110 *((unsigned long *)arg) = (unsigned long)mkv_d->duration; | |
3111 return DEMUXER_CTRL_OK; | |
3112 | |
3113 case DEMUXER_CTRL_GET_PERCENT_POS: | |
3114 if (mkv_d->duration == -1.0) { | |
3115 if (demuxer->movi_start == demuxer->movi_end) | |
3116 return DEMUXER_CTRL_DONTKNOW; | |
3117 | |
3118 *((int *)arg) = | |
3119 (int)((demuxer->filepos - demuxer->movi_start) / | |
3120 ((demuxer->movi_end - demuxer->movi_start) / 100)); | |
3121 return DEMUXER_CTRL_OK; | |
3122 } | |
3123 | |
3124 *((int *)arg) = (int)(100 * mkv_d->last_pts / mkv_d->duration); | |
3125 return DEMUXER_CTRL_OK; | |
3126 | |
3127 default: | |
3128 return DEMUXER_CTRL_NOTIMPL; | |
3129 } | |
3130 } | |
3131 | |
3132 #endif /* HAVE_MATROSKA */ |