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