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