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