Mercurial > mplayer.hg
annotate libmpdemux/demux_mkv.cpp @ 11289:c3f049d801d8
_ ---> - in monitor_* options
author | diego |
---|---|
date | Mon, 27 Oct 2003 10:23:10 +0000 |
parents | ec45f2106ec6 |
children | ef36cd5b757e |
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; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
241 #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
|
242 z_stream zstream; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
243 bool zstream_initiated; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
244 #endif |
10024 | 245 } mkv_track_t; |
246 | |
247 typedef struct mkv_demuxer { | |
248 float duration, last_pts; | |
249 uint64_t last_filepos; | |
250 | |
251 mkv_track_t **tracks; | |
252 int num_tracks; | |
253 mkv_track_t *video, *audio, *subs_track; | |
254 | |
10283
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
255 uint64_t tc_scale, cluster_tc, first_tc; |
10024 | 256 |
257 mpstream_io_callback *in; | |
258 | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
259 uint64_t clear_subs_at[SUB_MAX_TEXT]; |
10024 | 260 |
261 subtitle subs; | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
262 int subtitle_type; |
10024 | 263 |
264 EbmlStream *es; | |
265 EbmlElement *saved_l1, *saved_l2; | |
266 KaxSegment *segment; | |
267 KaxCluster *cluster; | |
268 | |
269 mkv_track_index_t *index; | |
270 int num_indexes, cues_found, cues_searched; | |
271 int64_t *cluster_positions; | |
272 int num_cluster_pos; | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
273 vector<uint64_t> *parsed_seekheads; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
274 vector<uint64_t> *parsed_cues; |
10024 | 275 |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
276 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
|
277 bool v_skip_to_keyframe, a_skip_to_keyframe; |
11260 | 278 |
279 vector<mkv_chapter_t> *chapters; // No support for nested chapters atm. | |
280 uint64_t stop_timecode; | |
10024 | 281 } mkv_demuxer_t; |
282 | |
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
|
283 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
|
284 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
|
285 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
|
286 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
|
287 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
|
288 } 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
|
289 |
10438
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
290 #if __GNUC__ == 2 |
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
291 #pragma pack(2) |
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
292 #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
|
293 #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
|
294 #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
|
295 |
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 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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 } 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
|
308 |
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 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
|
310 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
|
311 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
|
312 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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 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
|
322 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
|
323 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
|
324 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
|
325 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
|
326 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
|
327 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
|
328 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
|
329 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
|
330 } 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
|
331 |
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 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
|
333 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
|
334 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
|
335 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 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
|
341 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
|
342 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
|
343 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
|
344 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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 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
|
350 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
|
351 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
|
352 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
|
353 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
|
354 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
|
355 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
|
356 } 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
|
357 |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
358 // 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
|
359 // 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
|
360 typedef struct { |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
361 uint32_t id_size; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
362 uint32_t codec_type; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
363 uint32_t reserved1; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
364 uint16_t reserved2; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
365 uint16_t data_reference_index; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
366 uint16_t version; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
367 uint16_t revision; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
368 uint32_t vendor; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
369 uint32_t temporal_quality; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
370 uint32_t spatial_quality; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
371 uint16_t width; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
372 uint16_t height; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
373 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
|
374 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
|
375 uint32_t data_size; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
376 uint16_t frame_count; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
377 char compressor_name[32]; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
378 uint16_t depth; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
379 uint16_t color_table_id; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
380 } qt_image_description_t; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
381 |
10438
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
382 #if __GNUC__ == 2 |
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
383 #pragma pack() |
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
384 #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
|
385 #pragma pack(pop) |
10438
ed760986e1fd
Fixes for stuff that only showed up with gcc versions other than 3.2.
mosu
parents:
10437
diff
changeset
|
386 #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
|
387 |
10024 | 388 static uint16_t get_uint16(const void *buf) { |
389 uint16_t ret; | |
390 unsigned char *tmp; | |
391 | |
392 tmp = (unsigned char *) buf; | |
393 | |
394 ret = tmp[1] & 0xff; | |
395 ret = (ret << 8) + (tmp[0] & 0xff); | |
396 | |
397 return ret; | |
398 } | |
399 | |
400 static uint32_t get_uint32(const void *buf) { | |
401 uint32_t ret; | |
402 unsigned char *tmp; | |
403 | |
404 tmp = (unsigned char *) buf; | |
405 | |
406 ret = tmp[3] & 0xff; | |
407 ret = (ret << 8) + (tmp[2] & 0xff); | |
408 ret = (ret << 8) + (tmp[1] & 0xff); | |
409 ret = (ret << 8) + (tmp[0] & 0xff); | |
410 | |
411 return ret; | |
412 } | |
413 | |
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
|
414 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
|
415 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
|
416 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
|
417 |
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 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
|
419 |
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 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
|
421 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
|
422 |
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 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
|
424 } |
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 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
|
427 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
|
428 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
|
429 |
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 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
|
431 |
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 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
|
433 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
|
434 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
|
435 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
|
436 |
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 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
|
438 } |
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 |
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 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
|
441 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
|
442 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
|
443 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
|
444 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
|
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 |
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 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
|
448 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
|
449 |
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 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
|
451 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
|
452 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
|
453 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
|
454 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
|
455 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
|
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 |
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 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
|
459 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
|
460 |
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 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
|
462 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
|
463 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
|
464 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
|
465 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
|
466 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
|
467 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
|
468 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
|
469 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
470 |
10024 | 471 static void handle_subtitles(demuxer_t *d, KaxBlock *block, int64_t duration) { |
472 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
|
473 int len, line, state, i; |
10024 | 474 char *s1, *s2, *buffer; |
475 | |
476 if (duration == -1) { | |
477 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Warning: No KaxBlockDuration " | |
478 "element for subtitle track found.\n"); | |
479 return; | |
480 } | |
481 | |
482 DataBuffer &data = block->GetBuffer(0); | |
483 len = data.Size(); | |
484 | |
485 buffer = (char *)data.Buffer(); | |
486 s1 = buffer; | |
487 | |
488 while (((*s1 == '\n') || (*s1 == '\r')) && | |
489 ((unsigned int)(s1 - buffer) <= data.Size())) | |
490 s1++; | |
491 | |
492 line = 0; | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
493 mkv_d->subs.lines++; |
11276 | 494 if (mkv_d->subs.lines> SUB_MAX_TEXT - 1 ) |
495 { | |
496 mp_msg(MSGT_DEMUX, MSGL_WARN,"[mkv] Warning: too many sublines to render, skipping\n"); | |
497 mkv_d->subs.lines--; | |
498 return; | |
499 } | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
500 s2 = mkv_d->subs.text[mkv_d->subs.lines - 1]; |
10024 | 501 state = 0; |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
502 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
503 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
|
504 /* 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
|
505 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
|
506 and duration. */ |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
507 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
508 /* Find text section. */ |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
509 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
|
510 if (*s1 == ',') |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
511 i++; |
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 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
|
514 mkv_d->subs.lines--; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
515 return; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
516 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
517 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
518 /* Load text. */ |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
519 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
|
520 if (*s1 == '{') |
10024 | 521 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
|
522 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
|
523 state = 2; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
524 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
525 if (state == 0) { |
10024 | 526 *s2 = *s1; |
527 s2++; | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
528 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
|
529 break; |
10024 | 530 } |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
531 s1++; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
532 |
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
|
533 /* 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
|
534 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
|
535 ((*(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
|
536 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
|
537 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
|
538 |
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 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
|
540 *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
|
541 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
|
542 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
|
543 } |
59e3d641c48c
Marked SSA subs as UTF-8. Better newline handling for SSA subs. Patch by Tristan <z80@oceanfree.net>.
mosu
parents:
10860
diff
changeset
|
544 |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
545 if (state == 2) |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
546 state = 0; |
10024 | 547 } |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
548 *s2 = 0; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
549 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
550 } else { |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
551 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
|
552 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
|
553 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
|
554 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
|
555 break; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
556 *s2 = 0; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
557 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
|
558 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
|
559 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
|
560 mkv_d->subs.lines++; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
561 state = 1; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
562 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
563 } 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
|
564 state = 2; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
565 else if (*s1 == '>') |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
566 state = 0; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
567 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
|
568 state = 0; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
569 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
|
570 *s2 = *s1; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
571 s2++; |
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 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
574 s1++; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
575 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
576 |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
577 *s2 = 0; |
10024 | 578 } |
579 | |
580 #ifdef USE_ICONV | |
581 subcp_recode1(&mkv_d->subs); | |
582 #endif | |
583 | |
584 vo_sub = &mkv_d->subs; | |
585 vo_osd_changed(OSDTYPE_SUBTITLE); | |
586 | |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
587 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
|
588 block->GlobalTimecode() / 1000000 - mkv_d->first_tc + duration; |
10024 | 589 } |
590 | |
591 static mkv_track_t *new_mkv_track(mkv_demuxer_t *d) { | |
592 mkv_track_t *t; | |
593 | |
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
|
594 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
|
595 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
|
596 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
|
597 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
|
598 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
|
599 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
|
600 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
|
601 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
|
602 |
b4040706e1d3
Added 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 // 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
|
604 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
|
605 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
|
606 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
|
607 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
|
608 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
609 t->c_encodings = new vector<mkv_content_encoding_t>; |
10024 | 610 |
611 return t; | |
612 } | |
613 | |
614 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
|
615 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
|
616 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
|
617 |
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 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
|
619 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
|
620 (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
|
621 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
|
622 |
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 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
|
624 } |
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
|
625 |
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
|
626 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
|
627 mkv_track_t *c) { |
10024 | 628 int i; |
629 | |
630 for (i = 0; i < d->num_tracks; i++) | |
631 if ((d->tracks[i] != NULL) && (d->tracks[i]->tnum == n) && | |
632 (d->tracks[i] != c)) | |
633 return d->tracks[i]; | |
634 | |
635 return NULL; | |
636 } | |
637 | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
638 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
|
639 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
|
640 int i; |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
641 |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
642 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
|
643 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
|
644 (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
|
645 !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
|
646 (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
|
647 return d->tracks[i]; |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
648 |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
649 return NULL; |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
650 } |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
651 |
11154 | 652 static bool mkv_parse_idx(mkv_track_t *t) { |
653 uint32_t i, p, things_found; | |
654 int idx; | |
655 string line, s1, s2; | |
656 char *src; | |
657 | |
658 if ((t->private_data == NULL) || (t->private_size < 1)) | |
659 return false; | |
660 | |
661 things_found = 0; | |
662 i = 0; | |
663 src = (char *)t->private_data; | |
664 do { | |
665 line = ""; | |
666 while ((i < t->private_size) && (src[i] != '\n') && (src[i] != '\r')) { | |
667 if (!isspace(src[i])) | |
668 line += src[i]; | |
669 i++; | |
670 } | |
671 while ((i < t->private_size) && ((src[i] == '\n') || (src[i] == '\r'))) | |
672 i++; | |
673 | |
674 if (!strncasecmp(line.c_str(), "size:", 5)) { | |
675 s1 = line.substr(5); | |
676 idx = s1.find('x'); | |
677 if (idx >= 0) { | |
678 s2 = s1.substr(idx + 1); | |
679 s1.erase(idx); | |
680 t->sh_sub.width = strtol(s1.c_str(), NULL, 10); | |
681 t->sh_sub.height = strtol(s2.c_str(), NULL, 10); | |
682 things_found |= 1; | |
683 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub IDX parser: size: %d x %d\n", | |
684 t->sh_sub.width, t->sh_sub.height); | |
685 } | |
686 | |
687 } else if (!strncasecmp(line.c_str(), "palette:", 8)) { | |
688 s1 = line.substr(8); | |
689 for (p = 0; p < 15; p++) { | |
690 idx = s1.find(','); | |
691 if (idx < 0) | |
692 break; | |
693 s2 = s1.substr(0, idx); | |
694 s1.erase(0, idx + 1); | |
695 t->sh_sub.palette[p] = (unsigned int)strtol(s2.c_str(), NULL, 16); | |
696 } | |
697 if (idx >= 0) { | |
698 t->sh_sub.palette[15] = (unsigned int)strtol(s1.c_str(), NULL, 16); | |
699 things_found |= 2; | |
700 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub IDX parser: palette: 0x%06x " | |
701 "0x%06x 0x%06x 0x%06x 0x%06x 0x%06x 0x%06x 0x%06x 0x%06x " | |
702 "0x%06x 0x%06x 0x%06x 0x%06x 0x%06x 0x%06x 0x%06x\n", | |
703 t->sh_sub.palette[0], t->sh_sub.palette[1], | |
704 t->sh_sub.palette[2], t->sh_sub.palette[3], | |
705 t->sh_sub.palette[4], t->sh_sub.palette[5], | |
706 t->sh_sub.palette[6], t->sh_sub.palette[7], | |
707 t->sh_sub.palette[8], t->sh_sub.palette[9], | |
708 t->sh_sub.palette[10], t->sh_sub.palette[11], | |
709 t->sh_sub.palette[12], t->sh_sub.palette[13], | |
710 t->sh_sub.palette[14], t->sh_sub.palette[15]); | |
711 } | |
712 } | |
713 | |
714 } while ((i != t->private_size) && (things_found != 3)); | |
715 t->sh_sub.type = 'v'; | |
716 | |
717 return (things_found == 3); | |
718 } | |
719 | |
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
|
720 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
|
721 uint32_t &size, uint32_t 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
|
722 int 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
|
723 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
|
724 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
|
725 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
|
726 |
b4040706e1d3
Added 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 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
|
728 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
|
729 |
b4040706e1d3
Added 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 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
|
731 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
|
732 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
|
733 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
|
734 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
|
735 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
|
736 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
|
737 |
b4040706e1d3
Added 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 #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
|
739 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
|
740 int 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
|
741 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
742 old_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
|
743 new_data = (unsigned char *)safemalloc(new_size * 20); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
744 |
b4040706e1d3
Added 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 track->zstream.next_in = (Bytef *)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
|
746 track->zstream.next_out = (Bytef *)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
|
747 track->zstream.avail_in = 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
|
748 track->zstream.avail_out = 20 * 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
|
749 result = inflate(&track->zstream, Z_FULL_FLUSH); |
b4040706e1d3
Added 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 if (result != Z_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
|
751 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Zlib decompression failed. " |
b4040706e1d3
Added 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 "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
|
753 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
|
754 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
|
755 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
|
756 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
|
757 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
758 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
759 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] zlib decompression: from %d to " |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
760 "%d\n", new_size, 20 * new_size - track->zstream.avail_out); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
761 new_size = 20 * new_size - track->zstream.avail_out; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
762 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
763 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
|
764 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
|
765 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
|
766 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
767 #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
|
768 } |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
769 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
770 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
|
771 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
|
772 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
773 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
|
774 } |
b4040706e1d3
Added 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 |
10024 | 776 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
|
777 int i, track_num; |
10024 | 778 unsigned char *c; |
779 uint32_t u, offset, length; | |
780 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
|
781 mkv_content_encoding_t *ce; |
10024 | 782 BITMAPINFOHEADER *bih; |
783 WAVEFORMATEX *wfe; | |
784 | |
10028
7ca8b302032f
Loop counter was used inside for another loop as well.
mosu
parents:
10024
diff
changeset
|
785 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
|
786 t = d->tracks[track_num]; |
10028
7ca8b302032f
Loop counter was used inside for another loop as well.
mosu
parents:
10024
diff
changeset
|
787 |
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
|
788 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
|
789 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
|
790 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
|
791 |
b4040706e1d3
Added 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 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
|
793 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
|
794 "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
|
795 "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
|
796 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
|
797 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
|
798 } |
b4040706e1d3
Added 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 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
800 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
|
801 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
|
802 "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
|
803 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
|
804 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
|
805 } |
b4040706e1d3
Added 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 |
b4040706e1d3
Added 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 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
|
808 #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
|
809 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
|
810 "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
|
811 "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
|
812 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
|
813 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
|
814 #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
|
815 if (!t->zstream_initiated) { |
b4040706e1d3
Added 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 t->zstream.zalloc = (alloc_func)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
|
817 t->zstream.zfree = (free_func)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
|
818 t->zstream.opaque = (voidpf)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 inflateInit(&t->zstream); |
b4040706e1d3
Added 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 t->zstream_initiated = 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
|
821 } |
b4040706e1d3
Added 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 #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
|
823 } 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
|
824 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
|
825 "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
|
826 "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
|
827 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
|
828 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
|
829 } |
b4040706e1d3
Added 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 } |
b4040706e1d3
Added 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 |
b4040706e1d3
Added 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 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
|
833 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
|
834 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
|
835 |
b4040706e1d3
Added 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 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
|
837 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
|
838 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
|
839 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
|
840 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
|
841 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
|
842 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
|
843 } |
b4040706e1d3
Added 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 } |
b4040706e1d3
Added 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 |
10024 | 846 switch (t->type) { |
847 case 'v': // video track | |
848 if (t->codec_id == NULL) | |
849 continue; | |
850 if (!strcmp(t->codec_id, MKV_V_MSCOMP)) { | |
851 if ((t->private_data == NULL) || | |
852 (t->private_size < sizeof(BITMAPINFOHEADER))) { | |
853 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: CodecID for track " | |
854 "%u is '" MKV_V_MSCOMP "', but there was no " | |
855 "BITMAPINFOHEADER struct present. Therefore we don't have " | |
856 "a FourCC to identify the video codec used.\n", t->tnum); | |
857 continue; | |
858 } else { | |
859 t->ms_compat = 1; | |
860 | |
861 bih = (BITMAPINFOHEADER *)t->private_data; | |
862 | |
863 u = get_uint32(&bih->biWidth); | |
864 if (t->v_width != u) { | |
865 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: (MS " | |
866 "compatibility mode, track %u) " | |
867 "Matrosa says video width is %u, but the " | |
868 "BITMAPINFOHEADER says %u.\n", t->tnum, t->v_width, u); | |
869 if (t->v_width == 0) | |
870 t->v_width = u; | |
871 } | |
872 | |
873 u = get_uint32(&bih->biHeight); | |
874 if (t->v_height != u) { | |
875 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: (MS compatibility " | |
876 "mode, track %u) " | |
877 "Matrosa video height is %u, but the BITMAPINFOHEADER " | |
878 "says %u.\n", t->tnum, t->v_height, u); | |
879 if (t->v_height == 0) | |
880 t->v_height = u; | |
881 } | |
882 | |
883 memcpy(t->v_fourcc, &bih->biCompression, 4); | |
884 } | |
885 } | |
886 | |
887 if (t->v_width == 0) { | |
888 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] The width for track %u was " | |
889 "not set.\n", t->tnum); | |
890 continue; | |
891 } | |
892 if (t->v_height == 0) { | |
893 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] The height for track %u was " | |
894 "not set.\n", t->tnum); | |
895 continue; | |
896 } | |
897 | |
10081
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
898 if (t->v_dwidth == 0) |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
899 t->v_dwidth = t->v_width; |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
900 if (t->v_dheight == 0) |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
901 t->v_dheight = t->v_height; |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
902 |
10024 | 903 // This track seems to be ok. |
904 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
|
905 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
|
906 "-vid %u\n", t->tnum, t->codec_id, t->xid); |
10024 | 907 |
908 break; | |
909 | |
910 case 'a': // audio track | |
911 if (t->codec_id == NULL) | |
912 continue; | |
913 if (!strcmp(t->codec_id, MKV_A_ACM)) { | |
914 if ((t->private_data == NULL) || | |
915 (t->private_size < sizeof(WAVEFORMATEX))) { | |
916 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: CodecID for track " | |
917 "%u is '" MKV_A_ACM "', " | |
918 "but there was no WAVEFORMATEX struct present. " | |
919 "Therefore we don't have a format ID to identify the audio " | |
920 "codec used.\n", t->tnum); | |
921 continue; | |
922 } else { | |
923 t->ms_compat = 1; | |
924 | |
925 wfe = (WAVEFORMATEX *)t->private_data; | |
926 u = get_uint32(&wfe->nSamplesPerSec); | |
927 if (((uint32_t)t->a_sfreq) != u) { | |
928 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: (MS compatibility " | |
929 "mode for track %u) " | |
930 "Matroska says that there are %u samples per second, " | |
931 "but WAVEFORMATEX says that there are %u.\n", t->tnum, | |
932 (uint32_t)t->a_sfreq, u); | |
933 if (t->a_sfreq == 0.0) | |
934 t->a_sfreq = (float)u; | |
935 } | |
936 | |
937 u = get_uint16(&wfe->nChannels); | |
938 if (t->a_channels != u) { | |
939 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: (MS " | |
940 "compatibility mode for track %u) " | |
941 "Matroska says that there are %u channels, but the " | |
942 "WAVEFORMATEX says that there are %u.\n", t->tnum, | |
943 t->a_channels, u); | |
944 if (t->a_channels == 0) | |
945 t->a_channels = u; | |
946 } | |
947 | |
948 u = get_uint16(&wfe->wBitsPerSample); | |
10098 | 949 if (t->a_bps != u) { |
10024 | 950 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: (MS " |
951 "compatibility mode for track %u) " | |
952 "Matroska says that there are %u bits per sample, " | |
953 "but the WAVEFORMATEX says that there are %u.\n", t->tnum, | |
954 t->a_bps, u); | |
955 if (t->a_bps == 0) | |
956 t->a_bps = u; | |
957 } | |
958 | |
959 t->a_formattag = get_uint16(&wfe->wFormatTag); | |
960 } | |
961 } else { | |
11155 | 962 if (!strcmp(t->codec_id, MKV_A_MP3) || |
963 !strcmp(t->codec_id, MKV_A_MP2)) | |
10024 | 964 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
|
965 else if (!strncmp(t->codec_id, MKV_A_AC3, strlen(MKV_A_AC3))) |
10024 | 966 t->a_formattag = 0x2000; |
10105
dc4f1b768062
Support for DTS tracks (only with -hwac3 of course).
mosu
parents:
10099
diff
changeset
|
967 else if (!strcmp(t->codec_id, MKV_A_DTS)) |
dc4f1b768062
Support for DTS tracks (only with -hwac3 of course).
mosu
parents:
10099
diff
changeset
|
968 // 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
|
969 t->a_formattag = 0x2000; |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
970 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
|
971 !strcmp(t->codec_id, MKV_A_PCM_BE)) |
10024 | 972 t->a_formattag = 0x0001; |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
973 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
|
974 !strcmp(t->codec_id, MKV_A_AAC_2LC) || |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
975 !strcmp(t->codec_id, MKV_A_AAC_2SSR) || |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
976 !strcmp(t->codec_id, MKV_A_AAC_4MAIN) || |
10125 | 977 !strcmp(t->codec_id, MKV_A_AAC_4LC) || |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
978 !strcmp(t->codec_id, MKV_A_AAC_4SSR) || |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
979 !strcmp(t->codec_id, MKV_A_AAC_4LTP) || |
10125 | 980 !strcmp(t->codec_id, MKV_A_AAC_4SBR)) |
981 t->a_formattag = mmioFOURCC('M', 'P', '4', 'A'); | |
10024 | 982 else if (!strcmp(t->codec_id, MKV_A_VORBIS)) { |
983 if (t->private_data == NULL) { | |
984 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] WARNING: CodecID for " | |
985 "track %u is '" MKV_A_VORBIS | |
986 "', but there are no header packets present.", t->tnum); | |
987 continue; | |
988 } | |
989 | |
990 c = (unsigned char *)t->private_data; | |
991 if (c[0] != 2) { | |
992 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Vorbis track does not " | |
993 "contain valid headers.\n"); | |
994 continue; | |
995 } | |
996 | |
997 offset = 1; | |
998 for (i = 0; i < 2; i++) { | |
999 length = 0; | |
1000 while ((c[offset] == (unsigned char )255) && | |
1001 (length < t->private_size)) { | |
1002 length += 255; | |
1003 offset++; | |
1004 } | |
1005 if (offset >= (t->private_size - 1)) { | |
1006 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Vorbis track does not " | |
1007 "contain valid headers.\n"); | |
1008 continue; | |
1009 } | |
1010 length += c[offset]; | |
1011 offset++; | |
1012 t->header_sizes[i] = length; | |
1013 } | |
1014 | |
1015 t->headers[0] = &c[offset]; | |
1016 t->headers[1] = &c[offset + t->header_sizes[0]]; | |
1017 t->headers[2] = &c[offset + t->header_sizes[0] + | |
1018 t->header_sizes[1]]; | |
10079
7c13793dbfa0
Vorbis header packet lengths were calculated incorrectly.
mosu
parents:
10073
diff
changeset
|
1019 t->header_sizes[2] = t->private_size - offset - |
7c13793dbfa0
Vorbis header packet lengths were calculated incorrectly.
mosu
parents:
10073
diff
changeset
|
1020 t->header_sizes[0] - t->header_sizes[1]; |
10024 | 1021 |
1022 t->a_formattag = 0xFFFE; | |
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
|
1023 } 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
|
1024 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
|
1025 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
|
1026 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
|
1027 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
|
1028 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
|
1029 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
|
1030 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
|
1031 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
|
1032 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
|
1033 t->a_formattag = mmioFOURCC('s', 'i', 'p', 'r'); |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
1034 } else if (!strcmp(t->codec_id, MKV_A_QDMC) || |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
1035 !strcmp(t->codec_id, MKV_A_QDMC2)) { |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
1036 ; |
10024 | 1037 } else { |
1038 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
|
1039 "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
|
1040 "codec data.\n", t->codec_id, t->tnum); |
10024 | 1041 continue; |
1042 } | |
1043 } | |
1044 | |
1045 if (t->a_sfreq == 0.0) { | |
1046 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] The sampling frequency was not " | |
1047 "set for track %u.\n", t->tnum); | |
1048 continue; | |
1049 } | |
1050 | |
1051 if (t->a_channels == 0) { | |
1052 mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] The number of channels was not " | |
1053 "set for track %u.\n", t->tnum); | |
1054 continue; | |
1055 } | |
1056 | |
1057 // This track seems to be ok. | |
1058 t->ok = 1; | |
10706
ede87804e4e6
Removed some ":" in the track output for easier cut&paste.
mosu
parents:
10705
diff
changeset
|
1059 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
|
1060 "%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
|
1061 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
|
1062 t->language != NULL ? t->language : ""); |
10024 | 1063 break; |
1064 | |
11154 | 1065 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
|
1066 if (!strcmp(t->codec_id, MKV_S_VOBSUB)) { |
11154 | 1067 if (mkv_parse_idx(t)) { |
1068 t->ok = 1; | |
1069 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Track ID %u: subtitles (%s), " | |
1070 "-sid %u%s%s\n", t->tnum, t->codec_id, | |
1071 t->xid, t->language != NULL ? ", -slang " : "", | |
1072 t->language != NULL ? t->language : ""); | |
1073 } | |
1074 | |
1075 } else { // Text subtitles do not need any data | |
1076 t->ok = 1; // except the CodecID. | |
1077 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Track ID %u: subtitles (%s), " | |
1078 "-sid %u%s%s\n", t->tnum, t->codec_id, t->xid, | |
1079 t->language != NULL ? ", -slang " : "", | |
1080 t->language != NULL ? t->language : ""); | |
1081 } | |
10024 | 1082 break; |
1083 | |
1084 default: // unknown track type!? error in demuxer... | |
1085 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] Error in demux_mkv.cpp: unknown " | |
1086 "demuxer type for track %u: '%c'\n", t->tnum, t->type); | |
1087 continue; | |
1088 } | |
1089 | |
1090 if (t->ok) | |
1091 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Track %u seems to be ok.\n", t->tnum); | |
1092 } | |
1093 | |
1094 return 1; | |
1095 } | |
1096 | |
1097 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
|
1098 int i, k; |
10024 | 1099 |
1100 if (d == NULL) | |
1101 return; | |
1102 | |
1103 for (i = 0; i < d->num_tracks; i++) | |
1104 if (d->tracks[i] != NULL) { | |
1105 if (d->tracks[i]->private_data != NULL) | |
1106 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
|
1107 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
|
1108 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
|
1109 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
|
1110 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
|
1111 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
|
1112 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
|
1113 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
|
1114 } |
b4040706e1d3
Added 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 delete d->tracks[i]->c_encodings; |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1116 #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
|
1117 if (d->tracks[i]->zstream_initiated) |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1118 inflateEnd(&d->tracks[i]->zstream); |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1119 #endif |
10024 | 1120 free(d->tracks[i]); |
1121 } | |
1122 | |
1123 for (i = 0; i < d->num_indexes; i++) | |
1124 free(d->index[i].entries); | |
1125 free(d->index); | |
1126 | |
1127 if (d->es != NULL) | |
1128 delete d->es; | |
1129 if (d->saved_l1 != NULL) | |
1130 delete d->saved_l1; | |
1131 if (d->in != NULL) | |
1132 delete d->in; | |
1133 if (d->segment != NULL) | |
1134 delete d->segment; | |
11260 | 1135 if (d->chapters != NULL) |
1136 delete d->chapters; | |
10024 | 1137 |
1138 free(d); | |
1139 } | |
1140 | |
1141 static void add_index_entry(mkv_demuxer_t *d, uint32_t tnum, uint64_t filepos, | |
1142 uint64_t timecode, int is_key) { | |
1143 int i, found; | |
1144 mkv_index_entry_t *entry; | |
1145 | |
1146 for (i = 0, found = 0; i < d->num_indexes; i++) | |
1147 if (d->index[i].tnum == tnum) { | |
1148 found = 1; | |
1149 break; | |
1150 } | |
1151 | |
1152 if (!found) { | |
1153 d->index = (mkv_track_index_t *)realloc(d->index, (d->num_indexes + 1) * | |
1154 sizeof(mkv_track_index_t)); | |
1155 if (d->index == NULL) | |
1156 return; | |
1157 i = d->num_indexes; | |
1158 memset(&d->index[i], 0, sizeof(mkv_track_index_t)); | |
1159 d->index[i].tnum = tnum; | |
1160 d->num_indexes++; | |
1161 } | |
1162 | |
1163 d->index[i].entries = | |
1164 (mkv_index_entry_t *)realloc(d->index[i].entries, | |
1165 (d->index[i].num_entries + 1) * | |
1166 sizeof(mkv_index_entry_t)); | |
1167 if (d->index[i].entries == NULL) | |
1168 return; | |
1169 entry = &d->index[i].entries[d->index[i].num_entries]; | |
1170 entry->filepos = filepos; | |
1171 entry->timecode = timecode; | |
1172 entry->is_key = is_key; | |
1173 d->index[i].num_entries++; | |
1174 } | |
1175 | |
1176 static void add_cluster_position(mkv_demuxer_t *mkv_d, int64_t position) { | |
1177 mkv_d->cluster_positions = (int64_t *)realloc(mkv_d->cluster_positions, | |
1178 (mkv_d->num_cluster_pos + 1) * | |
1179 sizeof(int64_t)); | |
1180 if (mkv_d->cluster_positions != NULL) { | |
1181 mkv_d->cluster_positions[mkv_d->num_cluster_pos] = position; | |
1182 mkv_d->num_cluster_pos++; | |
1183 } else | |
1184 mkv_d->num_cluster_pos = 0; | |
1185 } | |
1186 | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1187 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
|
1188 unsigned int i; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1189 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1190 for (i = 0; i < vec.size(); i++) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1191 if (vec[i] == value) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1192 return 1; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1193 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1194 return 0; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1195 } |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1196 |
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
|
1197 #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
|
1198 (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
|
1199 #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
|
1200 (((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
|
1201 #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
|
1202 (((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
|
1203 |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1204 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
|
1205 EbmlElement *l2 = NULL; |
10024 | 1206 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
|
1207 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
|
1208 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
|
1209 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
|
1210 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
|
1211 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
|
1212 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
|
1213 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
|
1214 int upper_lvl_el, i, k; |
10024 | 1215 uint64_t tc_scale, filepos = 0, timecode = 0; |
1216 uint32_t tnum = 0; | |
1217 mkv_index_entry_t *entry; | |
1218 | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1219 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
|
1220 return; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1221 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1222 mkv_d->parsed_cues->push_back(pos); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1223 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1224 mkv_d->in->setFilePointer(pos); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1225 |
10024 | 1226 es = mkv_d->es; |
1227 tc_scale = mkv_d->tc_scale; | |
1228 upper_lvl_el = 0; | |
1229 | |
1230 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing cues ] -----------\n"); | |
1231 | |
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
|
1232 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
|
1233 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
|
1234 if (cues == NULL) |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1235 return; |
10024 | 1236 |
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
|
1237 if (!(EbmlId(*cues) == KaxCues::ClassInfos.GlobalId)) { |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1238 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
|
1239 "[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
|
1240 cues->Generic().DebugName); |
10024 | 1241 |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1242 return; |
10024 | 1243 } |
1244 | |
1245 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |+ found cues\n"); | |
1246 | |
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
|
1247 cues->Read(*es, KaxCues::ClassInfos.Context, upper_lvl_el, l2, true); |
10024 | 1248 |
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
|
1249 cpoint = FINDFIRST(cues, KaxCuePoint); |
10024 | 1250 |
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
|
1251 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
|
1252 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] | + found cue point\n"); |
10024 | 1253 |
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
|
1254 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
|
1255 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
|
1256 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
|
1257 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
|
1258 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1259 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1261 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
|
1262 (float)timecode / 1000.0); |
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 ctrackpos = FINDFIRST(cpoint, KaxCueTrackPositions); |
10024 | 1265 |
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
|
1266 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
|
1267 ctrack = FINDFIRST(ctrackpos, KaxCueTrack); |
10024 | 1268 |
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
|
1269 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
|
1270 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
|
1271 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
|
1272 } |
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
|
1273 |
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
|
1274 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
|
1275 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] | + found cue track: %u\n", tnum); |
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 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
|
1278 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
|
1279 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
|
1280 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
|
1281 } |
10024 | 1282 |
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
|
1283 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
|
1284 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
|
1285 "position: %llu\n", filepos); |
10024 | 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 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
|
1288 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
|
1289 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
|
1290 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 ctrackpos = FINDNEXT(cpoint, KaxCueTrackPositions, ctrackpos); |
10024 | 1292 } |
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
|
1293 |
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
|
1294 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
|
1295 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 delete cues; |
10024 | 1298 |
1299 // Debug: dump the index | |
1300 for (i = 0; i < mkv_d->num_indexes; i++) { | |
1301 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] Index for track %u contains %u " | |
1302 "entries.\n", mkv_d->index[i].tnum, mkv_d->index[i].num_entries); | |
1303 for (k = 0; k < mkv_d->index[i].num_entries; k++) { | |
1304 entry = &mkv_d->index[i].entries[k]; | |
1305 mp_msg(MSGT_DEMUX, MSGL_DBG2, "[mkv] %d: timecode %llu, filepos %llu, " | |
1306 "is key: %s\n", k, entry->timecode, entry->filepos, | |
1307 entry->is_key ? "yes" : "no"); | |
1308 } | |
1309 } | |
1310 | |
1311 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing cues ] -----------\n"); | |
1312 | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1313 mkv_d->cues_found = 1; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1314 } |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1315 |
11260 | 1316 static void parse_chapters(mkv_demuxer_t *mkv_d, uint64_t pos) { |
1317 EbmlElement *l2 = NULL; | |
1318 EbmlStream *es; | |
1319 KaxChapters *kchapters; | |
1320 KaxEditionEntry *keentry; | |
1321 KaxChapterAtom *kcatom; | |
1322 KaxChapterTimeStart *kctstart; | |
1323 KaxChapterTimeEnd *kctend; | |
1324 int upper_lvl_el, i, k; | |
1325 mkv_chapter_t chapter; | |
1326 | |
1327 if (mkv_d->chapters != NULL) | |
1328 return; | |
1329 | |
1330 es = mkv_d->es; | |
1331 upper_lvl_el = 0; | |
1332 | |
1333 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing chapters ] ---------\n"); | |
1334 | |
1335 mkv_d->in->setFilePointer(pos); | |
1336 | |
1337 kchapters = | |
1338 (KaxChapters *)es->FindNextElement(mkv_d->segment->Generic().Context, | |
1339 upper_lvl_el, 0xFFFFFFFFL, true, 1); | |
1340 if (kchapters == NULL) | |
1341 return; | |
1342 | |
1343 if (!(EbmlId(*kchapters) == KaxChapters::ClassInfos.GlobalId)) { | |
1344 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] No KaxChapters element found but %s.\n" | |
1345 "[mkv] \\---- [ parsing chapters ] ---------\n", | |
1346 kchapters->Generic().DebugName); | |
1347 | |
1348 return; | |
1349 } | |
1350 | |
1351 mkv_d->chapters = new vector<mkv_chapter_t>; | |
1352 kchapters->Read(*es, KaxChapters::ClassInfos.Context, upper_lvl_el, l2, | |
1353 true); | |
1354 | |
1355 for (i = 0; i < (int)kchapters->ListSize(); i++) { | |
1356 keentry = (KaxEditionEntry *)(*kchapters)[i]; | |
1357 if (EbmlId(*keentry) == KaxEditionEntry::ClassInfos.GlobalId) { | |
1358 for (k = 0; k < (int)keentry->ListSize(); k++) { | |
1359 kcatom = (KaxChapterAtom *)(*keentry)[k]; | |
1360 if (EbmlId(*kcatom) == KaxChapterAtom::ClassInfos.GlobalId) { | |
1361 chapter.start = 0; | |
1362 chapter.end = 0; | |
1363 kctstart = FINDFIRST(kcatom, KaxChapterTimeStart); | |
1364 if (kctstart != NULL) | |
1365 chapter.start = uint64(*kctstart) / 1000000; | |
1366 kctend = FINDFIRST(kcatom, KaxChapterTimeEnd); | |
1367 if (kctend != NULL) | |
1368 chapter.end = uint64(*kctend) / 1000000; | |
1369 mkv_d->chapters->push_back(chapter); | |
1370 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Chapter %u from %02d:%02d:%02d." | |
1371 "%03d to %02d:%02d:%02d.%03d\n", mkv_d->chapters->size(), | |
1372 (int)(chapter.start / 60 / 60 / 1000), | |
1373 (int)((chapter.start / 60 / 1000) % 60), | |
1374 (int)((chapter.start / 1000) % 60), | |
1375 (int)(chapter.start % 1000), | |
1376 (int)(chapter.end / 60 / 60 / 1000), | |
1377 (int)((chapter.end / 60 / 1000) % 60), | |
1378 (int)((chapter.end / 1000) % 60), | |
1379 (int)(chapter.end % 1000)); | |
1380 } | |
1381 } | |
1382 } | |
1383 } | |
1384 | |
1385 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing chapters ] ---------\n"); | |
1386 delete kchapters; | |
1387 } | |
1388 | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1389 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
|
1390 EbmlElement *l2 = NULL; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1391 EbmlStream *es; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1392 KaxSeekHead *kseekhead; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1393 KaxSeek *kseek; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1394 KaxSeekID *ksid; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1395 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
|
1396 int upper_lvl_el, i, k, s; |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1397 uint64_t seek_pos; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1398 EbmlId *id; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1399 EbmlElement *e; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1400 binary *b; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1401 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1402 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
|
1403 return; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1404 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1405 mkv_d->parsed_seekheads->push_back(pos); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1406 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1407 es = mkv_d->es; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1408 upper_lvl_el = 0; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1409 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1410 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
|
1411 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1412 mkv_d->in->setFilePointer(pos); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1413 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1414 kseekhead = |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1415 (KaxSeekHead *)es->FindNextElement(mkv_d->segment->Generic().Context, |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1416 upper_lvl_el, 0xFFFFFFFFL, true, 1); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1417 if (kseekhead == NULL) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1418 return; |
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 if (!(EbmlId(*kseekhead) == KaxSeekHead::ClassInfos.GlobalId)) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1421 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
|
1422 "[mkv] \\---- [ parsing seek head ] ---------\n", |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1423 kseekhead->Generic().DebugName); |
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 return; |
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 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1428 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
|
1429 true); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1430 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1431 for (i = 0; i < (int)kseekhead->ListSize(); i++) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1432 kseek = (KaxSeek *)(*kseekhead)[i]; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1433 if (!(EbmlId(*kseek) == KaxSeek::ClassInfos.GlobalId)) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1434 continue; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1435 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1436 seek_pos = 0; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1437 id = NULL; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1438 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1439 for (k = 0; k < (int)kseek->ListSize(); k++) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1440 e = (*kseek)[k]; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1441 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1442 if (EbmlId(*e) == KaxSeekID::ClassInfos.GlobalId) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1443 ksid = (KaxSeekID *)e; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1444 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1445 b = ksid->GetBuffer(); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1446 s = ksid->GetSize(); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1447 if (id != NULL) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1448 delete id; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1449 id = new EbmlId(b, s); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1450 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1451 } else if (EbmlId(*e) == KaxSeekPosition::ClassInfos.GlobalId) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1452 kspos = (KaxSeekPosition *)e; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1453 seek_pos = mkv_d->segment->GetGlobalPosition(uint64(*kspos)); |
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 } |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1456 } |
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 if ((seek_pos != 0) && (id != NULL)) { |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1459 if (*id == KaxSeekHead::ClassInfos.GlobalId) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1460 parse_seekhead(mkv_d, seek_pos); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1461 else if (*id == KaxCues::ClassInfos.GlobalId) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1462 parse_cues(mkv_d, seek_pos); |
11260 | 1463 else if (*id == KaxChapters::ClassInfos.GlobalId) |
1464 parse_chapters(mkv_d, seek_pos); | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1465 } |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1466 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1467 if (id != NULL) |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1468 delete id; |
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 delete kseekhead; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1472 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1473 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing seek head ] ---------\n"); |
10024 | 1474 } |
1475 | |
11260 | 1476 extern "C" void demux_mkv_seek(demuxer_t *demuxer, float rel_seek_secs, |
1477 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
|
1478 |
10024 | 1479 extern "C" int demux_mkv_open(demuxer_t *demuxer) { |
1480 unsigned char signature[4]; | |
1481 stream_t *s; | |
1482 demux_packet_t *dp; | |
1483 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
|
1484 int upper_lvl_el, exit_loop, i, vid, sid, aid; |
10024 | 1485 // 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
|
1486 EbmlElement *l0 = NULL, *l1 = NULL, *l2 = NULL; |
10024 | 1487 EbmlStream *es; |
1488 mkv_track_t *track; | |
1489 sh_audio_t *sh_a; | |
1490 sh_video_t *sh_v; | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1491 vector<uint64_t> seekheads_to_parse; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1492 vector<uint64_t> cues_to_parse; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1493 int64_t current_pos; |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
1494 qt_image_description_t *idesc; |
10024 | 1495 |
1496 #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
|
1497 subcp_open(); |
10024 | 1498 #endif |
1499 | |
1500 s = demuxer->stream; | |
1501 stream_seek(s, s->start_pos); | |
1502 memset(signature, 0, 4); | |
1503 stream_read(s, (char *)signature, 4); | |
1504 if ((signature[0] != 0x1A) || (signature[1] != 0x45) || | |
1505 (signature[2] != 0xDF) || (signature[3] != 0xA3)) | |
1506 return 0; | |
1507 stream_seek(s, s->start_pos); | |
1508 | |
1509 try { | |
1510 // 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
|
1511 mkv_d = (mkv_demuxer_t *)safemalloc(sizeof(mkv_demuxer_t)); |
10024 | 1512 memset(mkv_d, 0, sizeof(mkv_demuxer_t)); |
1513 mkv_d->duration = -1.0; | |
1514 | |
1515 // Create the interface between MPlayer's IO system and | |
1516 // libmatroska's IO system. | |
1517 mkv_d->in = new mpstream_io_callback(demuxer->stream); | |
1518 if (mkv_d->in == NULL) { | |
1519 free_mkv_demuxer(mkv_d); | |
1520 return 0; | |
1521 } | |
1522 mpstream_io_callback &io = *static_cast<mpstream_io_callback *>(mkv_d->in); | |
1523 mkv_d->es = new EbmlStream(io); | |
1524 if (mkv_d->es == NULL) { | |
1525 free_mkv_demuxer(mkv_d); | |
1526 return 0; | |
1527 } | |
1528 es = mkv_d->es; | |
1529 | |
1530 // Find the EbmlHead element. Must be the first one. | |
10638 | 1531 l0 = es->FindNextID(EbmlHead::ClassInfos, 0xFFFFFFFFFFFFFFFFULL); |
10024 | 1532 if (l0 == NULL) { |
1533 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] no head found\n"); | |
1534 free_mkv_demuxer(mkv_d); | |
1535 return 0; | |
1536 } | |
1537 // Don't verify its data for now. | |
1538 l0->SkipData(static_cast<EbmlStream &>(*es), l0->Generic().Context); | |
1539 delete l0; | |
1540 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Found the head...\n"); | |
1541 | |
1542 // Next element must be a segment | |
10638 | 1543 l0 = es->FindNextID(KaxSegment::ClassInfos, 0xFFFFFFFFFFFFFFFFULL); |
10024 | 1544 if (l0 == NULL) { |
1545 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] but no segment :(\n"); | |
1546 free_mkv_demuxer(mkv_d); | |
1547 return 0; | |
1548 } | |
1549 if (!(EbmlId(*l0) == KaxSegment::ClassInfos.GlobalId)) { | |
1550 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] but no segment :(\n"); | |
1551 free_mkv_demuxer(mkv_d); | |
1552 return 0; | |
1553 } | |
1554 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] + a segment...\n"); | |
1555 | |
1556 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
|
1557 mkv_d->tc_scale = MKVD_TIMECODESCALE; |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1558 mkv_d->parsed_seekheads = new vector<uint64_t>; |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1559 mkv_d->parsed_cues = new vector<uint64_t>; |
10024 | 1560 |
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
|
1561 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
|
1562 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
|
1563 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
|
1564 |
10024 | 1565 upper_lvl_el = 0; |
1566 exit_loop = 0; | |
1567 // We've got our segment, so let's find the tracks | |
1568 l1 = es->FindNextElement(l0->Generic().Context, upper_lvl_el, 0xFFFFFFFFL, | |
1569 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
|
1570 while ((l1 != NULL) && (upper_lvl_el <= 0)) { |
10024 | 1571 |
1572 if (EbmlId(*l1) == KaxInfo::ClassInfos.GlobalId) { | |
1573 // 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
|
1574 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
|
1575 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
|
1576 |
10024 | 1577 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |+ segment information...\n"); |
1578 | |
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
|
1579 l1->Read(*es, KaxInfo::ClassInfos.Context, upper_lvl_el, l2, true); |
10024 | 1580 |
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
|
1581 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
|
1582 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
|
1583 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
|
1584 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
|
1585 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
|
1586 } 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
|
1587 mkv_d->tc_scale = MKVD_TIMECODESCALE; |
10024 | 1588 |
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
|
1589 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
|
1590 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
|
1591 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
|
1592 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
|
1593 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
|
1594 } |
10024 | 1595 |
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
|
1596 l1->SkipData(*es, l1->Generic().Context); |
10024 | 1597 |
1598 } else if (EbmlId(*l1) == KaxTracks::ClassInfos.GlobalId) { | |
1599 // Yep, we've found our KaxTracks element. Now find all tracks | |
1600 // 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
|
1601 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1603 |
10024 | 1604 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
|
1605 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1607 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1608 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
|
1609 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
|
1610 // We actually found a track entry :) We're happy now. |
10024 | 1611 |
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
|
1612 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
|
1613 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
|
1614 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
|
1615 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
|
1616 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
|
1617 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
|
1618 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
|
1619 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
|
1620 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
|
1621 #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
|
1622 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
|
1623 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
|
1624 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
|
1625 #endif |
10024 | 1626 |
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
|
1627 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
|
1628 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1630 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
|
1631 return 0; |
10024 | 1632 |
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
|
1633 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
|
1634 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
|
1635 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
|
1636 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
|
1637 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
|
1638 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
|
1639 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
|
1640 "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
|
1641 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
|
1642 } |
10024 | 1643 |
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
|
1644 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
|
1645 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
|
1646 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
|
1647 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
|
1648 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
|
1649 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
|
1650 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
|
1651 "%.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
|
1652 (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
|
1653 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 } |
10024 | 1655 |
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
|
1656 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
|
1657 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
|
1658 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Track type: "); |
10081
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
1659 |
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
|
1660 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
|
1661 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
|
1662 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
|
1663 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
|
1664 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
|
1665 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
|
1666 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
|
1667 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
|
1668 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
|
1669 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
|
1670 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
|
1671 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
|
1672 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
|
1673 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
|
1674 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
|
1675 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
|
1676 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
|
1677 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
|
1678 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
|
1679 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
|
1680 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
|
1681 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
|
1682 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
|
1683 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1684 } |
10024 | 1685 |
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
|
1686 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
|
1687 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
|
1688 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
|
1689 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
|
1690 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
|
1691 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Audio track\n"); |
10024 | 1693 |
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
|
1694 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
|
1695 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
|
1696 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
|
1697 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
|
1698 "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
|
1699 } 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
|
1700 track->a_sfreq = 8000.0; |
10024 | 1701 |
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
|
1702 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
|
1703 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
|
1704 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
|
1705 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
|
1706 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
|
1707 } 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
|
1708 track->a_channels = 1; |
10024 | 1709 |
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
|
1710 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
|
1711 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
|
1712 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
|
1713 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
|
1714 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
|
1715 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 |
10024 | 1717 } |
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
|
1718 |
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
|
1719 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
|
1720 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
|
1721 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
|
1722 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
|
1723 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
|
1724 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
|
1725 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
|
1726 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1728 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
|
1729 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
|
1730 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
|
1731 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
|
1732 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1735 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
|
1736 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
|
1737 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
|
1738 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
|
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 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1742 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
|
1743 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
|
1744 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
|
1745 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
|
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 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1749 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
|
1750 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
|
1751 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
|
1752 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
|
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 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 // 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
|
1756 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
|
1757 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
|
1758 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
|
1759 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
|
1760 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
|
1761 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1766 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
|
1767 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
|
1768 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
|
1769 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
|
1770 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1773 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
|
1774 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
|
1775 "%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
|
1776 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
|
1777 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
|
1778 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
|
1779 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
|
1780 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1783 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
|
1784 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
|
1785 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
|
1786 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
|
1787 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 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
|
1790 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
|
1791 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
|
1792 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
|
1793 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
|
1794 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
|
1795 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
|
1796 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 |
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
|
1798 #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
|
1799 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
|
1800 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
|
1801 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
|
1802 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
|
1803 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
|
1804 |
b4040706e1d3
Added support for additional content encoding (compression, encryption) in general and zlib compression in particular (to be used with VobSubs).
mosu
parents:
11155
diff
changeset
|
1805 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
|
1806 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
|
1807 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
|
1808 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
|
1809 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
|
1810 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
|
1811 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
|
1812 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
|
1813 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
|
1814 |
b4040706e1d3
Added 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 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
|
1816 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
|
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 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
|
1819 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
|
1820 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
|
1821 |
b4040706e1d3
Added 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 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
|
1823 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
|
1824 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
|
1825 |
b4040706e1d3
Added 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 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
|
1827 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
|
1828 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
|
1829 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
|
1830 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
|
1831 |
b4040706e1d3
Added 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 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
|
1833 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
|
1834 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
|
1835 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
|
1836 |
b4040706e1d3
Added 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 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
|
1838 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
|
1839 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
|
1840 |
b4040706e1d3
Added 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 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
|
1842 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
|
1843 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
|
1844 (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
|
1845 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
|
1846 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
|
1847 } |
b4040706e1d3
Added 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 } |
b4040706e1d3
Added 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 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
|
1851 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
|
1852 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
|
1853 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
|
1854 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
|
1855 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
|
1856 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
|
1857 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
|
1858 |
b4040706e1d3
Added 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 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
|
1860 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
|
1861 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
|
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_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
|
1864 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
|
1865 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
|
1866 (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
|
1867 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
|
1868 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
|
1869 } |
b4040706e1d3
Added 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 |
b4040706e1d3
Added 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 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
|
1872 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
|
1873 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
|
1874 |
b4040706e1d3
Added 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 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
|
1876 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
|
1877 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
|
1878 |
b4040706e1d3
Added 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 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
|
1880 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
|
1881 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
|
1882 (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
|
1883 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
|
1884 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
|
1885 } |
b4040706e1d3
Added 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 |
b4040706e1d3
Added 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 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
|
1888 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
|
1889 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
|
1890 (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
|
1891 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
|
1892 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
|
1893 } |
b4040706e1d3
Added 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 |
b4040706e1d3
Added 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 } |
b4040706e1d3
Added 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 |
b4040706e1d3
Added 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 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
|
1898 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
|
1899 (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
|
1900 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
|
1901 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
|
1902 } |
b4040706e1d3
Added 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 } |
b4040706e1d3
Added 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 } |
b4040706e1d3
Added 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 |
b4040706e1d3
Added 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 #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
|
1907 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
|
1908 } // 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
|
1909 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1910 l1->SkipData(*es, l1->Generic().Context); |
10024 | 1911 |
1912 } else if (EbmlId(*l1) == KaxSeekHead::ClassInfos.GlobalId) { | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1913 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
|
1914 seekheads_to_parse.push_back(l1->GetElementPosition()); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1915 l1->SkipData(*es, l1->Generic().Context); |
10024 | 1916 |
1917 } else if ((EbmlId(*l1) == KaxCues::ClassInfos.GlobalId) && | |
1918 !mkv_d->cues_found) { | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1919 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
|
1920 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
|
1921 l1->SkipData(*es, l1->Generic().Context); |
10024 | 1922 |
11260 | 1923 } else if (EbmlId(*l1) == KaxChapters::ClassInfos.GlobalId) { |
1924 parse_chapters(mkv_d, l1->GetElementPosition()); | |
1925 l1->SkipData(*es, l1->Generic().Context); | |
1926 | |
10024 | 1927 } else if (EbmlId(*l1) == KaxCluster::ClassInfos.GlobalId) { |
1928 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] |+ found cluster, headers are " | |
1929 "parsed completely :)\n"); | |
1930 add_cluster_position(mkv_d, l1->GetElementPosition()); | |
1931 mkv_d->saved_l1 = l1; | |
1932 exit_loop = 1; | |
1933 | |
1934 } 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
|
1935 l1->SkipData(*es, l1->Generic().Context); |
10024 | 1936 |
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
|
1937 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
|
1938 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
|
1939 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
|
1940 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1941 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
1942 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
|
1943 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
|
1944 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
|
1945 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
|
1946 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
|
1947 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
|
1948 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
|
1949 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 } 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
|
1951 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
|
1952 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
|
1953 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
|
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 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. 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 |
10024 | 1957 if (exit_loop) // we've found the first cluster, so get out |
1958 break; | |
1959 | |
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
|
1960 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
|
1961 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
|
1962 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
|
1963 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
|
1964 |
10024 | 1965 } // while (l1 != NULL) |
1966 | |
1967 if (!exit_loop) { | |
1968 free_mkv_demuxer(mkv_d); | |
1969 return 0; | |
1970 } | |
1971 | |
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
|
1972 current_pos = io.getFilePointer(); |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1973 |
10283
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1974 // 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
|
1975 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
|
1976 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
|
1977 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
|
1978 (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
|
1979 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
|
1980 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
|
1981 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
|
1982 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
|
1983 } else |
21972de8631d
Support for files whose first timecode is not 0 (which is the case for splitted/linked files).
mosu
parents:
10273
diff
changeset
|
1984 mkv_d->first_tc = 0; |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1985 |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1986 // Parse all cues and seek heads |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1987 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
|
1988 parse_cues(mkv_d, cues_to_parse[i]); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1989 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
|
1990 parse_seekhead(mkv_d, seekheads_to_parse[i]); |
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
1991 |
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
|
1992 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
|
1993 |
10024 | 1994 } catch (exception &ex) { |
1995 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] caught exception\n"); | |
1996 return 0; | |
1997 } | |
1998 | |
1999 if (!check_track_information(mkv_d)) { | |
2000 free_mkv_demuxer(mkv_d); | |
2001 return 0; | |
2002 } | |
2003 | |
2004 track = NULL; | |
2005 if (demuxer->video->id == -1) { // Automatically select a video track. | |
2006 // Search for a video track that has the 'default' flag set. | |
2007 for (i = 0; i < mkv_d->num_tracks; i++) | |
2008 if ((mkv_d->tracks[i]->type == 'v') && mkv_d->tracks[i]->ok && | |
2009 mkv_d->tracks[i]->default_track) { | |
2010 track = mkv_d->tracks[i]; | |
2011 break; | |
2012 } | |
2013 | |
2014 if (track == NULL) | |
2015 // No track has the 'default' flag set - let's take the first video | |
2016 // track. | |
2017 for (i = 0; i < mkv_d->num_tracks; i++) | |
2018 if ((mkv_d->tracks[i]->type == 'v') && mkv_d->tracks[i]->ok) { | |
2019 track = mkv_d->tracks[i]; | |
2020 break; | |
2021 } | |
2022 } 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
|
2023 track = find_track_by_num(mkv_d, demuxer->video->id, 'v'); |
10024 | 2024 |
2025 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
|
2026 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
|
2027 |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2028 idesc = 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
|
2029 bih = (BITMAPINFOHEADER *)safemalloc(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
|
2030 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
|
2031 |
10024 | 2032 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
|
2033 BITMAPINFOHEADER *src; |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2034 src = (BITMAPINFOHEADER *)track->private_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
|
2035 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
|
2036 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
|
2037 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
|
2038 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
|
2039 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
|
2040 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
|
2041 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
|
2042 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
|
2043 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
|
2044 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
|
2045 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
|
2046 memcpy((char *)bih + sizeof(BITMAPINFOHEADER), |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2047 (char *)src + sizeof(BITMAPINFOHEADER), |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2048 track->private_size - sizeof(BITMAPINFOHEADER)); |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2049 |
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
|
2050 } 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
|
2051 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
|
2052 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
|
2053 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
|
2054 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
|
2055 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
|
2056 |
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 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
|
2058 (!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
|
2059 !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
|
2060 !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
|
2061 !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
|
2062 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
|
2063 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
|
2064 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
|
2065 |
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 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
|
2067 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
|
2068 |
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 = (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
|
2070 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
|
2071 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
|
2072 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
|
2073 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
|
2074 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
|
2075 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
|
2076 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
|
2077 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
|
2078 ((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
|
2079 ((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
|
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 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
|
2082 (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
|
2083 // 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
|
2084 ((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
|
2085 ((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
|
2086 } 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
|
2087 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
|
2088 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
|
2089 |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2090 #if defined(USE_QTX_CODECS) |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2091 } 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
|
2092 (!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
|
2093 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
|
2094 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
|
2095 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
|
2096 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
|
2097 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
|
2098 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
|
2099 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
|
2100 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
|
2101 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
|
2102 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
|
2103 idesc->horizontal_resolution = |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2104 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
|
2105 idesc->vertical_resolution = |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2106 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
|
2107 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
|
2108 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
|
2109 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
|
2110 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
|
2111 bih->biPlanes = 1; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2112 bih->biCompression = idesc->codec_type; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2113 #endif // defined(USE_QTX_CODECS) |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2114 |
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
|
2115 } 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
|
2116 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
|
2117 "(%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
|
2118 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
|
2119 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
|
2120 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2121 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2122 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2123 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
|
2124 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
|
2125 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
|
2126 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2127 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
|
2128 sh_v->bih = bih; |
10024 | 2129 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
|
2130 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
|
2131 track->v_frate = 25.0; |
10024 | 2132 sh_v->fps = track->v_frate; |
2133 sh_v->frametime = 1 / track->v_frate; | |
10081
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
2134 sh_v->disp_w = track->v_width; |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
2135 sh_v->disp_h = track->v_height; |
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
2136 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
|
2137 if (idesc != NULL) |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2138 sh_v->ImageDesc = idesc; |
10081
0181d5fc8474
Support for aspect ratio set via DisplayWidth/DisplayHeight.
mosu
parents:
10079
diff
changeset
|
2139 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] Aspect: %f\n", sh_v->aspect); |
10024 | 2140 |
2141 demuxer->video->id = track->tnum; | |
2142 demuxer->video->sh = sh_v; | |
2143 sh_v->ds = demuxer->video; | |
2144 | |
2145 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
|
2146 } 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
|
2147 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
|
2148 |
10024 | 2149 } else { |
2150 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] No video track found/wanted.\n"); | |
2151 demuxer->video->id = -2; | |
2152 } | |
2153 | |
2154 track = NULL; | |
2155 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
|
2156 // 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
|
2157 if (audio_lang != NULL) { |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2158 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
|
2159 } |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2160 if (track == NULL) |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2161 // 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
|
2162 // 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
|
2163 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
|
2164 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
|
2165 mkv_d->tracks[i]->default_track) { |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2166 track = mkv_d->tracks[i]; |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2167 break; |
531b00ad6f2d
Support for selecting the audio track in Matroska files via -alang.
mosu
parents:
10149
diff
changeset
|
2168 } |
10024 | 2169 |
2170 if (track == NULL) | |
2171 // No track has the 'default' flag set - let's take the first audio | |
2172 // track. | |
2173 for (i = 0; i < mkv_d->num_tracks; i++) | |
2174 if ((mkv_d->tracks[i]->type == 'a') && mkv_d->tracks[i]->ok) { | |
2175 track = mkv_d->tracks[i]; | |
2176 break; | |
2177 } | |
2178 } 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
|
2179 track = find_track_by_num(mkv_d, demuxer->audio->id, 'a'); |
10024 | 2180 |
2181 if (track) { | |
2182 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Will play audio track %u\n", | |
2183 track->tnum); | |
2184 sh_a = new_sh_audio(demuxer, track->tnum); | |
2185 | |
2186 demuxer->audio->id = track->tnum; | |
2187 demuxer->audio->sh = sh_a; | |
2188 sh_a->ds = demuxer->audio; | |
2189 | |
2190 mkv_d->audio = track; | |
2191 | |
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
|
2192 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
|
2193 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
|
2194 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
|
2195 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
|
2196 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
|
2197 memset(sh_a->wf, 0, sizeof(WAVEFORMATEX)); |
10024 | 2198 } |
10125 | 2199 sh_a->format = track->a_formattag; |
2200 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
|
2201 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
|
2202 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
|
2203 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
|
2204 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
|
2205 sh_a->samplesize = track->a_bps / 8; |
11155 | 2206 if (!strcmp(track->codec_id, MKV_A_MP3) || |
2207 !strcmp(track->codec_id, MKV_A_MP2)) { | |
10024 | 2208 sh_a->wf->nAvgBytesPerSec = 16000; |
2209 sh_a->wf->nBlockAlign = 1152; | |
2210 sh_a->wf->wBitsPerSample = 0; | |
2211 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
|
2212 |
11114
d8ddd7727084
More liberal codec id recognition for AC3 codecs (needed for transcoded DNET from RM).
mosu
parents:
10984
diff
changeset
|
2213 } else if (!strncmp(track->codec_id, MKV_A_AC3, strlen(MKV_A_AC3))) { |
10024 | 2214 sh_a->wf->nAvgBytesPerSec = 16000; |
2215 sh_a->wf->nBlockAlign = 1536; | |
2216 sh_a->wf->wBitsPerSample = 0; | |
2217 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
|
2218 |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2219 } 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
|
2220 !strcmp(track->codec_id, MKV_A_PCM_BE)) { |
10024 | 2221 sh_a->wf->nAvgBytesPerSec = sh_a->channels * sh_a->samplerate * 2; |
2222 sh_a->wf->nBlockAlign = sh_a->wf->nAvgBytesPerSec; | |
2223 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
|
2224 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
|
2225 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
|
2226 |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2227 } 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
|
2228 !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
|
2229 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
|
2230 sh_a->wf->nAvgBytesPerSec = 16000; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2231 sh_a->wf->nBlockAlign = 1486; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2232 track->fix_i_bps = true; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2233 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
|
2234 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
|
2235 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
|
2236 track->private_size); |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2237 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
|
2238 } |
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_QDMC)) |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2240 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
|
2241 else |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2242 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
|
2243 |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2244 } 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
|
2245 int profile, srate_idx; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2246 |
10125 | 2247 sh_a->wf->nAvgBytesPerSec = 16000; |
2248 sh_a->wf->nBlockAlign = 1024; | |
2249 sh_a->wf->wBitsPerSample = 0; | |
2250 sh_a->samplesize = 0; | |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2251 |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2252 // 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
|
2253 // A_AAC/MPEG2/MAIN |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2254 // 0123456789012345 |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2255 if (!strcmp(&track->codec_id[12], "MAIN")) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2256 profile = 0; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2257 else if (!strcmp(&track->codec_id[12], "LC")) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2258 profile = 1; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2259 else if (!strcmp(&track->codec_id[12], "SSR")) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2260 profile = 2; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2261 else |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2262 profile = 3; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2263 if (92017 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2264 srate_idx = 0; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2265 else if (75132 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2266 srate_idx = 1; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2267 else if (55426 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2268 srate_idx = 2; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2269 else if (46009 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2270 srate_idx = 3; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2271 else if (37566 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2272 srate_idx = 4; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2273 else if (27713 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2274 srate_idx = 5; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2275 else if (23004 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2276 srate_idx = 6; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2277 else if (18783 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2278 srate_idx = 7; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2279 else if (13856 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2280 srate_idx = 8; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2281 else if (11502 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2282 srate_idx = 9; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2283 else if (9391 <= sh_a->samplerate) |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2284 srate_idx = 10; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2285 else |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2286 srate_idx = 11; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2287 |
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
|
2288 sh_a->codecdata = (unsigned char *)safemalloc(2); |
10133
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2289 sh_a->codecdata_len = 2; |
d9c9422887ca
Endian fixes and proper support for headerless AAC streams.
mosu
parents:
10125
diff
changeset
|
2290 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
|
2291 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
|
2292 |
10024 | 2293 } else if (!strcmp(track->codec_id, MKV_A_VORBIS)) { |
2294 for (i = 0; i < 3; i++) { | |
2295 dp = new_demux_packet(track->header_sizes[i]); | |
2296 memcpy(dp->buffer, track->headers[i], track->header_sizes[i]); | |
2297 dp->pts = 0; | |
2298 dp->flags = 0; | |
2299 ds_add_packet(demuxer->audio, dp); | |
2300 } | |
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
|
2301 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2302 } 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
|
2303 !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
|
2304 // 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
|
2305 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
|
2306 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
|
2307 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
|
2308 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
|
2309 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2310 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
|
2311 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
|
2312 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2313 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
|
2314 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
|
2315 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
|
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 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
|
2318 |
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 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
|
2320 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
|
2321 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
|
2322 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
|
2323 } 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
|
2324 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
|
2325 |
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 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
|
2327 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
|
2328 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
|
2329 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
|
2330 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
|
2331 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
|
2332 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
|
2333 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
|
2334 ((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
|
2335 ((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
|
2336 ((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
|
2337 ((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
|
2338 ((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
|
2339 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
|
2340 |
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
|
2341 track->realmedia = true; |
10024 | 2342 } |
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
|
2343 |
10024 | 2344 } else { |
2345 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] No audio track found/wanted.\n"); | |
2346 demuxer->audio->id = -2; | |
2347 } | |
2348 | |
2349 // DO NOT automatically select a subtitle track and behave like DVD | |
2350 // 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
|
2351 track = NULL; |
4c4c2761643c
Proper key frame reporting. Proper handling of "no subtitles wanted".
mosu
parents:
10060
diff
changeset
|
2352 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
|
2353 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
|
2354 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
|
2355 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
|
2356 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
|
2357 if (!strcmp(track->codec_id, MKV_S_VOBSUB)) { |
11154 | 2358 mp_msg(MSGT_DEMUX, MSGL_INFO, "[mkv] Will display subtitle track %u\n", |
2359 track->tnum); | |
2360 mkv_d->subs_track = track; | |
2361 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
|
2362 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
|
2363 sizeof(mkv_sh_sub_t)); |
11154 | 2364 demuxer->sub->id = track->xid; |
2365 | |
11276 | 2366 } else if (strcmp(track->codec_id, MKV_S_TEXTASCII) && |
11154 | 2367 strcmp(track->codec_id, MKV_S_TEXTUTF8) && |
2368 strcmp(track->codec_id, MKV_S_TEXTSSA) && | |
11276 | 2369 strcmp(track->codec_id, "S_SSA") && |
2370 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
|
2371 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
|
2372 "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
|
2373 else { |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2374 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
|
2375 track->tnum); |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2376 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
|
2377 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
|
2378 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
|
2379 mkv_d->subs.text[i] = (char *)safemalloc(256); |
10024 | 2380 |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2381 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
|
2382 sub_utf8 = 1; // Force UTF-8 conversion. |
10984 | 2383 if (!strcmp(track->codec_id, MKV_S_TEXTSSA) || |
11276 | 2384 !strcmp(track->codec_id, "S_SSA") || |
2385 !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
|
2386 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
|
2387 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
|
2388 } else |
10845
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2389 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
|
2390 } else |
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2391 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
|
2392 "subtitle track with the id %u.\n", demuxer->sub->id); |
11154 | 2393 demuxer->sub->sh = NULL; |
10024 | 2394 } |
2395 } | |
2396 | |
11260 | 2397 demuxer->priv = mkv_d; |
2398 | |
2399 if (mkv_d->chapters != NULL) { | |
2400 for (i = 0; i < (int)mkv_d->chapters->size(); i++) { | |
2401 (*mkv_d->chapters)[i].start -= mkv_d->first_tc; | |
2402 (*mkv_d->chapters)[i].end -= mkv_d->first_tc; | |
2403 } | |
2404 if ((dvd_last_chapter > 0) && | |
2405 (dvd_last_chapter <= (int)mkv_d->chapters->size())) { | |
2406 if ((*mkv_d->chapters)[dvd_last_chapter - 1].end != 0) | |
2407 mkv_d->stop_timecode = (*mkv_d->chapters)[dvd_last_chapter - 1].end; | |
2408 else if ((dvd_last_chapter + 1) <= (int)mkv_d->chapters->size()) | |
2409 mkv_d->stop_timecode = (*mkv_d->chapters)[dvd_last_chapter].start; | |
2410 } | |
2411 } | |
2412 | |
10024 | 2413 if (s->end_pos == 0) |
2414 demuxer->seekable = 0; | |
2415 else { | |
2416 demuxer->movi_start = s->start_pos; | |
2417 demuxer->movi_end = s->end_pos; | |
2418 demuxer->seekable = 1; | |
11260 | 2419 if ((dvd_chapter != 1) && (mkv_d->chapters != NULL) && |
2420 (dvd_chapter <= (int)mkv_d->chapters->size())) | |
2421 demux_mkv_seek(demuxer, (float)(*mkv_d->chapters)[dvd_chapter - 1].start | |
2422 / 1000.0, 1); | |
10024 | 2423 } |
2424 | |
2425 return 1; | |
2426 } | |
2427 | |
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
|
2428 // 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
|
2429 #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
|
2430 #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
|
2431 |
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
|
2432 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
|
2433 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
|
2434 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
|
2435 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
|
2436 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
|
2437 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
|
2438 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
|
2439 |
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
|
2440 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
|
2441 !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
|
2442 |
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
|
2443 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
|
2444 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
|
2445 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
|
2446 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
|
2447 }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
|
2448 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
|
2449 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
|
2450 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
|
2451 } |
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
|
2452 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
|
2453 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
|
2454 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
|
2455 // 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
|
2456 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
|
2457 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
|
2458 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
|
2459 } 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
|
2460 // 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
|
2461 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
|
2462 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
|
2463 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
|
2464 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
|
2465 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
|
2466 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
|
2467 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
|
2468 } |
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
|
2469 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
|
2470 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
|
2471 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
|
2472 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
|
2473 } |
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 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
|
2475 "%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
|
2476 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
|
2477 } |
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 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
|
2479 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
|
2480 |
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 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
|
2482 } |
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 |
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
|
2484 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
|
2485 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
|
2486 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
|
2487 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
|
2488 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
|
2489 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
|
2490 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
|
2491 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2492 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
|
2493 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
|
2494 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
|
2495 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
|
2496 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
|
2497 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
|
2498 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
|
2499 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
|
2500 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
|
2501 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
|
2502 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
|
2503 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
|
2504 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2505 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
|
2506 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
|
2507 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
|
2508 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
|
2509 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
|
2510 } 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
|
2511 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
|
2512 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
|
2513 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
|
2514 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
|
2515 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2516 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
|
2517 |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2518 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
|
2519 } |
c2fc1c310699
Necessary changes for the upcoming libebml/libmatroska 0.5.0. Implemented support for RealAudio and RealVideo inside Matroska.
mosu
parents:
10283
diff
changeset
|
2520 |
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
|
2521 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
|
2522 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
|
2523 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
|
2524 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
|
2525 |
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 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
|
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 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
|
2529 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
|
2530 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
|
2531 !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
|
2532 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
|
2533 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
|
2534 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
|
2535 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
|
2536 |
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
|
2537 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
|
2538 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
|
2539 |
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
|
2540 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
|
2541 |
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
|
2542 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
|
2543 } |
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
|
2544 |
11154 | 2545 #define mpeg_read(buf, num) _mpeg_read(srcbuf, size, srcpos, buf, num) |
2546 static uint32_t _mpeg_read(unsigned char *srcbuf, uint32_t size, | |
2547 uint32_t &srcpos, unsigned char *dstbuf, | |
2548 uint32_t num) { | |
2549 uint32_t real_num; | |
2550 | |
2551 if ((srcpos + num) >= size) | |
2552 real_num = size - srcpos; | |
2553 else | |
2554 real_num = num; | |
2555 memcpy(dstbuf, &srcbuf[srcpos], real_num); | |
2556 srcpos += real_num; | |
2557 | |
2558 return real_num; | |
2559 } | |
2560 | |
2561 #define mpeg_getc() _mpeg_getch(srcbuf, size, srcpos) | |
2562 static int _mpeg_getch(unsigned char *srcbuf, uint32_t size, | |
2563 uint32_t &srcpos) { | |
2564 unsigned char c; | |
2565 | |
2566 if (mpeg_read(&c, 1) != 1) | |
2567 return -1; | |
2568 return (int)c; | |
2569 } | |
2570 | |
2571 #define mpeg_seek(b, w) _mpeg_seek(size, srcpos, b, w) | |
2572 static int _mpeg_seek(uint32_t size, uint32_t &srcpos, uint32_t num, | |
2573 int whence) { | |
2574 uint32_t new_pos; | |
2575 | |
2576 if (whence == SEEK_SET) | |
2577 new_pos = num; | |
2578 else if (whence == SEEK_CUR) | |
2579 new_pos = srcpos + num; | |
2580 else | |
2581 abort(); | |
2582 | |
2583 if (new_pos >= size) { | |
2584 srcpos = size; | |
2585 return 1; | |
2586 } | |
2587 | |
2588 srcpos = new_pos; | |
2589 return 0; | |
2590 } | |
2591 | |
2592 #define mpeg_tell() srcpos | |
2593 | |
2594 // Adopted from vobsub.c | |
2595 static int mpeg_run(demuxer_t *demuxer, unsigned char *srcbuf, uint32_t size) { | |
2596 uint32_t len, idx, version, srcpos, packet_size; | |
2597 int c, aid; | |
2598 float pts; | |
2599 /* Goto start of a packet, it starts with 0x000001?? */ | |
2600 const unsigned char wanted[] = { 0, 0, 1 }; | |
2601 unsigned char buf[5]; | |
2602 demux_packet_t *dp; | |
2603 demux_stream_t *ds; | |
2604 mkv_demuxer_t *mkv_d; | |
2605 | |
2606 mkv_d = (mkv_demuxer_t *)demuxer->priv; | |
2607 ds = demuxer->sub; | |
2608 | |
2609 srcpos = 0; | |
2610 packet_size = 0; | |
2611 while (1) { | |
2612 if (mpeg_read(buf, 4) != 4) | |
2613 return -1; | |
2614 while (memcmp(buf, wanted, sizeof(wanted)) != 0) { | |
2615 c = mpeg_getc(); | |
2616 if (c < 0) | |
2617 return -1; | |
2618 memmove(buf, buf + 1, 3); | |
2619 buf[3] = c; | |
2620 } | |
2621 switch (buf[3]) { | |
2622 case 0xb9: /* System End Code */ | |
2623 return 0; | |
2624 break; | |
2625 | |
2626 case 0xba: /* Packet start code */ | |
2627 c = mpeg_getc(); | |
2628 if (c < 0) | |
2629 return -1; | |
2630 if ((c & 0xc0) == 0x40) | |
2631 version = 4; | |
2632 else if ((c & 0xf0) == 0x20) | |
2633 version = 2; | |
2634 else { | |
2635 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] VobSub: Unsupported MPEG " | |
2636 "version: 0x%02x\n", c); | |
2637 return -1; | |
2638 } | |
2639 | |
2640 if (version == 4) { | |
2641 if (mpeg_seek(9, SEEK_CUR)) | |
2642 return -1; | |
2643 } else if (version == 2) { | |
2644 if (mpeg_seek(7, SEEK_CUR)) | |
2645 return -1; | |
2646 } else | |
2647 abort(); | |
2648 break; | |
2649 | |
2650 case 0xbd: /* packet */ | |
2651 if (mpeg_read(buf, 2) != 2) | |
2652 return -1; | |
2653 len = buf[0] << 8 | buf[1]; | |
2654 idx = mpeg_tell(); | |
2655 c = mpeg_getc(); | |
2656 if (c < 0) | |
2657 return -1; | |
2658 if ((c & 0xC0) == 0x40) { /* skip STD scale & size */ | |
2659 if (mpeg_getc() < 0) | |
2660 return -1; | |
2661 c = mpeg_getc(); | |
2662 if (c < 0) | |
2663 return -1; | |
2664 } | |
2665 if ((c & 0xf0) == 0x20) { /* System-1 stream timestamp */ | |
2666 /* Do we need this? */ | |
2667 abort(); | |
2668 } else if ((c & 0xf0) == 0x30) { | |
2669 /* Do we need this? */ | |
2670 abort(); | |
2671 } else if ((c & 0xc0) == 0x80) { /* System-2 (.VOB) stream */ | |
2672 uint32_t pts_flags, hdrlen, dataidx; | |
2673 c = mpeg_getc(); | |
2674 if (c < 0) | |
2675 return -1; | |
2676 pts_flags = c; | |
2677 c = mpeg_getc(); | |
2678 if (c < 0) | |
2679 return -1; | |
2680 hdrlen = c; | |
2681 dataidx = mpeg_tell() + hdrlen; | |
2682 if (dataidx > idx + len) { | |
2683 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] VobSub: Invalid header " | |
2684 "length: %d (total length: %d, idx: %d, dataidx: %d)\n", | |
2685 hdrlen, len, idx, dataidx); | |
2686 return -1; | |
2687 } | |
2688 if ((pts_flags & 0xc0) == 0x80) { | |
2689 if (mpeg_read(buf, 5) != 5) | |
2690 return -1; | |
2691 if (!(((buf[0] & 0xf0) == 0x20) && (buf[0] & 1) && (buf[2] & 1) && | |
2692 (buf[4] & 1))) { | |
2693 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] VobSub PTS error: 0x%02x " | |
2694 "%02x%02x %02x%02x \n", | |
2695 buf[0], buf[1], buf[2], buf[3], buf[4]); | |
2696 pts = 0; | |
2697 } else | |
2698 pts = ((buf[0] & 0x0e) << 29 | buf[1] << 22 | | |
2699 (buf[2] & 0xfe) << 14 | buf[3] << 7 | (buf[4] >> 1)); | |
2700 } else /* if ((pts_flags & 0xc0) == 0xc0) */ { | |
2701 /* what's this? */ | |
2702 /* abort(); */ | |
2703 } | |
2704 mpeg_seek(dataidx, SEEK_SET); | |
2705 aid = mpeg_getc(); | |
2706 if (aid < 0) { | |
2707 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] VobSub: Bogus aid %d\n", aid); | |
2708 return -1; | |
2709 } | |
2710 packet_size = len - ((unsigned int)mpeg_tell() - idx); | |
2711 | |
2712 dp = new_demux_packet(packet_size); | |
2713 dp->flags = 1; | |
2714 dp->pts = mkv_d->last_pts; | |
2715 if (mpeg_read(dp->buffer, packet_size) != packet_size) { | |
2716 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] VobSub: mpeg_read failure"); | |
2717 packet_size = 0; | |
2718 return -1; | |
2719 } | |
2720 ds_add_packet(ds, dp); | |
2721 idx = len; | |
2722 } | |
2723 break; | |
2724 | |
2725 case 0xbe: /* Padding */ | |
2726 if (mpeg_read(buf, 2) != 2) | |
2727 return -1; | |
2728 len = buf[0] << 8 | buf[1]; | |
2729 if ((len > 0) && mpeg_seek(len, SEEK_CUR)) | |
2730 return -1; | |
2731 break; | |
2732 | |
2733 default: | |
2734 if ((0xc0 <= buf[3]) && (buf[3] < 0xf0)) { | |
2735 /* MPEG audio or video */ | |
2736 if (mpeg_read(buf, 2) != 2) | |
2737 return -1; | |
2738 len = (buf[0] << 8) | buf[1]; | |
2739 if ((len > 0) && mpeg_seek(len, SEEK_CUR)) | |
2740 return -1; | |
2741 | |
2742 } | |
2743 else { | |
2744 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] VobSub: unknown header " | |
2745 "0x%02X%02X%02X%02X\n", buf[0], buf[1], buf[2], buf[3]); | |
2746 return -1; | |
2747 } | |
2748 } | |
2749 } | |
2750 return 0; | |
2751 } | |
2752 | |
10024 | 2753 extern "C" int demux_mkv_fill_buffer(demuxer_t *d) { |
2754 demux_packet_t *dp; | |
2755 demux_stream_t *ds; | |
2756 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
|
2757 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
|
2758 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
|
2759 char *texttmp; |
10024 | 2760 // 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
|
2761 EbmlElement *l0 = NULL, *l1 = NULL, *l2 = NULL, *l3 = NULL; |
10024 | 2762 EbmlStream *es; |
2763 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
|
2764 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
|
2765 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
|
2766 float current_pts; |
10024 | 2767 |
2768 mkv_d = (mkv_demuxer_t *)d->priv; | |
2769 es = mkv_d->es; | |
2770 l0 = mkv_d->segment; | |
2771 | |
2772 // End of stream | |
2773 if (mkv_d->saved_l1 == NULL) | |
2774 return 0; | |
2775 | |
2776 exit_loop = 0; | |
2777 upper_lvl_el = 0; | |
2778 l1 = mkv_d->saved_l1; | |
2779 mkv_d->saved_l1 = NULL; | |
2780 found_data = 0; | |
2781 try { | |
2782 // The idea is not to handle a complete KaxCluster with each call to | |
2783 // 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
|
2784 while ((l1 != NULL) && (upper_lvl_el <= 0)) { |
10024 | 2785 |
2786 if (EbmlId(*l1) == KaxCluster::ClassInfos.GlobalId) { | |
2787 mkv_d->cluster = (KaxCluster *)l1; | |
2788 if (found_data) { | |
2789 mkv_d->saved_l1 = l1; | |
2790 break; | |
2791 } | |
2792 | |
2793 if (mkv_d->saved_l2 != NULL) { | |
2794 l2 = mkv_d->saved_l2; | |
2795 mkv_d->saved_l2 = NULL; | |
2796 } else | |
2797 l2 = es->FindNextElement(l1->Generic().Context, upper_lvl_el, | |
2798 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
|
2799 while ((l2 != NULL) && (upper_lvl_el <= 0)) { |
10024 | 2800 |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
2801 // Handle at least one data packets in one call to |
10024 | 2802 // demux_mkv_fill_buffer - but abort if we have found that. |
2803 if (found_data >= 1) { | |
2804 mkv_d->saved_l2 = l2; | |
2805 mkv_d->saved_l1 = l1; | |
2806 exit_loop = 1; | |
2807 break; | |
2808 } | |
2809 | |
2810 if (EbmlId(*l2) == KaxClusterTimecode::ClassInfos.GlobalId) { | |
2811 KaxClusterTimecode &ctc = *static_cast<KaxClusterTimecode *>(l2); | |
2812 ctc.ReadData(es->I_O()); | |
2813 mkv_d->cluster_tc = uint64(ctc); | |
10273 | 2814 #if LIBEBML_VERSION >= 000404 |
2815 mkv_d->cluster->InitTimecode(mkv_d->cluster_tc, mkv_d->tc_scale); | |
2816 #else | |
10024 | 2817 mkv_d->cluster->InitTimecode(mkv_d->cluster_tc); |
10273 | 2818 #endif // LIBEBML_VERSION |
10024 | 2819 |
2820 } else if (EbmlId(*l2) == KaxBlockGroup::ClassInfos.GlobalId) { | |
2821 | |
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
|
2822 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
|
2823 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
|
2824 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
|
2825 |
10024 | 2826 block = NULL; |
2827 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
|
2828 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
|
2829 block_fref = 0; |
10024 | 2830 |
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
|
2831 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
|
2832 true); |
10024 | 2833 |
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
|
2834 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
|
2835 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
|
2836 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
|
2837 |
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 kblock = FINDFIRST(l2, KaxBlock); |
11260 | 2839 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
|
2840 kblock->SetParent(*mkv_d->cluster); |
11260 | 2841 if ((mkv_d->stop_timecode > 0) && |
2842 ((kblock->GlobalTimecode() / 1000000 - mkv_d->first_tc) >= | |
2843 mkv_d->stop_timecode)) { | |
2844 delete l2; | |
2845 return 0; | |
2846 } | |
2847 } | |
10024 | 2848 |
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
|
2849 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
|
2850 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
|
2851 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
|
2852 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
|
2853 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
|
2854 block_fref = int64(*krefblock); |
10024 | 2855 |
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
|
2856 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
|
2857 } |
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
|
2858 |
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
|
2859 if (kblock != NULL) { |
10024 | 2860 // 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
|
2861 lines_cut = false; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2862 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
|
2863 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
|
2864 (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
|
2865 sl = linei; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2866 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
|
2867 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
|
2868 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
|
2869 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
|
2870 sl++; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2871 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2872 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
|
2873 mkv_d->subs.lines--; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2874 linei--; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2875 lines_cut = true; |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2876 } |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2877 if (lines_cut) { |
71db96cf88d4
Support for SSA text subs in Matroska. Patch partially by Tristan <z80@oceanfree.net>.
mosu
parents:
10844
diff
changeset
|
2878 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
|
2879 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
|
2880 } |
10024 | 2881 } |
2882 | |
2883 ds = NULL; | |
2884 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
|
2885 (mkv_d->video->tnum == kblock->TrackNum())) { |
10024 | 2886 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
|
2887 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
|
2888 } 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
|
2889 (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
|
2890 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
|
2891 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
|
2892 } 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
|
2893 (mkv_d->subs_track->tnum == kblock->TrackNum())) { |
11154 | 2894 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
|
2895 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
|
2896 } |
10024 | 2897 |
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
|
2898 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
|
2899 |
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
|
2900 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
|
2901 mkv_d->first_tc) / 1000.0; |
10930 | 2902 if (current_pts < 0.0) |
2903 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
|
2904 |
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
|
2905 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
|
2906 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
|
2907 (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
|
2908 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
|
2909 |
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
|
2910 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
|
2911 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
|
2912 |
10844
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2913 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
|
2914 uint32_t i, sum; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2915 sh_audio_t *sh; |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2916 |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2917 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
|
2918 DataBuffer &data = kblock->GetBuffer(i); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2919 sum += data.Size(); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2920 } |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2921 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
|
2922 if (block_duration != -1) { |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2923 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
|
2924 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
|
2925 sh->i_bps); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2926 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
|
2927 } 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
|
2928 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
|
2929 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
|
2930 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
|
2931 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
|
2932 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
|
2933 sh->i_bps); |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2934 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
|
2935 } |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2936 } |
98681fdabf79
Support for Quicktime stuff in Matroska (e.g. Sorenson, QDesign Music codecs etc.).
mosu
parents:
10706
diff
changeset
|
2937 |
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
|
2938 } 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
|
2939 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
|
2940 |
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
|
2941 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
|
2942 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
|
2943 (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
|
2944 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
|
2945 |
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
|
2946 } 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
|
2947 (mkv_d->subs_track->tnum == kblock->TrackNum())) { |
11154 | 2948 if (mkv_d->subtitle_type != MKV_SUBTYPE_VOBSUB) { |
2949 if (!mkv_d->v_skip_to_keyframe) | |
2950 handle_subtitles(d, kblock, block_duration); | |
2951 use_this_block = false; | |
2952 } | |
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
|
2953 |
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
|
2954 } 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
|
2955 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
|
2956 |
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
|
2957 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
|
2958 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
|
2959 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
|
2960 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
|
2961 |
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
|
2962 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
|
2963 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
|
2964 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
|
2965 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
|
2966 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
|
2967 |
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
|
2968 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
|
2969 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
|
2970 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
|
2971 |
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
|
2972 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
|
2973 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
|
2974 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
|
2975 |
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
|
2976 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
|
2977 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
|
2978 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
|
2979 |
11154 | 2980 else if ((ds == d->sub) && |
2981 (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
|
2982 mpeg_run(d, re_buffer, re_size); |
11154 | 2983 |
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
|
2984 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
|
2985 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
|
2986 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
|
2987 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
|
2988 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
|
2989 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
|
2990 found_data++; |
10024 | 2991 } |
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
|
2992 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
|
2993 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
|
2994 } |
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
|
2995 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
|
2996 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
|
2997 mkv_d->skip_to_timecode = 0; |
11154 | 2998 } 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
|
2999 mkv_d->a_skip_to_keyframe = false; |
10024 | 3000 } |
3001 | |
3002 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
|
3003 } // kblock != NULL |
10024 | 3004 |
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
|
3005 } 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
|
3006 l2->SkipData(*es, l2->Generic().Context); |
10024 | 3007 |
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
|
3008 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
|
3009 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
|
3010 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
|
3011 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
3012 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
3013 if (upper_lvl_el > 0) { |
10024 | 3014 upper_lvl_el--; |
3015 if (upper_lvl_el > 0) | |
3016 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
|
3017 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
|
3018 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
|
3019 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
|
3020 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
3021 } 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
|
3022 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
|
3023 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
|
3024 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
|
3025 |
10024 | 3026 } |
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
|
3027 |
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
|
3028 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
|
3029 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
|
3030 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
|
3031 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
|
3032 |
10024 | 3033 } // 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
|
3034 |
10024 | 3035 } else if (EbmlId(*l1) == KaxCues::ClassInfos.GlobalId) |
3036 return 0; | |
3037 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
|
3038 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
|
3039 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
3040 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
|
3041 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
|
3042 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
|
3043 } |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
3044 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
3045 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
|
3046 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
|
3047 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
|
3048 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
|
3049 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
|
3050 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
|
3051 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
|
3052 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
3053 } 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
|
3054 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
|
3055 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
|
3056 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
|
3057 |
b6a31ca4f9a2
Big reorganization. Relies on libmatroska's Read() function and then processes units in memory. Also some fixes for handling of global elements which re-enable playback of files created with the latest VDubMod.
mosu
parents:
10438
diff
changeset
|
3058 } |
10024 | 3059 |
3060 if (exit_loop) | |
3061 break; | |
3062 | |
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
|
3063 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
|
3064 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
|
3065 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
|
3066 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
|
3067 |
10024 | 3068 } // while (l1 != NULL) |
3069 } catch (exception ex) { | |
3070 mp_msg(MSGT_DEMUX, MSGL_ERR, "[mkv] exception caught\n"); | |
3071 return 0; | |
3072 } | |
3073 | |
3074 if (found_data) | |
3075 return 1; | |
3076 | |
3077 return 0; | |
3078 } | |
3079 | |
3080 extern "C" void resync_audio_stream(sh_audio_t *sh_audio); | |
3081 | |
3082 extern "C" void demux_mkv_seek(demuxer_t *demuxer, float rel_seek_secs, | |
3083 int flags) { | |
3084 int i, k, upper_lvl_el; | |
3085 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *)demuxer->priv; | |
3086 int64_t target_timecode, target_filepos = 0, min_diff, diff, current_pos; | |
3087 int64_t cluster_pos; | |
3088 mkv_track_index_t *index; | |
3089 mkv_index_entry_t *entry; | |
3090 EbmlElement *l1; | |
3091 | |
3092 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] SEEK, relss: %.3f, flags: %d\n", | |
3093 rel_seek_secs, flags); | |
3094 | |
3095 if (!mkv_d->cues_found && !mkv_d->cues_searched) { | |
3096 // We've not found an index so far. So let's skip over all level 1 | |
3097 // elements until we either hit another segment, the end of the file | |
3098 // or - suprise - some cues. | |
3099 current_pos = mkv_d->in->getFilePointer(); | |
3100 | |
3101 // Skip the data but do not delete the element! This is our current | |
3102 // cluster, and we need it later on in demux_mkv_fill_buffer. | |
3103 l1 = mkv_d->saved_l1; | |
3104 l1->SkipData(static_cast<EbmlStream &>(*mkv_d->es), l1->Generic().Context); | |
3105 l1 = mkv_d->es->FindNextElement(mkv_d->segment->Generic().Context, | |
3106 upper_lvl_el, 0xFFFFFFFFL, true, 1); | |
3107 while (l1 != NULL) { | |
3108 if (upper_lvl_el) | |
3109 break; | |
3110 | |
3111 if (EbmlId(*l1) == KaxCues::ClassInfos.GlobalId) { | |
10685
f54ffeb29447
Support for linked seek heads, multiple seek heads, multiple cues.
mosu
parents:
10684
diff
changeset
|
3112 parse_cues(mkv_d, l1->GetElementPosition()); |
10024 | 3113 delete l1; |
3114 break; | |
3115 } else { | |
3116 if (EbmlId(*l1) == KaxCluster::ClassInfos.GlobalId) | |
3117 add_cluster_position(mkv_d, l1->GetElementPosition()); | |
3118 l1->SkipData(static_cast<EbmlStream &>(*mkv_d->es), | |
3119 l1->Generic().Context); | |
3120 delete l1; | |
3121 l1 = mkv_d->es->FindNextElement(mkv_d->segment->Generic().Context, | |
3122 upper_lvl_el, 0xFFFFFFFFL, true, 1); | |
3123 } | |
3124 } | |
3125 | |
3126 if (demuxer->stream->eof) | |
3127 stream_reset(demuxer->stream); | |
3128 mkv_d->in->setFilePointer(current_pos); | |
3129 | |
3130 mkv_d->cues_searched = 1; | |
3131 } | |
3132 | |
3133 if (!(flags & 2)) { // Time in secs | |
3134 if (flags & 1) // Absolute seek | |
3135 target_timecode = 0; | |
3136 else // Relative seek | |
3137 target_timecode = (int64_t)(mkv_d->last_pts * 1000.0); | |
3138 target_timecode += (int64_t)(rel_seek_secs * 1000.0); | |
3139 if (target_timecode < 0) | |
3140 target_timecode = 0; | |
3141 | |
3142 min_diff = 0xFFFFFFFL; | |
3143 | |
3144 // Let's find the entry in the index with the smallest difference | |
3145 // to the wanted timecode. | |
3146 entry = NULL; | |
3147 for (i = 0; i < mkv_d->num_indexes; i++) | |
3148 if (mkv_d->index[i].tnum == mkv_d->video->tnum) { | |
3149 index = &mkv_d->index[i]; | |
3150 for (k = 0; k < index->num_entries; k++) { | |
3151 if (!index->entries[k].is_key) | |
3152 continue; | |
3153 diff = target_timecode - (int64_t)index->entries[k].timecode; | |
11260 | 3154 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
|
3155 (diff >= 0) && (diff < min_diff)) { |
10024 | 3156 min_diff = diff; |
10874
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3157 entry = &index->entries[k]; |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3158 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
|
3159 "%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
|
3160 "%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
|
3161 (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
|
3162 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
|
3163 target_timecode) : 0, k); |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3164 |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3165 } 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
|
3166 (diff < 0) && (-diff < min_diff)) { |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3167 min_diff = -diff; |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3168 entry = &index->entries[k]; |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3169 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
|
3170 "%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
|
3171 "%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
|
3172 (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
|
3173 k < index->num_entries ? |
f75ec55301c4
Different decision making for seeking which takes the direction into account.
mosu
parents:
10861
diff
changeset
|
3174 (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
|
3175 0, k); |
10024 | 3176 } |
3177 } | |
3178 break; | |
3179 } | |
3180 | |
3181 if (mkv_d->saved_l1 != NULL) | |
3182 delete mkv_d->saved_l1; | |
3183 | |
3184 if (mkv_d->saved_l2 != NULL) { | |
3185 delete mkv_d->saved_l2; | |
3186 mkv_d->saved_l2 = NULL; | |
3187 } | |
3188 | |
3189 if (entry != NULL) { // We've found an entry. | |
3190 mkv_d->in->setFilePointer(entry->filepos); | |
3191 upper_lvl_el = 0; | |
3192 mkv_d->saved_l1 = | |
3193 mkv_d->es->FindNextElement(mkv_d->segment->Generic().Context, | |
3194 upper_lvl_el, 0xFFFFFFFFL, true, 1); | |
3195 } else { // We've not found an entry --> no index? | |
3196 target_filepos = (int64_t)(target_timecode * mkv_d->last_filepos / | |
3197 (mkv_d->last_pts * 1000.0)); | |
3198 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
|
3199 "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
|
3200 (int64_t)(mkv_d->last_pts * 1000.0)); |
10024 | 3201 // Let's find the nearest cluster so that libebml does not have to |
3202 // do so much work. | |
3203 cluster_pos = 0; | |
3204 min_diff = 0x0FFFFFFFL; | |
3205 for (i = 0; i < mkv_d->num_cluster_pos; i++) { | |
3206 diff = mkv_d->cluster_positions[i] - target_filepos; | |
3207 if (rel_seek_secs < 0) { | |
3208 if ((diff > 0) && (diff < min_diff)) { | |
3209 cluster_pos = mkv_d->cluster_positions[i]; | |
3210 min_diff = diff; | |
3211 } | |
10099
71d703e35ff3
Removed the abs function as someone reported compilation problems under MacOS.
mosu
parents:
10098
diff
changeset
|
3212 } else if ((diff < 0 ? -1 * diff : diff) < min_diff) { |
10024 | 3213 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
|
3214 min_diff = diff < 0 ? -1 * diff : diff; |
10024 | 3215 } |
3216 } | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3217 if (min_diff != 0x0FFFFFFFL) { |
10024 | 3218 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
|
3219 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
|
3220 "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
|
3221 } |
10024 | 3222 if (target_filepos >= demuxer->movi_end) |
3223 return; | |
3224 mkv_d->in->setFilePointer(target_filepos); | |
3225 upper_lvl_el = 0; | |
3226 mkv_d->saved_l1 = | |
3227 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
|
3228 upper_lvl_el, 0xFFFFFFFFL, true, 1); |
10024 | 3229 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek result: target_timecode %lld, " |
3230 "did not find an entry. Calculated target_filspos: %lld\n", | |
3231 target_timecode, target_filepos); | |
3232 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek found %p (%s).\n", | |
3233 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
|
3234 mkv_d->saved_l1->Generic().DebugName); |
10024 | 3235 } |
3236 | |
10060
f4d6cf8c6c93
Fixed seeking in audio-only files. Added support for subtitle track selection via "-slang".
mosu
parents:
10036
diff
changeset
|
3237 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
|
3238 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
|
3239 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
|
3240 mkv_d->skip_to_timecode = target_timecode; |
10024 | 3241 |
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
|
3242 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
|
3243 |
10024 | 3244 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
|
3245 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
|
3246 (int64_t)(mkv_d->last_pts * 1000.0)); |
10024 | 3247 |
3248 mkv_d->subs.lines = 0; | |
3249 vo_sub = &mkv_d->subs; | |
3250 vo_osd_changed(OSDTYPE_SUBTITLE); | |
3251 | |
3252 if(demuxer->audio->sh != NULL) | |
3253 resync_audio_stream((sh_audio_t *)demuxer->audio->sh); | |
3254 | |
3255 } else | |
3256 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] seek unsupported flags\n"); | |
3257 | |
3258 } | |
3259 | |
3260 extern "C" void demux_close_mkv(demuxer_t *demuxer) { | |
3261 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *)demuxer->priv; | |
3262 | |
3263 free_mkv_demuxer(mkv_d); | |
3264 | |
3265 #ifdef USE_ICONV | |
3266 subcp_close(); | |
3267 #endif | |
3268 } | |
3269 | |
3270 extern "C" int demux_mkv_control(demuxer_t *demuxer, int cmd, void *arg) { | |
3271 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *)demuxer->priv; | |
3272 | |
3273 switch (cmd) { | |
3274 case DEMUXER_CTRL_GET_TIME_LENGTH: | |
3275 if (mkv_d->duration == -1.0) | |
3276 return DEMUXER_CTRL_DONTKNOW; | |
3277 | |
3278 *((unsigned long *)arg) = (unsigned long)mkv_d->duration; | |
3279 return DEMUXER_CTRL_OK; | |
3280 | |
3281 case DEMUXER_CTRL_GET_PERCENT_POS: | |
3282 if (mkv_d->duration == -1.0) { | |
3283 if (demuxer->movi_start == demuxer->movi_end) | |
3284 return DEMUXER_CTRL_DONTKNOW; | |
3285 | |
3286 *((int *)arg) = | |
3287 (int)((demuxer->filepos - demuxer->movi_start) / | |
3288 ((demuxer->movi_end - demuxer->movi_start) / 100)); | |
3289 return DEMUXER_CTRL_OK; | |
3290 } | |
3291 | |
3292 *((int *)arg) = (int)(100 * mkv_d->last_pts / mkv_d->duration); | |
3293 return DEMUXER_CTRL_OK; | |
3294 | |
3295 default: | |
3296 return DEMUXER_CTRL_NOTIMPL; | |
3297 } | |
3298 } | |
3299 | |
3300 #endif /* HAVE_MATROSKA */ |