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