annotate libmpdemux/demux_mkv.cpp @ 10845:71db96cf88d4

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