annotate libmpdemux/demux_mkv.c @ 23006:512a16ec4bcb

Mono audio should be supported by NAS, too. Patch by Erik Auerswald {auerswal -at- unix-ag <dot> uni-kl de}
author reimar
date Thu, 19 Apr 2007 16:28:59 +0000
parents 09dc129234a0
children 20be83485595
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2 * native Matroska demuxer
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3 * Written by Aurelien Jacobs <aurel@gnuage.org>
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
4 * Based on the one written by Ronald Bultje for gstreamer
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
5 * and on demux_mkv.cpp from Moritz Bunkus.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
6 * Licence: GPL
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
7 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
8
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
9 #include "config.h"
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
10
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
11 #include <stdlib.h>
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
12 #include <stdio.h>
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
13 #include <ctype.h>
18558
4928dd61f136 Fix potential integer overflows in memory allocation.
rtogni
parents: 18507
diff changeset
14 #include <inttypes.h>
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
15
22605
4d81dbdf46b9 Add explicit location for headers from the stream/ directory.
diego
parents: 22445
diff changeset
16 #include "stream/stream.h"
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
17 #include "demuxer.h"
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
18 #include "stheader.h"
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
19 #include "ebml.h"
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
20 #include "matroska.h"
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
21
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
22 #include "mp_msg.h"
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
23 #include "help_mp.h"
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
24
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16912
diff changeset
25 #include "subreader.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16912
diff changeset
26 #include "libvo/sub.h"
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
27
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
28 #include "libass/ass.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
29 #include "libass/ass_mp.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
30
22616
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
31 #include "libavutil/common.h"
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
32
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
33 #ifdef USE_QTX_CODECS
22606
97343cedd966 Use explicit path for headers from the loader/ directory.
diego
parents: 22605
diff changeset
34 #include "loader/qtx/qtxsdk/components.h"
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
35 #endif
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
36
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
37 #ifdef HAVE_ZLIB
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
38 #include <zlib.h>
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
39 #endif
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
40
22081
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
41 #ifdef USE_LIBAVUTIL_SO
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
42 #include <ffmpeg/lzo.h>
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
43 #else
22081
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
44 #include "libavutil/lzo.h"
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
45 #endif
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
46
18036
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
47 static unsigned char sipr_swaps[38][2]={
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
48 {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68},
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
49 {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46},
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
50 {25,94},{26,54},{28,75},{29,50},{32,70},{33,92},{35,74},{38,85},{40,56},
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
51 {42,87},{43,65},{45,59},{48,79},{49,93},{51,89},{55,95},{61,76},{67,83},
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
52 {77,80} };
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
53
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
54 // Map flavour to bytes per second
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
55 #define SIPR_FLAVORS 4
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
56 #define ATRC_FLAVORS 8
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
57 #define COOK_FLAVORS 34
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
58 static int sipr_fl2bps[SIPR_FLAVORS] = {813, 1062, 625, 2000};
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
59 static int atrc_fl2bps[ATRC_FLAVORS] = {8269, 11714, 13092, 16538, 18260, 22050, 33075, 44100};
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
60 static int cook_fl2bps[COOK_FLAVORS] = {1000, 1378, 2024, 2584, 4005, 5513, 8010, 4005, 750, 2498,
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
61 4048, 5513, 8010, 11973, 8010, 2584, 4005, 2067, 2584, 2584,
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
62 4005, 4005, 5513, 5513, 8010, 12059, 1550, 8010, 12059, 5513,
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
63 12016, 16408, 22911, 33506};
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
64
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
65 typedef struct
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
66 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
67 uint32_t order, type, scope;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
68 uint32_t comp_algo;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
69 uint8_t *comp_settings;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
70 int comp_settings_len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
71 } mkv_content_encoding_t;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
72
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
73 typedef struct mkv_track
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
74 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
75 int tnum;
19640
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
76 char *name;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
77
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
78 char *codec_id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
79 int ms_compat;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
80 char *language;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
81
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
82 int type;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
83
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
84 uint32_t v_width, v_height, v_dwidth, v_dheight;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
85 float v_frate;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
86
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
87 uint32_t a_formattag;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
88 uint32_t a_channels, a_bps;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
89 float a_sfreq;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
90
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
91 float default_duration;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
92
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
93 int default_track;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
94
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
95 void *private_data;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
96 unsigned int private_size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
97
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
98 /* stuff for realmedia */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
99 int realmedia;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
100 int rv_kf_base, rv_kf_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
101 float rv_pts; /* previous video timestamp */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
102 float ra_pts; /* previous audio timestamp */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
103
18036
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
104 /** realaudio descrambling */
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
105 int sub_packet_size; ///< sub packet size, per stream
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
106 int sub_packet_h; ///< number of coded frames per block
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
107 int coded_framesize; ///< coded frame size, per stream
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
108 int audiopk_size; ///< audio packet size
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
109 unsigned char *audio_buf; ///< place to store reordered audio data
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
110 float *audio_timestamp; ///< timestamp for each audio packet
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
111 int sub_packet_cnt; ///< number of subpacket already received
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
112 int audio_filepos; ///< file position of first audio packet in block
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
113
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
114 /* stuff for quicktime */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
115 int fix_i_bps;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
116 float qt_last_a_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
117
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
118 int subtitle_type;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
119
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
120 /* The timecodes of video frames might have to be reordered if they're
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
121 in display order (the timecodes, not the frames themselves!). In this
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
122 case demux packets have to be cached with the help of these variables. */
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
123 int reorder_timecodes;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
124 demux_packet_t **cached_dps;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
125 int num_cached_dps, num_allocated_dps;
14515
35a6c4db00ae More support for AVC in Matroska.
mosu
parents: 14513
diff changeset
126 float max_pts;
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
127
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
128 /* generic content encoding support */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
129 mkv_content_encoding_t *encodings;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
130 int num_encodings;
12547
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
131
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
132 /* For VobSubs and SSA/ASS */
18934
a3788ff5d0b6 Rename mkv_sh_sub_t to sh_sub_t, move it to demuxer.h.
eugeni
parents: 18917
diff changeset
133 sh_sub_t sh_sub;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
134 } mkv_track_t;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
135
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
136 typedef struct mkv_index
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
137 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
138 int tnum;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
139 uint64_t timecode, filepos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
140 } mkv_index_t;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
141
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
142 typedef struct mkv_attachment
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
143 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
144 char* name;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
145 char* mime;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
146 uint64_t uid;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
147 void* data;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
148 unsigned int data_size;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
149 } mkv_attachment_t;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
150
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
151 typedef struct mkv_demuxer
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
152 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
153 off_t segment_start;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
154
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
155 float duration, last_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
156 uint64_t last_filepos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
157
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
158 mkv_track_t **tracks;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
159 int num_tracks;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
160
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
161 uint64_t tc_scale, cluster_tc, first_tc;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
162 int has_first_tc;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
163
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
164 uint64_t cluster_size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
165 uint64_t blockgroup_size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
166
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
167 mkv_index_t *indexes;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
168 int num_indexes;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
169
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
170 off_t *parsed_cues;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
171 int parsed_cues_num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
172 off_t *parsed_seekhead;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
173 int parsed_seekhead_num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
174
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
175 uint64_t *cluster_positions;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
176 int num_cluster_pos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
177
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
178 int64_t skip_to_timecode;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
179 int v_skip_to_keyframe, a_skip_to_keyframe;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
180
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
181 int64_t stop_timecode;
18754
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
182
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
183 int last_aid;
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
184 int audio_tracks[MAX_A_STREAMS];
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
185
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
186 mkv_attachment_t *attachments;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
187 int num_attachments;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
188 } mkv_demuxer_t;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
189
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
190
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
191 typedef struct
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
192 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
193 uint32_t chunks; /* number of chunks */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
194 uint32_t timestamp; /* timestamp from packet header */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
195 uint32_t len; /* length of actual data */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
196 uint32_t chunktab; /* offset to chunk offset array */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
197 } dp_hdr_t;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
198
11815
0fa6f4fcfcbb Compiler/system compatibility fixes.
mosu
parents: 11812
diff changeset
199 typedef struct __attribute__((__packed__))
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
200 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
201 uint32_t size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
202 uint32_t fourcc1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
203 uint32_t fourcc2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
204 uint16_t width;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
205 uint16_t height;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
206 uint16_t bpp;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
207 uint32_t unknown1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
208 uint32_t fps;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
209 uint32_t type1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
210 uint32_t type2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
211 } real_video_props_t;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
212
11815
0fa6f4fcfcbb Compiler/system compatibility fixes.
mosu
parents: 11812
diff changeset
213 typedef struct __attribute__((__packed__))
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
214 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
215 uint32_t fourcc1; /* '.', 'r', 'a', 0xfd */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
216 uint16_t version1; /* 4 or 5 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
217 uint16_t unknown1; /* 00 000 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
218 uint32_t fourcc2; /* .ra4 or .ra5 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
219 uint32_t unknown2; /* ??? */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
220 uint16_t version2; /* 4 or 5 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
221 uint32_t header_size; /* == 0x4e */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
222 uint16_t flavor; /* codec flavor id */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
223 uint32_t coded_frame_size; /* coded frame size */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
224 uint32_t unknown3; /* big number */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
225 uint32_t unknown4; /* bigger number */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
226 uint32_t unknown5; /* yet another number */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
227 uint16_t sub_packet_h;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
228 uint16_t frame_size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
229 uint16_t sub_packet_size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
230 uint16_t unknown6; /* 00 00 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
231 uint16_t sample_rate;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
232 uint16_t unknown8; /* 0 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
233 uint16_t sample_size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
234 uint16_t channels;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
235 } real_audio_v4_props_t;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
236
11815
0fa6f4fcfcbb Compiler/system compatibility fixes.
mosu
parents: 11812
diff changeset
237 typedef struct __attribute__((__packed__))
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
238 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
239 uint32_t fourcc1; /* '.', 'r', 'a', 0xfd */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
240 uint16_t version1; /* 4 or 5 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
241 uint16_t unknown1; /* 00 000 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
242 uint32_t fourcc2; /* .ra4 or .ra5 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
243 uint32_t unknown2; /* ??? */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
244 uint16_t version2; /* 4 or 5 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
245 uint32_t header_size; /* == 0x4e */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
246 uint16_t flavor; /* codec flavor id */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
247 uint32_t coded_frame_size; /* coded frame size */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
248 uint32_t unknown3; /* big number */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
249 uint32_t unknown4; /* bigger number */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
250 uint32_t unknown5; /* yet another number */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
251 uint16_t sub_packet_h;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
252 uint16_t frame_size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
253 uint16_t sub_packet_size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
254 uint16_t unknown6; /* 00 00 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
255 uint8_t unknown7[6]; /* 0, srate, 0 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
256 uint16_t sample_rate;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
257 uint16_t unknown8; /* 0 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
258 uint16_t sample_size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
259 uint16_t channels;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
260 uint32_t genr; /* "genr" */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
261 uint32_t fourcc3; /* fourcc */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
262 } real_audio_v5_props_t;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
263
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
264
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
265 /* for e.g. "-slang ger" */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
266 extern char *dvdsub_lang;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
267 extern char *audio_lang;
13501
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
268 extern int dvdsub_id;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
269
20140
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
270 /**
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
271 * \brief ensures there is space for at least one additional element
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
272 * \param array array to grow
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
273 * \param nelem current number of elements in array
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
274 * \param elsize size of one array element
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
275 */
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
276 static void grow_array(void **array, int nelem, size_t elsize) {
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
277 if (!(nelem & 31))
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
278 *array = realloc(*array, (nelem + 32) * elsize);
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
279 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
280
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
281 static mkv_track_t *
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
282 demux_mkv_find_track_by_num (mkv_demuxer_t *d, int n, int type)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
283 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
284 int i, id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
285
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
286 for (i=0, id=0; i < d->num_tracks; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
287 if (d->tracks[i] != NULL && d->tracks[i]->type == type)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
288 if (id++ == n)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
289 return d->tracks[i];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
290
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
291 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
292 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
293
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
294 static mkv_track_t *
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
295 demux_mkv_find_track_by_language (mkv_demuxer_t *d, char *language, int type)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
296 {
12041
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
297 int i, len;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
298
12041
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
299 language += strspn(language,",");
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
300 while((len = strcspn(language,",")) > 0)
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
301 {
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
302 for (i=0; i < d->num_tracks; i++)
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
303 if (d->tracks[i] != NULL && d->tracks[i]->language != NULL &&
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
304 d->tracks[i]->type == type &&
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
305 !strncmp(d->tracks[i]->language, language, len))
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
306 return d->tracks[i];
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
307 language += len;
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
308 language += strspn(language,",");
c5aa951feff8 Parse comma separated language lists instead of comparing the complete language string. Patch by Loren Merritt <lorenm at u dot washington dot edu>
mosu
parents: 11934
diff changeset
309 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
310
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
311 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
312 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
313
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
314 static void
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
315 add_cluster_position (mkv_demuxer_t *mkv_d, uint64_t position)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
316 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
317 int i = mkv_d->num_cluster_pos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
318
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
319 while (i--)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
320 if (mkv_d->cluster_positions[i] == position)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
321 return;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
322
20140
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
323 grow_array(&mkv_d->cluster_positions, mkv_d->num_cluster_pos,
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
324 sizeof(uint64_t));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
325 mkv_d->cluster_positions[mkv_d->num_cluster_pos++] = position;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
326 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
327
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
328
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
329 #define AAC_SYNC_EXTENSION_TYPE 0x02b7
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
330 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
331 aac_get_sample_rate_index (uint32_t sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
332 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
333 if (92017 <= sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
334 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
335 else if (75132 <= sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
336 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
337 else if (55426 <= sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
338 return 2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
339 else if (46009 <= sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
340 return 3;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
341 else if (37566 <= sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
342 return 4;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
343 else if (27713 <= sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
344 return 5;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
345 else if (23004 <= sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
346 return 6;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
347 else if (18783 <= sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
348 return 7;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
349 else if (13856 <= sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
350 return 8;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
351 else if (11502 <= sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
352 return 9;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
353 else if (9391 <= sample_rate)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
354 return 10;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
355 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
356 return 11;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
357 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
358
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
359
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
360 static int
12550
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
361 vobsub_parse_size (mkv_track_t *t, const char *start)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
362 {
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
363 if (sscanf(&start[6], "%dx%d", &t->sh_sub.width, &t->sh_sub.height) == 2)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
364 {
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
365 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub size: %ux%u\n",
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
366 t->sh_sub.width, t->sh_sub.height);
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
367 return 1;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
368 }
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
369 return 0;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
370 }
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
371
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
372 static int
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
373 vobsub_parse_palette (mkv_track_t *t, const char *start)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
374 {
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
375 int i, r, g, b, y, u, v, tmp;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
376
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
377 start += 8;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
378 while (isspace(*start))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
379 start++;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
380 for (i = 0; i < 16; i++)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
381 {
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
382 if (sscanf(start, "%06x", &tmp) != 1)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
383 break;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
384 r = tmp >> 16 & 0xff;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
385 g = tmp >> 8 & 0xff;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
386 b = tmp & 0xff;
22377
fd54975f9135 Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
reimar
parents: 22157
diff changeset
387 y = av_clip_uint8( 0.1494 * r + 0.6061 * g + 0.2445 * b);
fd54975f9135 Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
reimar
parents: 22157
diff changeset
388 u = av_clip_uint8( 0.6066 * r - 0.4322 * g - 0.1744 * b + 128);
fd54975f9135 Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
reimar
parents: 22157
diff changeset
389 v = av_clip_uint8(-0.08435 * r - 0.3422 * g + 0.4266 * b + 128);
12550
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
390 t->sh_sub.palette[i] = y << 16 | u << 8 | v;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
391 start += 6;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
392 while ((*start == ',') || isspace(*start))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
393 start++;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
394 }
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
395 if (i == 16)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
396 {
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
397 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub palette: %06x,%06x,"
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
398 "%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,%06x,"
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
399 "%06x,%06x,%06x\n", t->sh_sub.palette[0],
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
400 t->sh_sub.palette[1], t->sh_sub.palette[2],
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
401 t->sh_sub.palette[3], t->sh_sub.palette[4],
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
402 t->sh_sub.palette[5], t->sh_sub.palette[6],
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
403 t->sh_sub.palette[7], t->sh_sub.palette[8],
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
404 t->sh_sub.palette[9], t->sh_sub.palette[10],
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
405 t->sh_sub.palette[11], t->sh_sub.palette[12],
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
406 t->sh_sub.palette[13], t->sh_sub.palette[14],
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
407 t->sh_sub.palette[15]);
14561
a226d301eec1 Handle missing palettes in the info part of VobSubs in Matroska files correctly by giving mplayer a NULL pointer. This way it will use a default palette instead of black only. Patch by Csillag Kristof (fenwick () freemail ! hu)
mosu
parents: 14515
diff changeset
408 t->sh_sub.has_palette = 1;
12550
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
409 return 2;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
410 }
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
411 return 0;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
412 }
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
413
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
414 static int
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
415 vobsub_parse_custom_colors (mkv_track_t *t, const char *start)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
416 {
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
417 int use_custom_colors, i;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
418
13131
ab937f4a17ad Cosmetics: fix some compiler warnings.
mosu
parents: 13129
diff changeset
419 use_custom_colors = 0;
12550
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
420 start += 14;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
421 while (isspace(*start))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
422 start++;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
423 if (!strncasecmp(start, "ON", 2) || (*start == '1'))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
424 use_custom_colors = 1;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
425 else if (!strncasecmp(start, "OFF", 3) || (*start == '0'))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
426 use_custom_colors = 0;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
427 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub custom colors: %s\n",
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
428 use_custom_colors ? "ON" : "OFF");
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
429 if ((start = strstr(start, "colors:")) != NULL)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
430 {
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
431 start += 7;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
432 while (isspace(*start))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
433 start++;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
434 for (i = 0; i < 4; i++)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
435 {
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
436 if (sscanf(start, "%06x", &t->sh_sub.colors[i]) != 1)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
437 break;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
438 start += 6;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
439 while ((*start == ',') || isspace(*start))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
440 start++;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
441 }
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
442 if (i == 4)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
443 {
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
444 t->sh_sub.custom_colors = 4;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
445 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub colors: %06x,"
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
446 "%06x,%06x,%06x\n", t->sh_sub.colors[0],
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
447 t->sh_sub.colors[1], t->sh_sub.colors[2],
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
448 t->sh_sub.colors[3]);
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
449 }
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
450 }
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
451 if (!use_custom_colors)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
452 t->sh_sub.custom_colors = 0;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
453 return 4;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
454 }
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
455
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
456 static int
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
457 vobsub_parse_forced_subs (mkv_track_t *t, const char *start)
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
458 {
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
459 start += 12;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
460 while (isspace(*start))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
461 start++;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
462 if (!strncasecmp(start, "on", 2) || (*start == '1'))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
463 t->sh_sub.forced_subs_only = 1;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
464 else if (!strncasecmp(start, "off", 3) || (*start == '0'))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
465 t->sh_sub.forced_subs_only = 0;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
466 else
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
467 return 0;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
468 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] VobSub forced subs: %d\n",
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
469 t->sh_sub.forced_subs_only);
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
470 return 8;
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
471 }
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
472
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
473 /** \brief Free cached demux packets
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
474 *
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
475 * Reordering the timecodes requires caching of demux packets. This function
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
476 * frees all these cached packets and the memory for the cached pointers
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
477 * itself.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
478 *
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
479 * \param demuxer The demuxer for which the cache is to be freed.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
480 */
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
481 static void
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
482 free_cached_dps (demuxer_t *demuxer)
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
483 {
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
484 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
485 mkv_track_t *track;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
486 int i, k;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
487
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
488 for (k = 0; k < mkv_d->num_tracks; k++)
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
489 {
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
490 track = mkv_d->tracks[k];
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
491 for (i = 0; i < track->num_cached_dps; i++)
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
492 free_demux_packet (track->cached_dps[i]);
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
493 free(track->cached_dps);
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
494 track->cached_dps = NULL;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
495 track->num_cached_dps = 0;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
496 track->num_allocated_dps = 0;
15517
9560b286481c Reset the saved max_pts used for timecode reordering after seeking. Otherwise playback is broken after seeking back in a file that needs the timecodes to be reordered. Patch by Sam Dennis <sam () malfunction ! screaming !net>
mosu
parents: 15450
diff changeset
497 track->max_pts = 0;
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
498 }
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
499 }
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
500
12550
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
501 static int
12547
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
502 demux_mkv_parse_idx (mkv_track_t *t)
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
503 {
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
504 int things_found, last;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
505 char *buf, *pos, *start;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
506
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
507 if ((t->private_data == NULL) || (t->private_size == 0))
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
508 return 0;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
509
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
510 things_found = 0;
18885
5c8acc972551 rm unnecesary casts from void* - part 4
reynaldo
parents: 18754
diff changeset
511 buf = malloc(t->private_size + 1);
12547
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
512 if (buf == NULL)
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
513 return 0;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
514 memcpy(buf, t->private_data, t->private_size);
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
515 buf[t->private_size] = 0;
14561
a226d301eec1 Handle missing palettes in the info part of VobSubs in Matroska files correctly by giving mplayer a NULL pointer. This way it will use a default palette instead of black only. Patch by Csillag Kristof (fenwick () freemail ! hu)
mosu
parents: 14515
diff changeset
516 t->sh_sub.has_palette = 0;
12547
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
517
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
518 pos = buf;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
519 start = buf;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
520 last = 0;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
521 do
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
522 {
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
523 if ((*pos == 0) || (*pos == '\r') || (*pos == '\n'))
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
524 {
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
525 if (*pos == 0)
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
526 last = 1;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
527 *pos = 0;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
528
12550
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
529 if (!strncasecmp(start, "size: ", 6))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
530 things_found |= vobsub_parse_size(t, start);
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
531 else if (!strncasecmp(start, "palette:", 8))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
532 things_found |= vobsub_parse_palette(t, start);
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
533 else if (!strncasecmp(start, "custom colors:", 14))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
534 things_found |= vobsub_parse_custom_colors(t, start);
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
535 else if (!strncasecmp(start, "forced subs:", 12))
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
536 things_found |= vobsub_parse_forced_subs(t, start);
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
537
12547
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
538 if (last)
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
539 break;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
540 do
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
541 {
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
542 pos++;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
543 }
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
544 while ((*pos == '\r') || (*pos == '\n'));
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
545 start = pos;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
546 }
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
547 else
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
548 pos++;
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
549 }
12550
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
550 while (!last && (*start != 0));
12547
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
551
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
552 free(buf);
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
553
12550
733c9d9882d1 Support for the "custom colors" and "forced subtitles" entries in the VobSub idx. Made the parser handle whitespaces better.
mosu
parents: 12547
diff changeset
554 return (things_found & 3) == 3;
12547
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
555 }
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
556
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
557
a60ba1b93e25 Try to get the "size:" and "palette:" entries for VobSub tracks from the private data.
mosu
parents: 12443
diff changeset
558 static int
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
559 demux_mkv_decode (mkv_track_t *track, uint8_t *src, uint8_t **dest,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
560 uint32_t *size, uint32_t type)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
561 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
562 int i, result;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
563 int modified = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
564
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
565 *dest = src;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
566 if (track->num_encodings <= 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
567 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
568
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
569 for (i=0; i<track->num_encodings; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
570 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
571 if (!(track->encodings[i].scope & type))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
572 continue;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
573
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
574 #ifdef HAVE_ZLIB
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
575 if (track->encodings[i].comp_algo == 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
576 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
577 /* zlib encoded track */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
578 z_stream zstream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
579
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
580 zstream.zalloc = (alloc_func) 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
581 zstream.zfree = (free_func) 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
582 zstream.opaque = (voidpf) 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
583 if (inflateInit (&zstream) != Z_OK)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
584 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
585 mp_msg (MSGT_DEMUX, MSGL_WARN,
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
586 MSGTR_MPDEMUX_MKV_ZlibInitializationFailed);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
587 return modified;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
588 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
589 zstream.next_in = (Bytef *) src;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
590 zstream.avail_in = *size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
591
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
592 modified = 1;
22008
ac44a63aab35 *dest = malloc (*size); is useless directly before *dest = realloc (*dest, *size);
reimar
parents: 21997
diff changeset
593 *dest = NULL;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
594 zstream.avail_out = *size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
595 do {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
596 *size += 4000;
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
597 *dest = realloc (*dest, *size);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
598 zstream.next_out = (Bytef *) (*dest + zstream.total_out);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
599 result = inflate (&zstream, Z_NO_FLUSH);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
600 if (result != Z_OK && result != Z_STREAM_END)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
601 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
602 mp_msg (MSGT_DEMUX, MSGL_WARN,
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
603 MSGTR_MPDEMUX_MKV_ZlibDecompressionFailed);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
604 free(*dest);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
605 *dest = NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
606 inflateEnd (&zstream);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
607 return modified;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
608 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
609 zstream.avail_out += 4000;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
610 } while (zstream.avail_out == 4000 &&
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
611 zstream.avail_in != 0 && result != Z_STREAM_END);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
612
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
613 *size = zstream.total_out;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
614 inflateEnd (&zstream);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
615 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
616 #endif
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
617 if (track->encodings[i].comp_algo == 2)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
618 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
619 /* lzo encoded track */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
620 int dstlen = *size * 3;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
621
22011
9562199ac075 Simplify and make lzo decompression code more similar to zlib one.
reimar
parents: 22010
diff changeset
622 *dest = NULL;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
623 while (1)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
624 {
22081
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
625 int srclen = *size;
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
626 if (dstlen > SIZE_MAX - LZO_OUTPUT_PADDING) goto lzo_fail;
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
627 *dest = realloc (*dest, dstlen + LZO_OUTPUT_PADDING);
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
628 result = lzo1x_decode (*dest, &dstlen, src, &srclen);
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
629 if (result == 0)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
630 break;
22081
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
631 if (!(result & LZO_OUTPUT_FULL))
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
632 {
22081
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
633 lzo_fail:
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
634 mp_msg (MSGT_DEMUX, MSGL_WARN,
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
635 MSGTR_MPDEMUX_MKV_LzoDecompressionFailed);
22010
04b7b7090eee Forgotten free on error
reimar
parents: 22008
diff changeset
636 free(*dest);
04b7b7090eee Forgotten free on error
reimar
parents: 22008
diff changeset
637 *dest = NULL;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
638 return modified;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
639 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
640 mp_msg (MSGT_DEMUX, MSGL_DBG2,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
641 "[mkv] lzo decompression buffer too small.\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
642 dstlen *= 2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
643 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
644 *size = dstlen;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
645 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
646 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
647
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
648 return modified;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
649 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
650
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
651
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
652 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
653 demux_mkv_read_info (demuxer_t *demuxer)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
654 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
655 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
656 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
657 uint64_t length, l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
658 int il;
19809
99d375aab4db Fix movie duration calculation in case when TimecodeScale element comes after
eugeni
parents: 19645
diff changeset
659 uint64_t tc_scale = 1000000;
19812
30349b8fe806 Fix r19815: mkv_d->duration could be assigned an uninitialized value.
eugeni
parents: 19811
diff changeset
660 long double duration = 0.;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
661
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
662 length = ebml_read_length (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
663 while (length > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
664 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
665 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
666 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
667 case MATROSKA_ID_TIMECODESCALE:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
668 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
669 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
670 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
671 return 1;
19809
99d375aab4db Fix movie duration calculation in case when TimecodeScale element comes after
eugeni
parents: 19645
diff changeset
672 tc_scale = num;
16750
0a31740dd5e6 Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents: 16346
diff changeset
673 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + timecode scale: %"PRIu64"\n",
19809
99d375aab4db Fix movie duration calculation in case when TimecodeScale element comes after
eugeni
parents: 19645
diff changeset
674 tc_scale);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
675 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
676 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
677
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
678 case MATROSKA_ID_DURATION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
679 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
680 long double num = ebml_read_float (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
681 if (num == EBML_FLOAT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
682 return 1;
19809
99d375aab4db Fix movie duration calculation in case when TimecodeScale element comes after
eugeni
parents: 19645
diff changeset
683 duration = num;
99d375aab4db Fix movie duration calculation in case when TimecodeScale element comes after
eugeni
parents: 19645
diff changeset
684 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + duration: %.3Lfs\n",
99d375aab4db Fix movie duration calculation in case when TimecodeScale element comes after
eugeni
parents: 19645
diff changeset
685 duration * tc_scale / 1000000000.0);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
686 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
687 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
688
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
689 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
690 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
691 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
692 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
693 length -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
694 }
19809
99d375aab4db Fix movie duration calculation in case when TimecodeScale element comes after
eugeni
parents: 19645
diff changeset
695 mkv_d->tc_scale = tc_scale;
99d375aab4db Fix movie duration calculation in case when TimecodeScale element comes after
eugeni
parents: 19645
diff changeset
696 mkv_d->duration = duration * tc_scale / 1000000000.0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
697 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
698 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
699
20133
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
700 /**
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
701 * \brief free array of kv_content_encoding_t
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
702 * \param encodings pointer to array
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
703 * \param numencodings number of encodings in array
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
704 */
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
705 static void
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
706 demux_mkv_free_encodings(mkv_content_encoding_t *encodings, int numencodings)
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
707 {
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
708 while (numencodings-- > 0)
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
709 free(encodings[numencodings].comp_settings);
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
710 free(encodings);
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
711 }
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
712
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
713 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
714 demux_mkv_read_trackencodings (demuxer_t *demuxer, mkv_track_t *track)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
715 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
716 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
717 mkv_content_encoding_t *ce, e;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
718 uint64_t len, length, l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
719 int il, n;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
720
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
721 ce = malloc (sizeof (*ce));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
722 n = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
723
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
724 len = length = ebml_read_length (s, &il);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
725 len += il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
726 while (length > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
727 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
728 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
729 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
730 case MATROSKA_ID_CONTENTENCODING:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
731 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
732 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
733 int i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
734
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
735 memset (&e, 0, sizeof (e));
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
736 e.scope = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
737
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
738 len = ebml_read_length (s, &i);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
739 l = len + i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
740
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
741 while (len > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
742 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
743 uint64_t num, l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
744 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
745
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
746 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
747 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
748 case MATROSKA_ID_CONTENTENCODINGORDER:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
749 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
750 if (num == EBML_UINT_INVALID)
20133
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
751 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
752 e.order = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
753 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
754
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
755 case MATROSKA_ID_CONTENTENCODINGSCOPE:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
756 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
757 if (num == EBML_UINT_INVALID)
20133
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
758 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
759 e.scope = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
760 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
761
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
762 case MATROSKA_ID_CONTENTENCODINGTYPE:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
763 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
764 if (num == EBML_UINT_INVALID)
20133
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
765 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
766 e.type = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
767 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
768
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
769 case MATROSKA_ID_CONTENTCOMPRESSION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
770 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
771 uint64_t le;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
772
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
773 le = ebml_read_length (s, &i);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
774 l = le + i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
775
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
776 while (le > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
777 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
778 uint64_t l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
779 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
780
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
781 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
782 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
783 case MATROSKA_ID_CONTENTCOMPALGO:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
784 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
785 if (num == EBML_UINT_INVALID)
20133
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
786 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
787 e.comp_algo = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
788 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
789
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
790 case MATROSKA_ID_CONTENTCOMPSETTINGS:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
791 l = ebml_read_length (s, &i);
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
792 e.comp_settings = malloc (l);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
793 stream_read (s, e.comp_settings, l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
794 e.comp_settings_len = l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
795 l += i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
796 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
797
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
798 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
799 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
800 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
801 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
802 le -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
803 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
804
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
805 if (e.type == 1)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
806 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
807 mp_msg(MSGT_DEMUX, MSGL_WARN,
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
808 MSGTR_MPDEMUX_MKV_TrackEncrypted, track->tnum);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
809 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
810 else if (e.type != 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
811 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
812 mp_msg(MSGT_DEMUX, MSGL_WARN,
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
813 MSGTR_MPDEMUX_MKV_UnknownContentEncoding, track->tnum);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
814 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
815
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
816 if (e.comp_algo != 0 && e.comp_algo != 2)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
817 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
818 mp_msg (MSGT_DEMUX, MSGL_WARN,
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
819 MSGTR_MPDEMUX_MKV_UnknownCompression,
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
820 track->tnum, e.comp_algo);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
821 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
822 #ifndef HAVE_ZLIB
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
823 else if (e.comp_algo == 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
824 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
825 mp_msg (MSGT_DEMUX, MSGL_WARN,
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
826 MSGTR_MPDEMUX_MKV_ZlibCompressionUnsupported,
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
827 track->tnum);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
828 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
829 #endif
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
830
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
831 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
832 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
833
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
834 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
835 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
836 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
837 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
838 len -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
839 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
840 for (i=0; i<n; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
841 if (e.order <= ce[i].order)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
842 break;
20129
053ed52b8951 Remove cast of realloc result missed in last patch
reimar
parents: 20128
diff changeset
843 ce = realloc (ce, (n+1) *sizeof (*ce));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
844 memmove (ce+i+1, ce+i, (n-i) * sizeof (*ce));
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
845 memcpy (ce+i, &e, sizeof (e));
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
846 n++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
847 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
848 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
849
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
850 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
851 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
852 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
853 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
854
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
855 length -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
856 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
857
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
858 track->encodings = ce;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
859 track->num_encodings = n;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
860 return len;
20133
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
861
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
862 err_out:
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
863 demux_mkv_free_encodings(ce, n);
6d6c0840113f Free track encodings on error or demuxer close
reimar
parents: 20130
diff changeset
864 return 0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
865 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
866
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
867 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
868 demux_mkv_read_trackaudio (demuxer_t *demuxer, mkv_track_t *track)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
869 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
870 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
871 uint64_t len, length, l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
872 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
873
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
874 track->a_sfreq = 8000.0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
875 track->a_channels = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
876
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
877 len = length = ebml_read_length (s, &il);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
878 len += il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
879 while (length > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
880 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
881 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
882 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
883 case MATROSKA_ID_AUDIOSAMPLINGFREQ:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
884 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
885 long double num = ebml_read_float (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
886 if (num == EBML_FLOAT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
887 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
888 track->a_sfreq = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
889 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Sampling frequency: %f\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
890 track->a_sfreq);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
891 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
892 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
893
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
894 case MATROSKA_ID_AUDIOBITDEPTH:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
895 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
896 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
897 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
898 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
899 track->a_bps = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
900 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Bit depth: %u\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
901 track->a_bps);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
902 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
903 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
904
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
905 case MATROSKA_ID_AUDIOCHANNELS:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
906 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
907 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
908 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
909 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
910 track->a_channels = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
911 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Channels: %u\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
912 track->a_channels);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
913 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
914 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
915
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
916 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
917 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
918 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
919 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
920 length -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
921 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
922 return len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
923 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
924
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
925 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
926 demux_mkv_read_trackvideo (demuxer_t *demuxer, mkv_track_t *track)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
927 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
928 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
929 uint64_t len, length, l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
930 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
931
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
932 len = length = ebml_read_length (s, &il);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
933 len += il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
934 while (length > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
935 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
936 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
937 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
938 case MATROSKA_ID_VIDEOFRAMERATE:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
939 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
940 long double num = ebml_read_float (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
941 if (num == EBML_FLOAT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
942 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
943 track->v_frate = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
944 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Frame rate: %f\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
945 track->v_frate);
14058
4dee22ed8608 Make use of the default duration for one frame if it is present in the file. This produces much smoother timecodes for laced audio frames. And I REALLY don't know why I missed that before...
mosu
parents: 14054
diff changeset
946 if (track->v_frate > 0)
4dee22ed8608 Make use of the default duration for one frame if it is present in the file. This produces much smoother timecodes for laced audio frames. And I REALLY don't know why I missed that before...
mosu
parents: 14054
diff changeset
947 track->default_duration = 1 / track->v_frate;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
948 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
949 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
950
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
951 case MATROSKA_ID_VIDEODISPLAYWIDTH:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
952 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
953 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
954 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
955 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
956 track->v_dwidth = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
957 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Display width: %u\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
958 track->v_dwidth);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
959 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
960 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
961
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
962 case MATROSKA_ID_VIDEODISPLAYHEIGHT:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
963 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
964 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
965 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
966 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
967 track->v_dheight = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
968 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Display height: %u\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
969 track->v_dheight);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
970 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
971 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
972
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
973 case MATROSKA_ID_VIDEOPIXELWIDTH:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
974 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
975 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
976 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
977 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
978 track->v_width = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
979 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel width: %u\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
980 track->v_width);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
981 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
982 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
983
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
984 case MATROSKA_ID_VIDEOPIXELHEIGHT:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
985 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
986 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
987 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
988 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
989 track->v_height = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
990 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel height: %u\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
991 track->v_height);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
992 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
993 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
994
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
995 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
996 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
997 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
998 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
999 length -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1000 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1001 return len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1002 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1003
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1004 /**
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1005 * \brief free any data associated with given track
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1006 * \param track track of which to free data
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1007 */
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1008 static void
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1009 demux_mkv_free_trackentry(mkv_track_t *track) {
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1010 if (track->name)
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1011 free (track->name);
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1012 if (track->codec_id)
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1013 free (track->codec_id);
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1014 if (track->language)
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1015 free (track->language);
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1016 if (track->private_data)
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1017 free (track->private_data);
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1018 if (track->audio_buf)
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1019 free (track->audio_buf);
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1020 if (track->audio_timestamp)
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1021 free (track->audio_timestamp);
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1022 #ifdef USE_ASS
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1023 if (track->sh_sub.ass_track)
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1024 ass_free_track (track->sh_sub.ass_track);
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1025 #endif
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1026 demux_mkv_free_encodings(track->encodings, track->num_encodings);
20136
61272e6d8f08 Missing (in close function)/misplaced free for track structure itself.
reimar
parents: 20135
diff changeset
1027 free(track);
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1028 }
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1029
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1030 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1031 demux_mkv_read_trackentry (demuxer_t *demuxer)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1032 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1033 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1034 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1035 mkv_track_t *track;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1036 uint64_t len, length, l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1037 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1038
20130
b5c68feff55c replace malloc+memset by calloc
reimar
parents: 20129
diff changeset
1039 track = calloc (1, sizeof (*track));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1040 /* set default values */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1041 track->default_track = 1;
19640
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1042 track->name = 0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1043 track->language = strdup("eng");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1044
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1045 len = length = ebml_read_length (s, &il);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1046 len += il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1047 while (length > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1048 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1049 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1050 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1051 case MATROSKA_ID_TRACKNUMBER:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1052 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1053 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1054 if (num == EBML_UINT_INVALID)
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1055 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1056 track->tnum = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1057 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Track number: %u\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1058 track->tnum);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1059 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1060 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1061
19640
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1062 case MATROSKA_ID_TRACKNAME:
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1063 {
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1064 track->name = ebml_read_utf8 (s, &l);
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1065 if (track->name == NULL)
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1066 goto err_out;
19640
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1067 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Name: %s\n",
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1068 track->name);
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1069 break;
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1070 }
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1071
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1072 case MATROSKA_ID_TRACKTYPE:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1073 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1074 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1075 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1076 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1077 track->type = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1078 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Track type: ");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1079 switch (track->type)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1080 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1081 case MATROSKA_TRACK_AUDIO:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1082 mp_msg (MSGT_DEMUX, MSGL_V, "Audio\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1083 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1084 case MATROSKA_TRACK_VIDEO:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1085 mp_msg (MSGT_DEMUX, MSGL_V, "Video\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1086 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1087 case MATROSKA_TRACK_SUBTITLE:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1088 mp_msg (MSGT_DEMUX, MSGL_V, "Subtitle\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1089 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1090 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1091 mp_msg (MSGT_DEMUX, MSGL_V, "unknown\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1092 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1093 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1094 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1095 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1096
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1097 case MATROSKA_ID_TRACKAUDIO:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1098 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Audio track\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1099 l = demux_mkv_read_trackaudio (demuxer, track);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1100 if (l == 0)
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1101 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1102 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1103
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1104 case MATROSKA_ID_TRACKVIDEO:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1105 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Video track\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1106 l = demux_mkv_read_trackvideo (demuxer, track);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1107 if (l == 0)
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1108 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1109 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1110
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1111 case MATROSKA_ID_CODECID:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1112 track->codec_id = ebml_read_ascii (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1113 if (track->codec_id == NULL)
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1114 goto err_out;
12101
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
1115 if (!strcmp (track->codec_id, MKV_V_MSCOMP) ||
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
1116 !strcmp (track->codec_id, MKV_A_ACM))
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1117 track->ms_compat = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1118 else if (!strcmp (track->codec_id, MKV_S_VOBSUB))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1119 track->subtitle_type = MATROSKA_SUBTYPE_VOBSUB;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1120 else if (!strcmp (track->codec_id, MKV_S_TEXTSSA)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1121 || !strcmp (track->codec_id, MKV_S_TEXTASS)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1122 || !strcmp (track->codec_id, MKV_S_SSA)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1123 || !strcmp (track->codec_id, MKV_S_ASS))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1124 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1125 track->subtitle_type = MATROSKA_SUBTYPE_SSA;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1126 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1127 else if (!strcmp (track->codec_id, MKV_S_TEXTASCII))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1128 track->subtitle_type = MATROSKA_SUBTYPE_TEXT;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1129 if (!strcmp (track->codec_id, MKV_S_TEXTUTF8))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1130 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1131 track->subtitle_type = MATROSKA_SUBTYPE_TEXT;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1132 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1133 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Codec ID: %s\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1134 track->codec_id);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1135 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1136
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1137 case MATROSKA_ID_CODECPRIVATE:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1138 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1139 int x;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1140 uint64_t num = ebml_read_length (s, &x);
18558
4928dd61f136 Fix potential integer overflows in memory allocation.
rtogni
parents: 18507
diff changeset
1141 // audit: cheap guard against overflows later..
4928dd61f136 Fix potential integer overflows in memory allocation.
rtogni
parents: 18507
diff changeset
1142 if (num > SIZE_MAX - 1000) return 0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1143 l = x + num;
22081
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
1144 track->private_data = malloc (num + LZO_INPUT_PADDING);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1145 if (stream_read(s, track->private_data, num) != (int) num)
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1146 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1147 track->private_size = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1148 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + CodecPrivate, length "
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1149 "%u\n", track->private_size);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1150 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1151 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1152
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1153 case MATROSKA_ID_TRACKLANGUAGE:
20137
d4e7b776da63 Free track->language before assigning new value
reimar
parents: 20136
diff changeset
1154 free(track->language);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1155 track->language = ebml_read_utf8 (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1156 if (track->language == NULL)
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1157 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1158 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Language: %s\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1159 track->language);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1160 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1161
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1162 case MATROSKA_ID_TRACKFLAGDEFAULT:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1163 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1164 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1165 if (num == EBML_UINT_INVALID)
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1166 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1167 track->default_track = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1168 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Default flag: %u\n",
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1169 track->default_track);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1170 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1171 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1172
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1173 case MATROSKA_ID_TRACKDEFAULTDURATION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1174 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1175 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1176 if (num == EBML_UINT_INVALID)
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1177 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1178 if (num == 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1179 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Default duration: 0");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1180 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1181 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1182 track->v_frate = 1000000000.0 / num;
14058
4dee22ed8608 Make use of the default duration for one frame if it is present in the file. This produces much smoother timecodes for laced audio frames. And I REALLY don't know why I missed that before...
mosu
parents: 14054
diff changeset
1183 track->default_duration = num / 1000000000.0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1184 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + Default duration: "
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1185 "%.3fms ( = %.3f fps)\n",num/1000000.0,track->v_frate);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1186 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1187 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1188 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1189
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1190 case MATROSKA_ID_TRACKENCODINGS:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1191 l = demux_mkv_read_trackencodings (demuxer, track);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1192 if (l == 0)
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1193 goto err_out;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1194 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1195
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1196 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1197 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1198 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1199 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1200 length -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1201 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1202
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1203 mkv_d->tracks[mkv_d->num_tracks++] = track;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1204 return len;
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1205
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1206 err_out:
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1207 demux_mkv_free_trackentry(track);
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
1208 return 0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1209 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1210
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1211 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1212 demux_mkv_read_tracks (demuxer_t *demuxer)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1213 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1214 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1215 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1216 uint64_t length, l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1217 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1218
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1219 mkv_d->tracks = malloc (sizeof (*mkv_d->tracks));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1220 mkv_d->num_tracks = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1221
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1222 length = ebml_read_length (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1223 while (length > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1224 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1225 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1226 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1227 case MATROSKA_ID_TRACKENTRY:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1228 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + a track...\n");
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1229 mkv_d->tracks = realloc (mkv_d->tracks,
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1230 (mkv_d->num_tracks+1)
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1231 *sizeof (*mkv_d->tracks));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1232 l = demux_mkv_read_trackentry (demuxer);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1233 if (l == 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1234 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1235 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1236
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1237 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1238 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1239 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1240 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1241 length -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1242 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1243 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1244 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1245
20224
08ee6acd3f6c Implement -noidx since index can use quite a bit of memory, esp. when using valgrind.
reimar
parents: 20176
diff changeset
1246 extern int index_mode;
08ee6acd3f6c Implement -noidx since index can use quite a bit of memory, esp. when using valgrind.
reimar
parents: 20176
diff changeset
1247
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1248 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1249 demux_mkv_read_cues (demuxer_t *demuxer)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1250 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1251 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1252 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1253 uint64_t length, l, time, track, pos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1254 off_t off;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1255 int i, il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1256
20224
08ee6acd3f6c Implement -noidx since index can use quite a bit of memory, esp. when using valgrind.
reimar
parents: 20176
diff changeset
1257 if (index_mode == 0) {
08ee6acd3f6c Implement -noidx since index can use quite a bit of memory, esp. when using valgrind.
reimar
parents: 20176
diff changeset
1258 ebml_read_skip (s, NULL);
08ee6acd3f6c Implement -noidx since index can use quite a bit of memory, esp. when using valgrind.
reimar
parents: 20176
diff changeset
1259 return 0;
08ee6acd3f6c Implement -noidx since index can use quite a bit of memory, esp. when using valgrind.
reimar
parents: 20176
diff changeset
1260 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1261 off = stream_tell (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1262 for (i=0; i<mkv_d->parsed_cues_num; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1263 if (mkv_d->parsed_cues[i] == off)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1264 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1265 ebml_read_skip (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1266 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1267 }
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1268 mkv_d->parsed_cues = realloc (mkv_d->parsed_cues,
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1269 (mkv_d->parsed_cues_num+1)
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1270 * sizeof (off_t));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1271 mkv_d->parsed_cues[mkv_d->parsed_cues_num++] = off;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1272
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1273 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing cues ] -----------\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1274 length = ebml_read_length (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1275
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1276 while (length > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1277 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1278 time = track = pos = EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1279
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1280 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1281 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1282 case MATROSKA_ID_POINTENTRY:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1283 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1284 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1285
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1286 len = ebml_read_length (s, &i);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1287 l = len + i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1288
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1289 while (len > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1290 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1291 uint64_t l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1292 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1293
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1294 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1295 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1296 case MATROSKA_ID_CUETIME:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1297 time = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1298 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1299
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1300 case MATROSKA_ID_CUETRACKPOSITION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1301 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1302 uint64_t le;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1303
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1304 le = ebml_read_length (s, &i);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1305 l = le + i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1306
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1307 while (le > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1308 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1309 uint64_t l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1310 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1311
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1312 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1313 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1314 case MATROSKA_ID_CUETRACK:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1315 track = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1316 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1317
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1318 case MATROSKA_ID_CUECLUSTERPOSITION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1319 pos = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1320 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1321
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1322 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1323 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1324 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1325 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1326 le -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1327 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1328 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1329 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1330
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1331 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1332 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1333 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1334 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1335 len -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1336 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1337 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1338 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1339
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1340 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1341 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1342 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1343 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1344
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1345 length -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1346
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1347 if (time != EBML_UINT_INVALID && track != EBML_UINT_INVALID
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1348 && pos != EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1349 {
20140
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
1350 grow_array(&mkv_d->indexes, mkv_d->num_indexes, sizeof(mkv_index_t));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1351 mkv_d->indexes[mkv_d->num_indexes].tnum = track;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1352 mkv_d->indexes[mkv_d->num_indexes].timecode = time;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1353 mkv_d->indexes[mkv_d->num_indexes].filepos =mkv_d->segment_start+pos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1354 mp_msg (MSGT_DEMUX, MSGL_DBG2, "[mkv] |+ found cue point "
16750
0a31740dd5e6 Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents: 16346
diff changeset
1355 "for track %"PRIu64": timecode %"PRIu64", filepos: %"PRIu64"\n",
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1356 track, time, mkv_d->segment_start + pos);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1357 mkv_d->num_indexes++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1358 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1359 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1360
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1361 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing cues ] -----------\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1362 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1363 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1364
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1365 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1366 demux_mkv_read_chapters (demuxer_t *demuxer)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1367 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1368 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1369 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1370 uint64_t length, l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1371 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1372
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1373 if (demuxer->chapters)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1374 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1375 ebml_read_skip (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1376 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1377 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1378
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1379 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing chapters ] ---------\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1380 length = ebml_read_length (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1381
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1382 while (length > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1383 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1384 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1385 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1386 case MATROSKA_ID_EDITIONENTRY:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1387 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1388 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1389 int i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1390
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1391 len = ebml_read_length (s, &i);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1392 l = len + i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1393
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1394 while (len > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1395 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1396 uint64_t l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1397 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1398
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1399 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1400 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1401 case MATROSKA_ID_CHAPTERATOM:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1402 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1403 uint64_t len, start=0, end=0;
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1404 char* name = 0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1405 int i;
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1406 int cid;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1407
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1408 len = ebml_read_length (s, &i);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1409 l = len + i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1410
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1411 while (len > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1412 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1413 uint64_t l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1414 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1415
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1416 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1417 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1418 case MATROSKA_ID_CHAPTERTIMESTART:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1419 start = ebml_read_uint (s, &l) / 1000000;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1420 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1421
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1422 case MATROSKA_ID_CHAPTERTIMEEND:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1423 end = ebml_read_uint (s, &l) / 1000000;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1424 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1425
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1426 case MATROSKA_ID_CHAPTERDISPLAY:
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1427 {
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1428 uint64_t len;
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1429 int i;
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1430
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1431 len = ebml_read_length (s, &i);
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1432 l = len + i;
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1433 while (len > 0)
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1434 {
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1435 uint64_t l;
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1436 int il;
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1437
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1438 switch (ebml_read_id (s, &il))
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1439 {
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1440 case MATROSKA_ID_CHAPSTRING:
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1441 name = ebml_read_utf8 (s, &l);
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1442 break;
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1443 default:
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1444 ebml_read_skip (s, &l);
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1445 break;
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1446 }
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1447 len -= l + il;
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1448 }
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1449 }
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1450 break;
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1451
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1452 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1453 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1454 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1455 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1456 len -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1457 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1458
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1459 if (!name)
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1460 name = strdup("(unnamed)");
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1461
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1462 cid = demuxer_add_chapter(demuxer, name, start, end);
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1463
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1464 mp_msg(MSGT_DEMUX, MSGL_V,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1465 "[mkv] Chapter %u from %02d:%02d:%02d."
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1466 "%03d to %02d:%02d:%02d.%03d, %s\n",
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1467 cid,
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1468 (int) (start / 60 / 60 / 1000),
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1469 (int) ((start / 60 / 1000) % 60),
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1470 (int) ((start / 1000) % 60),
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1471 (int) (start % 1000),
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1472 (int) (end / 60 / 60 / 1000),
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1473 (int) ((end / 60 / 1000) % 60),
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1474 (int) ((end / 1000) % 60),
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1475 (int) (end % 1000), name);
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1476
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
1477 free(name);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1478 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1479 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1480
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1481 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1482 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1483 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1484 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1485 len -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1486 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1487 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1488 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1489
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1490 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1491 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1492 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1493 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1494
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1495 length -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1496 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1497
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1498 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing chapters ] ---------\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1499 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1500 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1501
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1502 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1503 demux_mkv_read_tags (demuxer_t *demuxer)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1504 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1505 ebml_read_skip (demuxer->stream, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1506 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1507 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1508
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1509 static int
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1510 demux_mkv_read_attachments (demuxer_t *demuxer)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1511 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1512 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1513 stream_t *s = demuxer->stream;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1514 uint64_t length, l;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1515 int il;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1516
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1517 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing attachments ] ---------\n");
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1518 length = ebml_read_length (s, NULL);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1519
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1520 while (length > 0)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1521 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1522 switch (ebml_read_id (s, &il))
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1523 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1524 case MATROSKA_ID_ATTACHEDFILE:
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1525 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1526 uint64_t len;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1527 int i;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1528 char* name = NULL;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1529 char* mime = NULL;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1530 uint64_t uid = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1531 char* data = NULL;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1532 int data_size = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1533
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1534 len = ebml_read_length (s, &i);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1535 l = len + i;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1536
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1537 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + an attachment...\n");
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1538
20140
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
1539 grow_array(&mkv_d->attachments, mkv_d->num_attachments,
1861d40674ca Simplify (by using realloc with NULL parameter) and refactor code to grow
reimar
parents: 20137
diff changeset
1540 sizeof(*mkv_d->attachments));
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1541
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1542 while (len > 0)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1543 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1544 uint64_t l;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1545 int il;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1546
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1547 switch (ebml_read_id (s, &il))
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1548 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1549 case MATROSKA_ID_FILENAME:
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1550 name = ebml_read_utf8 (s, &l);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1551 if (name == NULL)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1552 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1553 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + FileName: %s\n",
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1554 name);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1555 break;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1556
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1557 case MATROSKA_ID_FILEMIMETYPE:
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1558 mime = ebml_read_ascii (s, &l);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1559 if (mime == NULL)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1560 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1561 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + FileMimeType: %s\n",
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1562 mime);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1563 break;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1564
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1565 case MATROSKA_ID_FILEUID:
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1566 uid = ebml_read_uint (s, &l);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1567 break;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1568
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1569 case MATROSKA_ID_FILEDATA:
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1570 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1571 int x;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1572 uint64_t num = ebml_read_length (s, &x);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1573 l = x + num;
20154
2e7baee989ad Avoid memleak on error while reading attachments or multiple
reimar
parents: 20140
diff changeset
1574 free(data);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1575 data = malloc (num);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1576 if (stream_read(s, data, num) != (int) num)
20154
2e7baee989ad Avoid memleak on error while reading attachments or multiple
reimar
parents: 20140
diff changeset
1577 {
2e7baee989ad Avoid memleak on error while reading attachments or multiple
reimar
parents: 20140
diff changeset
1578 free(data);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1579 return 0;
20154
2e7baee989ad Avoid memleak on error while reading attachments or multiple
reimar
parents: 20140
diff changeset
1580 }
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1581 data_size = num;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1582 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + FileData, length "
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1583 "%u\n", data_size);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1584 break;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1585 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1586
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1587 default:
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1588 ebml_read_skip (s, &l);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1589 break;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1590 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1591 len -= l + il;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1592 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1593
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1594 mkv_d->attachments[mkv_d->num_attachments].name = name;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1595 mkv_d->attachments[mkv_d->num_attachments].mime = mime;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1596 mkv_d->attachments[mkv_d->num_attachments].uid = uid;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1597 mkv_d->attachments[mkv_d->num_attachments].data = data;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1598 mkv_d->attachments[mkv_d->num_attachments].data_size = data_size;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1599 mkv_d->num_attachments ++;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1600 mp_msg(MSGT_DEMUX, MSGL_V,
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1601 "[mkv] Attachment: %s, %s, %u bytes\n",
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1602 name, mime, data_size);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1603 #ifdef USE_ASS
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1604 if (extract_embedded_fonts && name && data && data_size &&
19621
a0105ea61f2d Extract "application/x-font" attachments from matroska, in addition
eugeni
parents: 19540
diff changeset
1605 mime && (strcmp(mime, "application/x-truetype-font") == 0 ||
a0105ea61f2d Extract "application/x-font" attachments from matroska, in addition
eugeni
parents: 19540
diff changeset
1606 strcmp(mime, "application/x-font") == 0))
21455
dd49d3712e6f Rename: ass_process_font -> ass_add_font.
eugeni
parents: 21421
diff changeset
1607 ass_add_font(ass_library, name, data, data_size);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1608 #endif
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1609 break;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1610 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1611
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1612 default:
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1613 ebml_read_skip (s, &l);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1614 break;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1615 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1616 length -= l + il;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1617 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1618
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1619 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing attachments ] ---------\n");
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1620 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1621 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1622
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
1623 static int
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1624 demux_mkv_read_seekhead (demuxer_t *demuxer)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1625 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1626 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1627 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1628 uint64_t length, l, seek_pos, saved_pos, num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1629 uint32_t seek_id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1630 int i, il, res = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1631 off_t off;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1632
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1633 off = stream_tell (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1634 for (i=0; i<mkv_d->parsed_seekhead_num; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1635 if (mkv_d->parsed_seekhead[i] == off)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1636 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1637 ebml_read_skip (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1638 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1639 }
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1640 mkv_d->parsed_seekhead = realloc (mkv_d->parsed_seekhead,
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1641 (mkv_d->parsed_seekhead_num+1)
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1642 * sizeof (off_t));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1643 mkv_d->parsed_seekhead[mkv_d->parsed_seekhead_num++] = off;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1644
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1645 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] /---- [ parsing seek head ] ---------\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1646 length = ebml_read_length (s, NULL);
20734
9f97c2b0340f If parsing a seek head fails then mplayer should try continue parsing the file after the seek head.
mosu
parents: 20712
diff changeset
1647 /* off now holds the position of the next element after the seek head. */
9f97c2b0340f If parsing a seek head fails then mplayer should try continue parsing the file after the seek head.
mosu
parents: 20712
diff changeset
1648 off = stream_tell (s) + length;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1649 while (length > 0 && !res)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1650 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1651
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1652 seek_id = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1653 seek_pos = EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1654
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1655 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1656 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1657 case MATROSKA_ID_SEEKENTRY:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1658 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1659 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1660
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1661 len = ebml_read_length (s, &i);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1662 l = len + i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1663
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1664 while (len > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1665 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1666 uint64_t l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1667 int il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1668
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1669 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1670 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1671 case MATROSKA_ID_SEEKID:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1672 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1673 if (num != EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1674 seek_id = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1675 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1676
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1677 case MATROSKA_ID_SEEKPOSITION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1678 seek_pos = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1679 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1680
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1681 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1682 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1683 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1684 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1685 len -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1686 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1687
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1688 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1689 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1690
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1691 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1692 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1693 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1694 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1695 length -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1696
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1697 if (seek_id == 0 || seek_id == MATROSKA_ID_CLUSTER
11899
18bd28454ef6 Do not try to seek beyond the end of the stream when parsing the headers.
mosu
parents: 11856
diff changeset
1698 || seek_pos == EBML_UINT_INVALID ||
18bd28454ef6 Do not try to seek beyond the end of the stream when parsing the headers.
mosu
parents: 11856
diff changeset
1699 ((mkv_d->segment_start + seek_pos) >= (uint64_t)demuxer->movi_end))
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1700 continue;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1701
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1702 saved_pos = stream_tell (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1703 if (!stream_seek (s, mkv_d->segment_start + seek_pos))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1704 res = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1705 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1706 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1707 if (ebml_read_id (s, &il) != seek_id)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1708 res = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1709 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1710 switch (seek_id)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1711 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1712 case MATROSKA_ID_CUES:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1713 if (demux_mkv_read_cues (demuxer))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1714 res = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1715 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1716
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1717 case MATROSKA_ID_TAGS:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1718 if (demux_mkv_read_tags (demuxer))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1719 res = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1720 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1721
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1722 case MATROSKA_ID_SEEKHEAD:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1723 if (demux_mkv_read_seekhead (demuxer))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1724 res = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1725 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1726
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1727 case MATROSKA_ID_CHAPTERS:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1728 if (demux_mkv_read_chapters (demuxer))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1729 res = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1730 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1731 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1732 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1733
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1734 stream_seek (s, saved_pos);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1735 }
20734
9f97c2b0340f If parsing a seek head fails then mplayer should try continue parsing the file after the seek head.
mosu
parents: 20712
diff changeset
1736 if (res)
9f97c2b0340f If parsing a seek head fails then mplayer should try continue parsing the file after the seek head.
mosu
parents: 20712
diff changeset
1737 {
9f97c2b0340f If parsing a seek head fails then mplayer should try continue parsing the file after the seek head.
mosu
parents: 20712
diff changeset
1738 /* If there was an error then try to skip this seek head. */
9f97c2b0340f If parsing a seek head fails then mplayer should try continue parsing the file after the seek head.
mosu
parents: 20712
diff changeset
1739 if (stream_seek (s, off))
9f97c2b0340f If parsing a seek head fails then mplayer should try continue parsing the file after the seek head.
mosu
parents: 20712
diff changeset
1740 res = 0;
9f97c2b0340f If parsing a seek head fails then mplayer should try continue parsing the file after the seek head.
mosu
parents: 20712
diff changeset
1741 }
9f97c2b0340f If parsing a seek head fails then mplayer should try continue parsing the file after the seek head.
mosu
parents: 20712
diff changeset
1742 else
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1743 if (length > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1744 stream_seek (s, stream_tell (s) + length);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1745 mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] \\---- [ parsing seek head ] ---------\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1746 return res;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1747 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1748
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1749 static int
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1750 demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track, int vid);
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1751 static int
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1752 demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid);
20872
a8b42366e68a Make subtitle stream handling more similar to audio and video streams.
reimar
parents: 20734
diff changeset
1753 static int
a8b42366e68a Make subtitle stream handling more similar to audio and video streams.
reimar
parents: 20734
diff changeset
1754 demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track, int sid);
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1755
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1756 static void
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1757 display_create_tracks (demuxer_t *demuxer)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1758 {
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1759 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *)demuxer->priv;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1760 int i, vid=0, aid=0, sid=0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1761
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1762 for (i=0; i<mkv_d->num_tracks; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1763 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1764 char *type = "unknown", str[32];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1765 *str = '\0';
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1766 switch (mkv_d->tracks[i]->type)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1767 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1768 case MATROSKA_TRACK_VIDEO:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1769 type = "video";
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1770 demux_mkv_open_video(demuxer, mkv_d->tracks[i], vid);
19640
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1771 if (mkv_d->tracks[i]->name)
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1772 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VID_%d_NAME=%s\n", vid, mkv_d->tracks[i]->name);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1773 sprintf (str, "-vid %u", vid++);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1774 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1775 case MATROSKA_TRACK_AUDIO:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1776 type = "audio";
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1777 demux_mkv_open_audio(demuxer, mkv_d->tracks[i], aid);
19640
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1778 if (mkv_d->tracks[i]->name)
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1779 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_NAME=%s\n", aid, mkv_d->tracks[i]->name);
18237
4231482179b6 Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents: 18236
diff changeset
1780 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", aid, mkv_d->tracks[i]->language);
12288
8c8c71a02e5a fix exploitable buffer overflow
rfelker
parents: 12101
diff changeset
1781 sprintf (str, "-aid %u, -alang %.5s",aid++,mkv_d->tracks[i]->language);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1782 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1783 case MATROSKA_TRACK_SUBTITLE:
13324
dcbdd8ea356d Spelling. Patch by Jan Minar <jjminar at fastmail onedot fm>.
mosu
parents: 13131
diff changeset
1784 type = "subtitles";
20872
a8b42366e68a Make subtitle stream handling more similar to audio and video streams.
reimar
parents: 20734
diff changeset
1785 demux_mkv_open_sub(demuxer, mkv_d->tracks[i], sid);
19640
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1786 if (mkv_d->tracks[i]->name)
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1787 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_NAME=%s\n", sid, mkv_d->tracks[i]->name);
18237
4231482179b6 Get ride of the several if(identify) messy lines and rearangment of some of the output, both patches by Kiriuja mplayer-patches AT en-directo_net, his changes are barely unrelated, nevertheless Im commiting them thogeter just for the sake of my mental healt, I had both patches already applied on my local three
reynaldo
parents: 18236
diff changeset
1788 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", sid, mkv_d->tracks[i]->language);
12288
8c8c71a02e5a fix exploitable buffer overflow
rfelker
parents: 12101
diff changeset
1789 sprintf (str, "-sid %u, -slang %.5s",sid++,mkv_d->tracks[i]->language);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1790 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1791 }
19640
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1792 if (mkv_d->tracks[i]->name)
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
1793 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_MKV_TrackIDName,
19640
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1794 mkv_d->tracks[i]->tnum, type, mkv_d->tracks[i]->codec_id, mkv_d->tracks[i]->name, str);
521f71200591 Display track names in matroska files.
eugeni
parents: 19621
diff changeset
1795 else
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
1796 mp_msg(MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_MKV_TrackID,
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1797 mkv_d->tracks[i]->tnum, type, mkv_d->tracks[i]->codec_id, str);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1798 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1799 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1800
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1801 static int
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1802 demux_mkv_open_video (demuxer_t *demuxer, mkv_track_t *track, int vid)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1803 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1804 BITMAPINFOHEADER *bih;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1805 void *ImageDesc = NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1806 sh_video_t *sh_v;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1808 if (track->ms_compat) /* MS compatibility mode */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1809 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1810 BITMAPINFOHEADER *src;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1811
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1812 if (track->private_data == NULL
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1813 || track->private_size < sizeof (BITMAPINFOHEADER))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1814 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1815
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1816 src = (BITMAPINFOHEADER *) track->private_data;
20130
b5c68feff55c replace malloc+memset by calloc
reimar
parents: 20129
diff changeset
1817 bih = calloc (1, track->private_size);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1818 bih->biSize = le2me_32 (src->biSize);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1819 bih->biWidth = le2me_32 (src->biWidth);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1820 bih->biHeight = le2me_32 (src->biHeight);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1821 bih->biPlanes = le2me_16 (src->biPlanes);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1822 bih->biBitCount = le2me_16 (src->biBitCount);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1823 bih->biCompression = le2me_32 (src->biCompression);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1824 bih->biSizeImage = le2me_32 (src->biSizeImage);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1825 bih->biXPelsPerMeter = le2me_32 (src->biXPelsPerMeter);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1826 bih->biYPelsPerMeter = le2me_32 (src->biYPelsPerMeter);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1827 bih->biClrUsed = le2me_32 (src->biClrUsed);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1828 bih->biClrImportant = le2me_32 (src->biClrImportant);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1829 memcpy((char *) bih + sizeof (BITMAPINFOHEADER),
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1830 (char *) src + sizeof (BITMAPINFOHEADER),
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1831 track->private_size - sizeof (BITMAPINFOHEADER));
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1832
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1833 if (track->v_width == 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1834 track->v_width = bih->biWidth;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1835 if (track->v_height == 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1836 track->v_height = bih->biHeight;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1837 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1838 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1839 {
20130
b5c68feff55c replace malloc+memset by calloc
reimar
parents: 20129
diff changeset
1840 bih = calloc (1, sizeof (BITMAPINFOHEADER));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1841 bih->biSize = sizeof (BITMAPINFOHEADER);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1842 bih->biWidth = track->v_width;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1843 bih->biHeight = track->v_height;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1844 bih->biBitCount = 24;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1845 bih->biSizeImage = bih->biWidth * bih->biHeight * bih->biBitCount/8;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1846
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1847 if (track->private_size >= sizeof (real_video_props_t)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1848 && (!strcmp (track->codec_id, MKV_V_REALV10)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1849 || !strcmp (track->codec_id, MKV_V_REALV20)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1850 || !strcmp (track->codec_id, MKV_V_REALV30)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1851 || !strcmp (track->codec_id, MKV_V_REALV40)))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1852 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1853 unsigned char *dst, *src;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1854 real_video_props_t *rvp;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1855 uint32_t type2;
20920
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20872
diff changeset
1856 unsigned int cnt;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1857
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1858 rvp = (real_video_props_t *) track->private_data;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1859 src = (unsigned char *) (rvp + 1);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1860
20920
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20872
diff changeset
1861 cnt = track->private_size - sizeof (real_video_props_t);
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20872
diff changeset
1862 bih = realloc(bih, sizeof (BITMAPINFOHEADER)+8+cnt);
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20872
diff changeset
1863 bih->biSize = 48+cnt;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1864 bih->biPlanes = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1865 type2 = be2me_32 (rvp->type2);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1866 if (type2 == 0x10003000 || type2 == 0x10003001)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1867 bih->biCompression=mmioFOURCC('R','V','1','3');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1868 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1869 bih->biCompression=mmioFOURCC('R','V',track->codec_id[9],'0');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1870 dst = (unsigned char *) (bih + 1);
20920
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20872
diff changeset
1871 ((unsigned int *) dst)[0] = rvp->type1;
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20872
diff changeset
1872 ((unsigned int *) dst)[1] = rvp->type2;
94b1a797661f Fix extradata passing to lavc RV20 decoder
rtogni
parents: 20872
diff changeset
1873 stream_read(demuxer->stream, dst+8, cnt);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1874 track->realmedia = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1875
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1876 #ifdef USE_QTX_CODECS
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1877 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1878 else if (track->private_size >= sizeof (ImageDescription)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1879 && !strcmp(track->codec_id, MKV_V_QUICKTIME))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1880 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1881 ImageDescriptionPtr idesc;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1882
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1883 idesc = (ImageDescriptionPtr) track->private_data;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1884 idesc->idSize = be2me_32 (idesc->idSize);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1885 idesc->cType = be2me_32 (idesc->cType);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1886 idesc->version = be2me_16 (idesc->version);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1887 idesc->revisionLevel = be2me_16 (idesc->revisionLevel);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1888 idesc->vendor = be2me_32 (idesc->vendor);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1889 idesc->temporalQuality = be2me_32 (idesc->temporalQuality);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1890 idesc->spatialQuality = be2me_32 (idesc->spatialQuality);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1891 idesc->width = be2me_16 (idesc->width);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1892 idesc->height = be2me_16 (idesc->height);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1893 idesc->hRes = be2me_32 (idesc->hRes);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1894 idesc->vRes = be2me_32 (idesc->vRes);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1895 idesc->dataSize = be2me_32 (idesc->dataSize);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1896 idesc->frameCount = be2me_16 (idesc->frameCount);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1897 idesc->depth = be2me_16 (idesc->depth);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1898 idesc->clutID = be2me_16 (idesc->clutID);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1899 bih->biPlanes = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1900 bih->biCompression = idesc->cType;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1901 ImageDesc = idesc;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1902 #endif /* USE_QTX_CODECS */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1903
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1904 }
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
1905 else if (!strcmp(track->codec_id, MKV_V_MPEG1))
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
1906 {
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
1907 bih->biCompression = mmioFOURCC('m', 'p', 'g', '1');
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18885
diff changeset
1908 track->reorder_timecodes = !correct_pts;
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
1909 }
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
1910 else if (!strcmp(track->codec_id, MKV_V_MPEG2))
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
1911 {
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
1912 bih->biCompression = mmioFOURCC('m', 'p', 'g', '2');
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18885
diff changeset
1913 track->reorder_timecodes = !correct_pts;
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
1914 }
19154
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1915 else if (!strcmp(track->codec_id, MKV_V_MPEG4_SP) ||
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1916 !strcmp(track->codec_id, MKV_V_MPEG4_ASP) ||
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1917 !strcmp(track->codec_id, MKV_V_MPEG4_AP))
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1918 {
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1919 bih->biCompression = mmioFOURCC('m', 'p', '4', 'v');
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1920 if (track->private_data && (track->private_size > 0))
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1921 {
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1922 bih->biSize += track->private_size;
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1923 bih = realloc (bih, bih->biSize);
19154
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1924 memcpy (bih + 1, track->private_data, track->private_size);
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1925 }
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1926 track->reorder_timecodes = !correct_pts;
2895b9807ff3 Native MPEG4 SP/ASP/AP support in Matroska.
rathann
parents: 18984
diff changeset
1927 }
14458
6e5956958746 Support for AVC in Matroska.
mosu
parents: 14058
diff changeset
1928 else if (!strcmp(track->codec_id, MKV_V_MPEG4_AVC))
6e5956958746 Support for AVC in Matroska.
mosu
parents: 14058
diff changeset
1929 {
6e5956958746 Support for AVC in Matroska.
mosu
parents: 14058
diff changeset
1930 bih->biCompression = mmioFOURCC('a', 'v', 'c', '1');
6e5956958746 Support for AVC in Matroska.
mosu
parents: 14058
diff changeset
1931 if (track->private_data && (track->private_size > 0))
6e5956958746 Support for AVC in Matroska.
mosu
parents: 14058
diff changeset
1932 {
6e5956958746 Support for AVC in Matroska.
mosu
parents: 14058
diff changeset
1933 bih->biSize += track->private_size;
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1934 bih = realloc (bih, bih->biSize);
14458
6e5956958746 Support for AVC in Matroska.
mosu
parents: 14058
diff changeset
1935 memcpy (bih + 1, track->private_data, track->private_size);
6e5956958746 Support for AVC in Matroska.
mosu
parents: 14058
diff changeset
1936 }
18917
d9a75b26da6c Add a new video pts tracking mode, enabled by option -correct-pts.
uau
parents: 18885
diff changeset
1937 track->reorder_timecodes = !correct_pts;
14458
6e5956958746 Support for AVC in Matroska.
mosu
parents: 14058
diff changeset
1938 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1939 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1940 {
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
1941 mp_msg (MSGT_DEMUX,MSGL_WARN, MSGTR_MPDEMUX_MKV_UnknownCodecID,
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1942 track->codec_id, track->tnum);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1943 free(bih);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1944 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1945 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1946 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1947
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1948 sh_v = new_sh_video_vid (demuxer, track->tnum, vid);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1949 sh_v->bih = bih;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1950 sh_v->format = sh_v->bih->biCompression;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1951 if (track->v_frate == 0.0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1952 track->v_frate = 25.0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1953 sh_v->fps = track->v_frate;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1954 sh_v->frametime = 1 / track->v_frate;
13381
8db5683d2b3c fix playback of files with displaysize not set (aspect was set to NaN for these)
reimar
parents: 13324
diff changeset
1955 sh_v->aspect = 0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1956 if (!track->realmedia)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1957 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1958 sh_v->disp_w = track->v_width;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1959 sh_v->disp_h = track->v_height;
13381
8db5683d2b3c fix playback of files with displaysize not set (aspect was set to NaN for these)
reimar
parents: 13324
diff changeset
1960 if (track->v_dheight)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1961 sh_v->aspect = (float)track->v_dwidth / (float)track->v_dheight;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1962 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1963 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1964 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1965 // vd_realvid.c will set aspect to disp_w/disp_h and rederive
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1966 // disp_w and disp_h from the RealVideo stream contents returned
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1967 // by the Real DLLs. If DisplayWidth/DisplayHeight was not set in
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1968 // the Matroska file then it has already been set to PixelWidth/Height
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1969 // by check_track_information.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1970 sh_v->disp_w = track->v_dwidth;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1971 sh_v->disp_h = track->v_dheight;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1972 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1973 sh_v->ImageDesc = ImageDesc;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1974 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] Aspect: %f\n", sh_v->aspect);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1975
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1976 sh_v->ds = demuxer->video;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1977 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1978 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1979
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1980 static int
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1981 demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1982 {
18754
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
1983 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
1984 sh_audio_t *sh_a = new_sh_audio_aid(demuxer, track->tnum, aid);
18984
07fc09eaab56 more c++ decl crap
rfelker
parents: 18937
diff changeset
1985 demux_packet_t *dp;
18754
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
1986 if(!sh_a) return 1;
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
1987 mkv_d->audio_tracks[mkv_d->last_aid] = track->tnum;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1988
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1989 sh_a->ds = demuxer->audio;
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1990 sh_a->wf = malloc (sizeof (WAVEFORMATEX));
12101
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
1991 if (track->ms_compat && (track->private_size >= sizeof(WAVEFORMATEX)))
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
1992 {
12101
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
1993 WAVEFORMATEX *wf = (WAVEFORMATEX *)track->private_data;
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
1994 sh_a->wf = realloc(sh_a->wf, track->private_size);
12101
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
1995 sh_a->wf->wFormatTag = le2me_16 (wf->wFormatTag);
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
1996 sh_a->wf->nChannels = le2me_16 (wf->nChannels);
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
1997 sh_a->wf->nSamplesPerSec = le2me_32 (wf->nSamplesPerSec);
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
1998 sh_a->wf->nAvgBytesPerSec = le2me_32 (wf->nAvgBytesPerSec);
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
1999 sh_a->wf->nBlockAlign = le2me_16 (wf->nBlockAlign);
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
2000 sh_a->wf->wBitsPerSample = le2me_16 (wf->wBitsPerSample);
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
2001 sh_a->wf->cbSize = track->private_size - sizeof(WAVEFORMATEX);
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
2002 memcpy(sh_a->wf + 1, wf + 1, track->private_size - sizeof(WAVEFORMATEX));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2003 if (track->a_sfreq == 0.0)
12101
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
2004 track->a_sfreq = sh_a->wf->nSamplesPerSec;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2005 if (track->a_channels == 0)
12101
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
2006 track->a_channels = sh_a->wf->nChannels;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2007 if (track->a_bps == 0)
12101
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
2008 track->a_bps = sh_a->wf->wBitsPerSample;
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
2009 track->a_formattag = sh_a->wf->wFormatTag;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2010 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2011 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2012 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2013 memset(sh_a->wf, 0, sizeof (WAVEFORMATEX));
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2014 if (!strcmp(track->codec_id, MKV_A_MP3) ||
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2015 !strcmp(track->codec_id, MKV_A_MP2))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2016 track->a_formattag = 0x0055;
13804
5c0fda3b83c3 DTS uses the format tag 0x2001. Patch by Joakim Plate (joakim ! plate () ecce ! se)
mosu
parents: 13501
diff changeset
2017 else if (!strncmp(track->codec_id, MKV_A_AC3, strlen(MKV_A_AC3)))
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2018 track->a_formattag = 0x2000;
13804
5c0fda3b83c3 DTS uses the format tag 0x2001. Patch by Joakim Plate (joakim ! plate () ecce ! se)
mosu
parents: 13501
diff changeset
2019 else if (!strcmp(track->codec_id, MKV_A_DTS))
5c0fda3b83c3 DTS uses the format tag 0x2001. Patch by Joakim Plate (joakim ! plate () ecce ! se)
mosu
parents: 13501
diff changeset
2020 track->a_formattag = 0x2001;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2021 else if (!strcmp(track->codec_id, MKV_A_PCM) ||
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2022 !strcmp(track->codec_id, MKV_A_PCM_BE))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2023 track->a_formattag = 0x0001;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2024 else if (!strcmp(track->codec_id, MKV_A_AAC_2MAIN) ||
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2025 !strncmp(track->codec_id, MKV_A_AAC_2LC,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2026 strlen(MKV_A_AAC_2LC)) ||
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2027 !strcmp(track->codec_id, MKV_A_AAC_2SSR) ||
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2028 !strcmp(track->codec_id, MKV_A_AAC_4MAIN) ||
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2029 !strncmp(track->codec_id, MKV_A_AAC_4LC,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2030 strlen(MKV_A_AAC_4LC)) ||
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2031 !strcmp(track->codec_id, MKV_A_AAC_4SSR) ||
16824
ab1eb8054890 Added support for A_AAC.
mosu
parents: 16750
diff changeset
2032 !strcmp(track->codec_id, MKV_A_AAC_4LTP) ||
ab1eb8054890 Added support for A_AAC.
mosu
parents: 16750
diff changeset
2033 !strcmp(track->codec_id, MKV_A_AAC))
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2034 track->a_formattag = mmioFOURCC('M', 'P', '4', 'A');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2035 else if (!strcmp(track->codec_id, MKV_A_VORBIS))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2036 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2037 if (track->private_data == NULL)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2038 return 1;
14843
bbb693d3b130 Fix the ogg fourcc nightmare!!!
rfelker
parents: 14561
diff changeset
2039 track->a_formattag = mmioFOURCC('v', 'r', 'b', 's');
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2040 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2041 else if (!strcmp(track->codec_id, MKV_A_QDMC))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2042 track->a_formattag = mmioFOURCC('Q', 'D', 'M', 'C');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2043 else if (!strcmp(track->codec_id, MKV_A_QDMC2))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2044 track->a_formattag = mmioFOURCC('Q', 'D', 'M', '2');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2045 else if (!strcmp(track->codec_id, MKV_A_FLAC))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2046 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2047 if (track->private_data == NULL || track->private_size == 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2048 {
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2049 mp_msg (MSGT_DEMUX, MSGL_WARN,
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2050 MSGTR_MPDEMUX_MKV_FlacTrackDoesNotContainValidHeaders);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2051 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2052 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2053 track->a_formattag = mmioFOURCC ('f', 'L', 'a', 'C');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2054 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2055 else if (track->private_size >= sizeof (real_audio_v4_props_t))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2056 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2057 if (!strcmp(track->codec_id, MKV_A_REAL28))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2058 track->a_formattag = mmioFOURCC('2', '8', '_', '8');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2059 else if (!strcmp(track->codec_id, MKV_A_REALATRC))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2060 track->a_formattag = mmioFOURCC('a', 't', 'r', 'c');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2061 else if (!strcmp(track->codec_id, MKV_A_REALCOOK))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2062 track->a_formattag = mmioFOURCC('c', 'o', 'o', 'k');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2063 else if (!strcmp(track->codec_id, MKV_A_REALDNET))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2064 track->a_formattag = mmioFOURCC('d', 'n', 'e', 't');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2065 else if (!strcmp(track->codec_id, MKV_A_REALSIPR))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2066 track->a_formattag = mmioFOURCC('s', 'i', 'p', 'r');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2067 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2068 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2069 {
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2070 mp_msg (MSGT_DEMUX, MSGL_WARN, MSGTR_MPDEMUX_MKV_UnknownAudioCodec,
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2071 track->codec_id, track->tnum);
18708
9e2b300db17b Change free_sh_audio() to take demuxer and stream id as parameters
uau
parents: 18558
diff changeset
2072 free_sh_audio(demuxer, track->tnum);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2073 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2074 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2075 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2076
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2077 sh_a->format = track->a_formattag;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2078 sh_a->wf->wFormatTag = track->a_formattag;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2079 sh_a->channels = track->a_channels;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2080 sh_a->wf->nChannels = track->a_channels;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2081 sh_a->samplerate = (uint32_t) track->a_sfreq;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2082 sh_a->wf->nSamplesPerSec = (uint32_t) track->a_sfreq;
13424
907cc2547357 With the latest change to dec_audio.c (1.32) the demuxers have to set sh_a->samplesize to something != 0.
mosu
parents: 13381
diff changeset
2083 if (track->a_bps == 0)
907cc2547357 With the latest change to dec_audio.c (1.32) the demuxers have to set sh_a->samplesize to something != 0.
mosu
parents: 13381
diff changeset
2084 {
907cc2547357 With the latest change to dec_audio.c (1.32) the demuxers have to set sh_a->samplesize to something != 0.
mosu
parents: 13381
diff changeset
2085 sh_a->samplesize = 2;
907cc2547357 With the latest change to dec_audio.c (1.32) the demuxers have to set sh_a->samplesize to something != 0.
mosu
parents: 13381
diff changeset
2086 sh_a->wf->wBitsPerSample = 16;
907cc2547357 With the latest change to dec_audio.c (1.32) the demuxers have to set sh_a->samplesize to something != 0.
mosu
parents: 13381
diff changeset
2087 }
907cc2547357 With the latest change to dec_audio.c (1.32) the demuxers have to set sh_a->samplesize to something != 0.
mosu
parents: 13381
diff changeset
2088 else
907cc2547357 With the latest change to dec_audio.c (1.32) the demuxers have to set sh_a->samplesize to something != 0.
mosu
parents: 13381
diff changeset
2089 {
907cc2547357 With the latest change to dec_audio.c (1.32) the demuxers have to set sh_a->samplesize to something != 0.
mosu
parents: 13381
diff changeset
2090 sh_a->samplesize = track->a_bps / 8;
907cc2547357 With the latest change to dec_audio.c (1.32) the demuxers have to set sh_a->samplesize to something != 0.
mosu
parents: 13381
diff changeset
2091 sh_a->wf->wBitsPerSample = track->a_bps;
907cc2547357 With the latest change to dec_audio.c (1.32) the demuxers have to set sh_a->samplesize to something != 0.
mosu
parents: 13381
diff changeset
2092 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2093 if (track->a_formattag == 0x0055) /* MP3 || MP2 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2094 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2095 sh_a->wf->nAvgBytesPerSec = 16000;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2096 sh_a->wf->nBlockAlign = 1152;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2097 }
13804
5c0fda3b83c3 DTS uses the format tag 0x2001. Patch by Joakim Plate (joakim ! plate () ecce ! se)
mosu
parents: 13501
diff changeset
2098 else if ((track->a_formattag == 0x2000) || /* AC3 */
5c0fda3b83c3 DTS uses the format tag 0x2001. Patch by Joakim Plate (joakim ! plate () ecce ! se)
mosu
parents: 13501
diff changeset
2099 (track->a_formattag == 0x2001)) /* DTS */
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2100 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2101 sh_a->wf->nAvgBytesPerSec = 16000;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2102 sh_a->wf->nBlockAlign = 1536;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2103 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2104 else if (track->a_formattag == 0x0001) /* PCM || PCM_BE */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2105 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2106 sh_a->wf->nAvgBytesPerSec = sh_a->channels * sh_a->samplerate*2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2107 sh_a->wf->nBlockAlign = sh_a->wf->nAvgBytesPerSec;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2108 if (!strcmp(track->codec_id, MKV_A_PCM_BE))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2109 sh_a->format = mmioFOURCC('t', 'w', 'o', 's');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2110 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2111 else if (!strcmp(track->codec_id, MKV_A_QDMC) ||
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2112 !strcmp(track->codec_id, MKV_A_QDMC2))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2113 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2114 sh_a->wf->nAvgBytesPerSec = 16000;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2115 sh_a->wf->nBlockAlign = 1486;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2116 track->fix_i_bps = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2117 track->qt_last_a_pts = 0.0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2118 if (track->private_data != NULL)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2119 {
18885
5c8acc972551 rm unnecesary casts from void* - part 4
reynaldo
parents: 18754
diff changeset
2120 sh_a->codecdata=malloc(track->private_size);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2121 memcpy (sh_a->codecdata, track->private_data,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2122 track->private_size);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2123 sh_a->codecdata_len = track->private_size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2124 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2125 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2126 else if (track->a_formattag == mmioFOURCC('M', 'P', '4', 'A'))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2127 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2128 int profile, srate_idx;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2129
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2130 sh_a->wf->nAvgBytesPerSec = 16000;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2131 sh_a->wf->nBlockAlign = 1024;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2132
16824
ab1eb8054890 Added support for A_AAC.
mosu
parents: 16750
diff changeset
2133 if (!strcmp (track->codec_id, MKV_A_AAC) &&
ab1eb8054890 Added support for A_AAC.
mosu
parents: 16750
diff changeset
2134 (NULL != track->private_data))
ab1eb8054890 Added support for A_AAC.
mosu
parents: 16750
diff changeset
2135 {
18885
5c8acc972551 rm unnecesary casts from void* - part 4
reynaldo
parents: 18754
diff changeset
2136 sh_a->codecdata=malloc(track->private_size);
16824
ab1eb8054890 Added support for A_AAC.
mosu
parents: 16750
diff changeset
2137 memcpy (sh_a->codecdata, track->private_data,
ab1eb8054890 Added support for A_AAC.
mosu
parents: 16750
diff changeset
2138 track->private_size);
ab1eb8054890 Added support for A_AAC.
mosu
parents: 16750
diff changeset
2139 sh_a->codecdata_len = track->private_size;
ab1eb8054890 Added support for A_AAC.
mosu
parents: 16750
diff changeset
2140 return 0;
ab1eb8054890 Added support for A_AAC.
mosu
parents: 16750
diff changeset
2141 }
ab1eb8054890 Added support for A_AAC.
mosu
parents: 16750
diff changeset
2142
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2143 /* Recreate the 'private data' */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2144 /* which faad2 uses in its initialization */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2145 srate_idx = aac_get_sample_rate_index (sh_a->samplerate);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2146 if (!strncmp (&track->codec_id[12], "MAIN", 4))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2147 profile = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2148 else if (!strncmp (&track->codec_id[12], "LC", 2))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2149 profile = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2150 else if (!strncmp (&track->codec_id[12], "SSR", 3))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2151 profile = 2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2152 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2153 profile = 3;
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
2154 sh_a->codecdata = malloc (5);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2155 sh_a->codecdata[0] = ((profile+1) << 3) | ((srate_idx&0xE) >> 1);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2156 sh_a->codecdata[1] = ((srate_idx&0x1)<<7)|(track->a_channels<<3);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2157
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2158 if (strstr(track->codec_id, "SBR") != NULL)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2159 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2160 /* HE-AAC (aka SBR AAC) */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2161 sh_a->codecdata_len = 5;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2162
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2163 sh_a->samplerate *= 2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2164 sh_a->wf->nSamplesPerSec *= 2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2165 srate_idx = aac_get_sample_rate_index(sh_a->samplerate);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2166 sh_a->codecdata[2] = AAC_SYNC_EXTENSION_TYPE >> 3;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2167 sh_a->codecdata[3] = ((AAC_SYNC_EXTENSION_TYPE&0x07)<<5) | 5;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2168 sh_a->codecdata[4] = (1 << 7) | (srate_idx << 3);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2169 track->default_duration = 1024.0 / (sh_a->samplerate / 2);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2170 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2171 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2172 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2173 sh_a->codecdata_len = 2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2174 track->default_duration = 1024.0 / (float)sh_a->samplerate;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2175 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2176 }
14843
bbb693d3b130 Fix the ogg fourcc nightmare!!!
rfelker
parents: 14561
diff changeset
2177 else if (track->a_formattag == mmioFOURCC('v', 'r', 'b', 's')) /* VORBIS */
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2178 {
15420
f3cf481bbcda vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents: 15285
diff changeset
2179 sh_a->wf->cbSize = track->private_size;
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
2180 sh_a->wf = realloc(sh_a->wf, sizeof(WAVEFORMATEX) + sh_a->wf->cbSize);
15420
f3cf481bbcda vorbis extradata is now passed from demuxer to decoder in matroska's way
nicodvb
parents: 15285
diff changeset
2181 memcpy((unsigned char *) (sh_a->wf+1), track->private_data, sh_a->wf->cbSize);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2182 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2183 else if (track->private_size >= sizeof(real_audio_v4_props_t)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2184 && !strncmp (track->codec_id, MKV_A_REALATRC, 7))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2185 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2186 /* Common initialization for all RealAudio codecs */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2187 real_audio_v4_props_t *ra4p;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2188 real_audio_v5_props_t *ra5p;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2189 unsigned char *src;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2190 int codecdata_length, version;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2191
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2192 ra4p = (real_audio_v4_props_t *) track->private_data;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2193 ra5p = (real_audio_v5_props_t *) track->private_data;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2194
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2195 sh_a->wf->nAvgBytesPerSec = 0; /* FIXME !? */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2196 sh_a->wf->nBlockAlign = be2me_16 (ra4p->frame_size);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2197
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2198 version = be2me_16 (ra4p->version1);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2199
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2200 if (version == 4)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2201 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2202 src = (unsigned char *) (ra4p + 1);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2203 src += src[0] + 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2204 src += src[0] + 1;
18036
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2205 track->sub_packet_size = be2me_16 (ra4p->sub_packet_size);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2206 track->sub_packet_h = be2me_16 (ra4p->sub_packet_h);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2207 track->coded_framesize = be2me_32 (ra4p->coded_frame_size);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2208 track->audiopk_size = be2me_16 (ra4p->frame_size);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2209 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2210 else
18036
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2211 {
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2212 src = (unsigned char *) (ra5p + 1);
18036
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2213 track->sub_packet_size = be2me_16 (ra5p->sub_packet_size);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2214 track->sub_packet_h = be2me_16 (ra5p->sub_packet_h);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2215 track->coded_framesize = be2me_32 (ra5p->coded_frame_size);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2216 track->audiopk_size = be2me_16 (ra5p->frame_size);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2217 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2218
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2219 src += 3;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2220 if (version == 5)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2221 src++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2222 codecdata_length = be2me_32 (*(uint32_t *)src);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2223 src += 4;
18036
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2224 sh_a->wf->cbSize = codecdata_length;
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
2225 sh_a->wf = realloc (sh_a->wf,
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
2226 sizeof (WAVEFORMATEX) +
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
2227 sh_a->wf->cbSize);
18036
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2228 memcpy(((char *)(sh_a->wf + 1)), src, codecdata_length);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2229
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2230 switch (track->a_formattag) {
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2231 case mmioFOURCC('a', 't', 'r', 'c'):
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2232 sh_a->wf->nAvgBytesPerSec = atrc_fl2bps[be2me_16 (ra4p->flavor)];
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2233 sh_a->wf->nBlockAlign = track->sub_packet_size;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2234 track->audio_buf = malloc(track->sub_packet_h * track->audiopk_size);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2235 track->audio_timestamp = malloc(track->sub_packet_h * sizeof(float));
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2236 break;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2237 case mmioFOURCC('c', 'o', 'o', 'k'):
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2238 sh_a->wf->nAvgBytesPerSec = cook_fl2bps[be2me_16 (ra4p->flavor)];
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2239 sh_a->wf->nBlockAlign = track->sub_packet_size;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2240 track->audio_buf = malloc(track->sub_packet_h * track->audiopk_size);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2241 track->audio_timestamp = malloc(track->sub_packet_h * sizeof(float));
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2242 break;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2243 case mmioFOURCC('s', 'i', 'p', 'r'):
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2244 sh_a->wf->nAvgBytesPerSec = sipr_fl2bps[be2me_16 (ra4p->flavor)];
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2245 sh_a->wf->nBlockAlign = track->coded_framesize;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2246 track->audio_buf = malloc(track->sub_packet_h * track->audiopk_size);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2247 track->audio_timestamp = malloc(track->sub_packet_h * sizeof(float));
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2248 break;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2249 case mmioFOURCC('2', '8', '_', '8'):
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2250 sh_a->wf->nAvgBytesPerSec = 3600;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2251 sh_a->wf->nBlockAlign = track->coded_framesize;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2252 track->audio_buf = malloc(track->sub_packet_h * track->audiopk_size);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2253 track->audio_timestamp = malloc(track->sub_packet_h * sizeof(float));
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2254 break;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2255 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2256
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2257 track->realmedia = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2258 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2259 else if (!strcmp(track->codec_id, MKV_A_FLAC) ||
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2260 (track->a_formattag == 0xf1ac))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2261 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2262 unsigned char *ptr;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2263 int size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2264 free(sh_a->wf);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2265 sh_a->wf = NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2266
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2267 if (track->a_formattag == mmioFOURCC('f', 'L', 'a', 'C'))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2268 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2269 ptr = (unsigned char *)track->private_data;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2270 size = track->private_size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2271 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2272 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2273 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2274 sh_a->format = mmioFOURCC('f', 'L', 'a', 'C');
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2275 ptr = (unsigned char *) track->private_data
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2276 + sizeof (WAVEFORMATEX);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2277 size = track->private_size - sizeof (WAVEFORMATEX);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2278 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2279 if (size < 4 || ptr[0] != 'f' || ptr[1] != 'L' ||
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2280 ptr[2] != 'a' || ptr[3] != 'C')
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2281 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2282 dp = new_demux_packet (4);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2283 memcpy (dp->buffer, "fLaC", 4);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2284 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2285 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2286 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2287 dp = new_demux_packet (size);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2288 memcpy (dp->buffer, ptr, size);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2289 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2290 dp->pts = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2291 dp->flags = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2292 ds_add_packet (demuxer->audio, dp);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2293 }
12101
d6ac3181fdca Fixed the support for the A_MS/ACM CodecID which just stores a WAVEFORMATEX in the track's private data.
mosu
parents: 12073
diff changeset
2294 else if (!track->ms_compat || (track->private_size < sizeof(WAVEFORMATEX)))
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2295 {
18708
9e2b300db17b Change free_sh_audio() to take demuxer and stream id as parameters
uau
parents: 18558
diff changeset
2296 free_sh_audio(demuxer, track->tnum);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2297 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2298 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2299
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2300 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2301 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2302
13126
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2303 /** \brief Parse the private data for VobSub subtitle tracks.
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2304
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2305 This function tries to parse the private data for all VobSub tracks.
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2306 The private data contains the normal text from the original .idx file.
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2307 Things like the palette, subtitle dimensions and custom colors are
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2308 stored here.
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2309
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2310 \param demuxer The generic demuxer.
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2311 */
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2312 static void
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2313 demux_mkv_parse_vobsub_data (demuxer_t *demuxer)
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2314 {
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2315 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2316 mkv_track_t *track;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2317 int i, m, size;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2318 uint8_t *buffer;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2319
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2320 for (i = 0; i < mkv_d->num_tracks; i++)
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2321 {
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2322 track = mkv_d->tracks[i];
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2323 if ((track->type != MATROSKA_TRACK_SUBTITLE) ||
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2324 (track->subtitle_type != MATROSKA_SUBTYPE_VOBSUB))
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2325 continue;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2326
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2327 size = track->private_size;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2328 m = demux_mkv_decode (track,track->private_data,&buffer,&size,2);
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2329 if (buffer && m)
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2330 {
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2331 free (track->private_data);
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2332 track->private_data = buffer;
18507
aca735a7f219 fix parsing of vobsub private data, patch by Evgeniy Stepanov <eugeni P stepanov A gmail P com>
gpoirier
parents: 18404
diff changeset
2333 track->private_size = size;
13126
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2334 }
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2335 if (!demux_mkv_parse_idx (track))
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2336 {
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2337 free (track->private_data);
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2338 track->private_data = NULL;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2339 track->private_size = 0;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2340 }
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2341 }
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2342 }
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2343
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2344 /** \brief Parse the private data for SSA/ASS subtitle tracks.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2345
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2346 This function tries to parse the private data for all SSA/ASS tracks.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2347 The private data contains the normal text from the original script,
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2348 from the start to the beginning of 'Events' section, including '[Events]' line.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2349
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2350 \param demuxer The generic demuxer.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2351 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2352 #ifdef USE_ASS
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2353 static void
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2354 demux_mkv_parse_ass_data (demuxer_t *demuxer)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2355 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2356 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2357 mkv_track_t *track;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2358 int i, m, size;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2359 uint8_t *buffer;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2360
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2361 for (i = 0; i < mkv_d->num_tracks; i++)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2362 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2363 track = mkv_d->tracks[i];
21609
3452c36a7fe2 VobSub tracks cannot be handled by libass, do not mark them with 'a'.
eugeni
parents: 21455
diff changeset
2364 if (track->type != MATROSKA_TRACK_SUBTITLE ||
3452c36a7fe2 VobSub tracks cannot be handled by libass, do not mark them with 'a'.
eugeni
parents: 21455
diff changeset
2365 track->subtitle_type == MATROSKA_SUBTYPE_VOBSUB)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2366 continue;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2367
19643
f48d49b400cf Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents: 19642
diff changeset
2368 if (track->subtitle_type == MATROSKA_SUBTYPE_SSA)
f48d49b400cf Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents: 19642
diff changeset
2369 {
21166
aaa43c5017fa Cosmetics: indentation fix.
eugeni
parents: 21038
diff changeset
2370 track->sh_sub.ass_track = ass_new_track(ass_library);
aaa43c5017fa Cosmetics: indentation fix.
eugeni
parents: 21038
diff changeset
2371 size = track->private_size;
aaa43c5017fa Cosmetics: indentation fix.
eugeni
parents: 21038
diff changeset
2372 m = demux_mkv_decode (track,track->private_data,&buffer,&size,2);
aaa43c5017fa Cosmetics: indentation fix.
eugeni
parents: 21038
diff changeset
2373 if (buffer && m)
aaa43c5017fa Cosmetics: indentation fix.
eugeni
parents: 21038
diff changeset
2374 {
aaa43c5017fa Cosmetics: indentation fix.
eugeni
parents: 21038
diff changeset
2375 free (track->private_data);
aaa43c5017fa Cosmetics: indentation fix.
eugeni
parents: 21038
diff changeset
2376 track->private_data = buffer;
aaa43c5017fa Cosmetics: indentation fix.
eugeni
parents: 21038
diff changeset
2377 track->private_size = size;
aaa43c5017fa Cosmetics: indentation fix.
eugeni
parents: 21038
diff changeset
2378 }
aaa43c5017fa Cosmetics: indentation fix.
eugeni
parents: 21038
diff changeset
2379 ass_process_codec_private(track->sh_sub.ass_track, track->private_data, track->private_size);
19643
f48d49b400cf Add support for rendering matroska plaintext subtitles with libass.
eugeni
parents: 19642
diff changeset
2380 }
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2381 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2382 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2383 #endif
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2384
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2385 static int
20872
a8b42366e68a Make subtitle stream handling more similar to audio and video streams.
reimar
parents: 20734
diff changeset
2386 demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track, int sid)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2387 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2388 if (track->subtitle_type != MATROSKA_SUBTYPE_UNKNOWN)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2389 {
20872
a8b42366e68a Make subtitle stream handling more similar to audio and video streams.
reimar
parents: 20734
diff changeset
2390 sh_sub_t *sh = new_sh_sub_sid(demuxer, track->tnum, sid);
22137
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2391 track->sh_sub.type = 't';
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2392 if (track->subtitle_type == MATROSKA_SUBTYPE_VOBSUB)
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2393 track->sh_sub.type = 'v';
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2394 if (track->subtitle_type == MATROSKA_SUBTYPE_SSA)
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2395 track->sh_sub.type = 'a';
20872
a8b42366e68a Make subtitle stream handling more similar to audio and video streams.
reimar
parents: 20734
diff changeset
2396 if (sh)
a8b42366e68a Make subtitle stream handling more similar to audio and video streams.
reimar
parents: 20734
diff changeset
2397 memcpy(sh, &track->sh_sub, sizeof(sh_sub_t));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2398 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2399 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2400 {
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2401 mp_msg (MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_MKV_SubtitleTypeNotSupported,
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2402 track->codec_id);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2403 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2404 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2405
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2406 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2407 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2408
17695
3f20b096782d Add audio_delay argument to demux_mkv_seek.
corey
parents: 17308
diff changeset
2409 static void demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2410
15285
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15154
diff changeset
2411 /** \brief Given a matroska track number and type, find the id that mplayer would ask for.
13501
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2412 * \param d The demuxer for which the subtitle id should be returned.
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2413 * \param num The matroska track number we are looking up.
15285
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15154
diff changeset
2414 * \param type The track type.
13501
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2415 */
15285
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15154
diff changeset
2416 static int demux_mkv_reverse_id(mkv_demuxer_t *d, int num, int type)
13501
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2417 {
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2418 int i, id;
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2419
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2420 for (i=0, id=0; i < d->num_tracks; i++)
15285
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15154
diff changeset
2421 if (d->tracks[i] != NULL && d->tracks[i]->type == type) {
13501
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2422 if (d->tracks[i]->tnum == num)
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2423 return id;
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2424 id++;
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2425 }
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2426
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2427 return -1;
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2428 }
a5004eb92a79 fix sub_select fiasco with global sub numbering. now multiple sub sources can be managed in essentially one list.
joey
parents: 13424
diff changeset
2429
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
2430 static int
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2431 demux_mkv_open (demuxer_t *demuxer)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2432 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2433 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2434 mkv_demuxer_t *mkv_d;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2435 mkv_track_t *track;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2436 int i, version, cont = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2437 char *str;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2438
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2439 stream_seek(s, s->start_pos);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2440 str = ebml_read_header (s, &version);
19977
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
2441 if (str == NULL || strcmp (str, "matroska") || version > 2)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2442 {
11856
rfelker
parents: 11832
diff changeset
2443 mp_msg (MSGT_DEMUX, MSGL_DBG2, "[mkv] no head found\n");
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2444 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2445 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2446 free (str);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2447
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2448 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] Found the head...\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2449
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2450 if (ebml_read_id (s, NULL) != MATROSKA_ID_SEGMENT)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2451 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2452 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] but no segment :(\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2453 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2454 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2455 ebml_read_length (s, NULL); /* return bytes number until EOF */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2456
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2457 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] + a segment...\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2458
20130
b5c68feff55c replace malloc+memset by calloc
reimar
parents: 20129
diff changeset
2459 mkv_d = calloc (1, sizeof (mkv_demuxer_t));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2460 demuxer->priv = mkv_d;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2461 mkv_d->tc_scale = 1000000;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2462 mkv_d->segment_start = stream_tell (s);
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
2463 mkv_d->parsed_cues = malloc (sizeof (off_t));
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
2464 mkv_d->parsed_seekhead = malloc (sizeof (off_t));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2465
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2466 while (!cont)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2467 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2468 switch (ebml_read_id (s, NULL))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2469 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2470 case MATROSKA_ID_INFO:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2471 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] |+ segment information...\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2472 cont = demux_mkv_read_info (demuxer);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2473 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2474
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2475 case MATROSKA_ID_TRACKS:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2476 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] |+ segment tracks...\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2477 cont = demux_mkv_read_tracks (demuxer);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2478 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2479
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2480 case MATROSKA_ID_CUES:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2481 cont = demux_mkv_read_cues (demuxer);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2482 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2483
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2484 case MATROSKA_ID_TAGS:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2485 cont = demux_mkv_read_tags (demuxer);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2486 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2487
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2488 case MATROSKA_ID_SEEKHEAD:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2489 cont = demux_mkv_read_seekhead (demuxer);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2490 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2491
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2492 case MATROSKA_ID_CHAPTERS:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2493 cont = demux_mkv_read_chapters (demuxer);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2494 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2495
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2496 case MATROSKA_ID_ATTACHMENTS:
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2497 cont = demux_mkv_read_attachments (demuxer);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2498 break;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2499
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2500 case MATROSKA_ID_CLUSTER:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2501 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2502 int p, l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2503 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] |+ found cluster, headers are "
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2504 "parsed completely :)\n");
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2505 /* get the first cluster timecode */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2506 p = stream_tell(s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2507 l = ebml_read_length (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2508 while (ebml_read_id (s, NULL) != MATROSKA_ID_CLUSTERTIMECODE)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2509 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2510 ebml_read_skip (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2511 if (stream_tell (s) >= p + l)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2512 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2513 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2514 if (stream_tell (s) < p + l)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2515 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2516 uint64_t num = ebml_read_uint (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2517 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2518 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2519 mkv_d->first_tc = num * mkv_d->tc_scale / 1000000.0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2520 mkv_d->has_first_tc = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2521 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2522 stream_seek (s, p - 4);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2523 cont = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2524 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2525 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2526
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2527 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2528 cont = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2529 case EBML_ID_VOID:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2530 ebml_read_skip (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2531 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2532 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2533 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2534
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
2535 display_create_tracks (demuxer);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2536
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2537 /* select video track */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2538 track = NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2539 if (demuxer->video->id == -1) /* automatically select a video track */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2540 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2541 /* search for a video track that has the 'default' flag set */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2542 for (i=0; i<mkv_d->num_tracks; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2543 if (mkv_d->tracks[i]->type == MATROSKA_TRACK_VIDEO
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2544 && mkv_d->tracks[i]->default_track)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2545 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2546 track = mkv_d->tracks[i];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2547 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2548 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2549
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2550 if (track == NULL)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2551 /* no track has the 'default' flag set */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2552 /* let's take the first video track */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2553 for (i=0; i<mkv_d->num_tracks; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2554 if (mkv_d->tracks[i]->type == MATROSKA_TRACK_VIDEO)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2555 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2556 track = mkv_d->tracks[i];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2557 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2558 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2559 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2560 else if (demuxer->video->id != -2) /* -2 = no video at all */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2561 track = demux_mkv_find_track_by_num (mkv_d, demuxer->video->id,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2562 MATROSKA_TRACK_VIDEO);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2563
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
2564 if (track && demuxer->v_streams[track->tnum])
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2565 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2566 mp_msg (MSGT_DEMUX, MSGL_INFO,
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2567 MSGTR_MPDEMUX_MKV_WillPlayVideoTrack, track->tnum);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2568 demuxer->video->id = track->tnum;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2569 demuxer->video->sh = demuxer->v_streams[track->tnum];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2570 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2571 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2572 {
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2573 mp_msg (MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_MKV_NoVideoTrackFound);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2574 demuxer->video->id = -2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2575 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2576
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2577 /* select audio track */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2578 track = NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2579 if (demuxer->audio->id == -1) /* automatically select an audio track */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2580 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2581 /* check if the user specified an audio language */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2582 if (audio_lang != NULL)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2583 track = demux_mkv_find_track_by_language(mkv_d, audio_lang,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2584 MATROSKA_TRACK_AUDIO);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2585 if (track == NULL)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2586 /* no audio language specified, or language not found */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2587 /* search for an audio track that has the 'default' flag set */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2588 for (i=0; i < mkv_d->num_tracks; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2589 if (mkv_d->tracks[i]->type == MATROSKA_TRACK_AUDIO
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2590 && mkv_d->tracks[i]->default_track)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2591 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2592 track = mkv_d->tracks[i];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2593 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2594 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2595
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2596 if (track == NULL)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2597 /* no track has the 'default' flag set */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2598 /* let's take the first audio track */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2599 for (i=0; i < mkv_d->num_tracks; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2600 if (mkv_d->tracks[i]->type == MATROSKA_TRACK_AUDIO)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2601 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2602 track = mkv_d->tracks[i];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2603 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2604 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2605 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2606 else if (demuxer->audio->id != -2) /* -2 = no audio at all */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2607 track = demux_mkv_find_track_by_num (mkv_d, demuxer->audio->id,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2608 MATROSKA_TRACK_AUDIO);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2609 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2610 {
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2611 mp_msg (MSGT_DEMUX, MSGL_INFO, MSGTR_MPDEMUX_MKV_NoAudioTrackFound);
11832
b9b330154ae1 Do not deactivate the video stream if no audio stream was wanted/found...
mosu
parents: 11815
diff changeset
2612 demuxer->audio->id = -2;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2613 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2614
18754
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2615
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2616 if(demuxer->audio->id != -2)
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2617 for (i=0; i < mkv_d->num_tracks; i++)
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2618 {
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2619 if(mkv_d->tracks[i]->type != MATROSKA_TRACK_AUDIO)
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2620 continue;
19540
70a5e89ea4cd Get rid of demux_aid_vid_mismatch mess.
reimar
parents: 19492
diff changeset
2621 if(demuxer->a_streams[track->tnum])
18754
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2622 {
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2623 if(track && mkv_d->tracks[i] == track)
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2624 {
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2625 demuxer->audio->id = track->tnum;
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2626 demuxer->audio->sh = demuxer->a_streams[track->tnum];
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2627 }
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2628 mkv_d->last_aid++;
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2629 if(mkv_d->last_aid == MAX_A_STREAMS)
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2630 break;
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2631 }
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2632 }
e0077bdf5ee5 feed any audio track present in the mux; switch to any of the available audio tracks
nicodvb
parents: 18708
diff changeset
2633
13126
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
2634 demux_mkv_parse_vobsub_data (demuxer);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2635 #ifdef USE_ASS
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2636 if (ass_enabled)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2637 demux_mkv_parse_ass_data (demuxer);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2638 #endif
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2639 /* DO NOT automatically select a subtitle track and behave like DVD */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2640 /* playback: only show subtitles if the user explicitely wants them. */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2641 track = NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2642 if (demuxer->sub->id >= 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2643 track = demux_mkv_find_track_by_num (mkv_d, demuxer->sub->id,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2644 MATROSKA_TRACK_SUBTITLE);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2645 else if (dvdsub_lang != NULL)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2646 track = demux_mkv_find_track_by_language (mkv_d, dvdsub_lang,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2647 MATROSKA_TRACK_SUBTITLE);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2648
20872
a8b42366e68a Make subtitle stream handling more similar to audio and video streams.
reimar
parents: 20734
diff changeset
2649 if (track)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2650 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2651 mp_msg (MSGT_DEMUX, MSGL_INFO,
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2652 MSGTR_MPDEMUX_MKV_WillDisplaySubtitleTrack, track->tnum);
15285
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15154
diff changeset
2653 dvdsub_id = demux_mkv_reverse_id(mkv_d, track->tnum, MATROSKA_TRACK_SUBTITLE);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2654 demuxer->sub->id = track->tnum;
22157
b6f01e891ba8 Make sure sub->sh is set when a subtitle is selected
reimar
parents: 22137
diff changeset
2655 if (demuxer->sub->sh == NULL)
b6f01e891ba8 Make sure sub->sh is set when a subtitle is selected
reimar
parents: 22137
diff changeset
2656 demuxer->sub->sh = malloc(sizeof(sh_sub_t));
b6f01e891ba8 Make sure sub->sh is set when a subtitle is selected
reimar
parents: 22137
diff changeset
2657 if (demuxer->sub->sh != NULL)
b6f01e891ba8 Make sure sub->sh is set when a subtitle is selected
reimar
parents: 22137
diff changeset
2658 memcpy(demuxer->sub->sh, &track->sh_sub, sizeof(sh_sub_t));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2659 }
11901
01bfcbd73986 Do not open more than one audio/video/subtitle stream at the same time.
mosu
parents: 11899
diff changeset
2660 else
01bfcbd73986 Do not open more than one audio/video/subtitle stream at the same time.
mosu
parents: 11899
diff changeset
2661 demuxer->sub->id = -2;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2662
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
2663 if (demuxer->chapters)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2664 {
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
2665 for (i=0; i < (int)demuxer->num_chapters; i++)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2666 {
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
2667 demuxer->chapters[i].start -= mkv_d->first_tc;
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
2668 demuxer->chapters[i].end -= mkv_d->first_tc;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2669 }
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
2670 if (dvd_last_chapter > 0 && dvd_last_chapter <= demuxer->num_chapters)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2671 {
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
2672 if (demuxer->chapters[dvd_last_chapter-1].end != 0)
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
2673 mkv_d->stop_timecode = demuxer->chapters[dvd_last_chapter-1].end;
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
2674 else if (dvd_last_chapter + 1 <= demuxer->num_chapters)
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
2675 mkv_d->stop_timecode = demuxer->chapters[dvd_last_chapter].start;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2676 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2677 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2678
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2679 if (s->end_pos == 0 || (mkv_d->indexes == NULL && index_mode < 0))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2680 demuxer->seekable = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2681 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2682 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2683 demuxer->movi_start = s->start_pos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2684 demuxer->movi_end = s->end_pos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2685 demuxer->seekable = 1;
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
2686 if (demuxer->chapters && dvd_chapter>1 && dvd_chapter<=demuxer->num_chapters)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2687 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2688 if (!mkv_d->has_first_tc)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2689 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2690 mkv_d->first_tc = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2691 mkv_d->has_first_tc = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2692 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2693 demux_mkv_seek (demuxer,
19342
4e68a3881201 Add matroska chapter seeking capability.
eugeni
parents: 19154
diff changeset
2694 demuxer->chapters[dvd_chapter-1].start/1000.0, 0.0, 1);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2695 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2696 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2697
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
2698 return DEMUXER_TYPE_MATROSKA;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2699 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2700
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
2701 static void
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2702 demux_close_mkv (demuxer_t *demuxer)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2703 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2704 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2705
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2706 if (mkv_d)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2707 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2708 int i;
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
2709 free_cached_dps (demuxer);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2710 if (mkv_d->tracks)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2711 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2712 for (i=0; i<mkv_d->num_tracks; i++)
20135
7079d029d27c Free track data if error occurs while reading trackentry
reimar
parents: 20133
diff changeset
2713 demux_mkv_free_trackentry(mkv_d->tracks[i]);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2714 free (mkv_d->tracks);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2715 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2716 if (mkv_d->indexes)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2717 free (mkv_d->indexes);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2718 if (mkv_d->cluster_positions)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2719 free (mkv_d->cluster_positions);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2720 if (mkv_d->parsed_cues)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2721 free (mkv_d->parsed_cues);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2722 if (mkv_d->parsed_seekhead)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2723 free (mkv_d->parsed_seekhead);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2724 if (mkv_d->attachments) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2725 for (i = 0; i < mkv_d->num_attachments; ++i) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2726 if (mkv_d->attachments[i].name)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2727 free (mkv_d->attachments[i].name);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2728 if (mkv_d->attachments[i].mime)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2729 free (mkv_d->attachments[i].mime);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2730 if (mkv_d->attachments[i].data)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2731 free (mkv_d->attachments[i].data);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2732 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2733 free (mkv_d->attachments);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2734 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2735 free (mkv_d);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2736 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2737 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2738
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2739 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2740 demux_mkv_read_block_lacing (uint8_t *buffer, uint64_t *size,
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
2741 uint8_t *laces, uint32_t **all_lace_sizes)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2742 {
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
2743 uint32_t total = 0, *lace_size;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2744 uint8_t flags;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2745 int i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2746
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
2747 *all_lace_sizes = NULL;
13131
ab937f4a17ad Cosmetics: fix some compiler warnings.
mosu
parents: 13129
diff changeset
2748 lace_size = NULL;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2749 /* lacing flags */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2750 flags = *buffer++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2751 (*size)--;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2752
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2753 switch ((flags & 0x06) >> 1)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2754 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2755 case 0: /* no lacing */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2756 *laces = 1;
18885
5c8acc972551 rm unnecesary casts from void* - part 4
reynaldo
parents: 18754
diff changeset
2757 lace_size = calloc(*laces, sizeof(uint32_t));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2758 lace_size[0] = *size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2759 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2760
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2761 case 1: /* xiph lacing */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2762 case 2: /* fixed-size lacing */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2763 case 3: /* EBML lacing */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2764 *laces = *buffer++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2765 (*size)--;
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
2766 (*laces)++;
18885
5c8acc972551 rm unnecesary casts from void* - part 4
reynaldo
parents: 18754
diff changeset
2767 lace_size = calloc(*laces, sizeof(uint32_t));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2768
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2769 switch ((flags & 0x06) >> 1)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2770 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2771 case 1: /* xiph lacing */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2772 for (i=0; i < *laces-1; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2773 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2774 lace_size[i] = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2775 do
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2776 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2777 lace_size[i] += *buffer;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2778 (*size)--;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2779 } while (*buffer++ == 0xFF);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2780 total += lace_size[i];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2781 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2782 lace_size[i] = *size - total;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2783 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2784
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2785 case 2: /* fixed-size lacing */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2786 for (i=0; i < *laces; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2787 lace_size[i] = *size / *laces;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2788 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2789
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2790 case 3: /* EBML lacing */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2791 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2792 int l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2793 uint64_t num = ebml_read_vlen_uint (buffer, &l);
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
2794 if (num == EBML_UINT_INVALID) {
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
2795 free(lace_size);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2796 return 1;
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
2797 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2798 buffer += l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2799 *size -= l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2800
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2801 total = lace_size[0] = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2802 for (i=1; i < *laces-1; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2803 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2804 int64_t snum;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2805 snum = ebml_read_vlen_int (buffer, &l);
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
2806 if (snum == EBML_INT_INVALID) {
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
2807 free(lace_size);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2808 return 1;
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
2809 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2810 buffer += l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2811 *size -= l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2812 lace_size[i] = lace_size[i-1] + snum;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2813 total += lace_size[i];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2814 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2815 lace_size[i] = *size - total;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2816 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2817 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2818 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2819 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2820 }
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
2821 *all_lace_sizes = lace_size;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2822 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2823 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2824
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2825 static void
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2826 handle_subtitles(demuxer_t *demuxer, mkv_track_t *track, char *block,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2827 int64_t size, uint64_t block_duration, uint64_t timecode)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2828 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2829 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
22137
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2830 demux_packet_t *dp;
21827
b0bc0d81f91b Subtitle handling cleanup: factor out code for parsing embedded subtitles
reimar
parents: 21704
diff changeset
2831 char *ptr1;
b0bc0d81f91b Subtitle handling cleanup: factor out code for parsing embedded subtitles
reimar
parents: 21704
diff changeset
2832 int i;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2833
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2834 if (block_duration == 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2835 {
20680
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2836 mp_msg (MSGT_DEMUX, MSGL_WARN,
d1a5b0ebf56f add MSGTR_MPDEMUX_MKV for demux_mkv.c
kraymer
parents: 20477
diff changeset
2837 MSGTR_MPDEMUX_MKV_NoBlockDurationForSubtitleTrackFound);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2838 return;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2839 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2840
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2841 #ifdef USE_ASS
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2842 if (ass_enabled && track->subtitle_type == MATROSKA_SUBTYPE_SSA) {
19492
c8daf3471201 SSA/ASS parser reworked, with 2 main results:
eugeni
parents: 19430
diff changeset
2843 ass_process_chunk(track->sh_sub.ass_track, block, size, (long long)timecode, (long long)block_duration);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2844 return;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2845 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2846 #endif
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents: 18934
diff changeset
2847
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2848 ptr1 = block;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2849 if (track->subtitle_type == MATROSKA_SUBTYPE_SSA)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2850 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2851 /* Find text section. */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2852 for (i=0; i < 8 && *ptr1 != '\0'; ptr1++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2853 if (*ptr1 == ',')
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2854 i++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2855 if (*ptr1 == '\0') /* Broken line? */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2856 return;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2857 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2858
14513
b712f8437a08 set sub_utf8 only when actually using mkv subtitles, will break external
reimar
parents: 14502
diff changeset
2859 sub_utf8 = 1;
22137
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2860 size -= ptr1 - block;
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2861 dp = new_demux_packet(size);
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2862 memcpy(dp->buffer, ptr1, size);
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2863 dp->pts = timecode / 1000.0f;
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2864 dp->endpts = (timecode + block_duration) / 1000.0f;
3d415b28e5e4 Another round of subtitle code cleanup
reimar
parents: 22081
diff changeset
2865 ds_add_packet(demuxer->sub, dp);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2866 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2867
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2868 // Taken from demux_real.c. Thanks to the original developpers :)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2869 #define SKIP_BITS(n) buffer <<= n
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2870 #define SHOW_BITS(n) ((buffer) >> (32 - (n)))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2871
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2872 static float real_fix_timestamp(mkv_track_t *track, unsigned char *s,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2873 int timestamp) {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2874 float v_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2875 uint32_t buffer = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2876 int kf = timestamp;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2877 int pict_type;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2878 int orig_kf;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2879
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2880 if (!strcmp(track->codec_id, MKV_V_REALV30) ||
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2881 !strcmp(track->codec_id, MKV_V_REALV40)) {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2882
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2883 if (!strcmp(track->codec_id, MKV_V_REALV30)) {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2884 SKIP_BITS(3);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2885 pict_type = SHOW_BITS(2);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2886 SKIP_BITS(2 + 7);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2887 }else{
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2888 SKIP_BITS(1);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2889 pict_type = SHOW_BITS(2);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2890 SKIP_BITS(2 + 7 + 3);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2891 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2892 kf = SHOW_BITS(13); // kf= 2*SHOW_BITS(12);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2893 orig_kf = kf;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2894 if (pict_type <= 1) {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2895 // I frame, sync timestamps:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2896 track->rv_kf_base = timestamp - kf;
20921
b22dfe3ddfaa Don't spam the console with timestamps (non-error messages printed every
rtogni
parents: 20920
diff changeset
2897 mp_msg(MSGT_DEMUX, MSGL_DBG2, "\nTS: base=%08X\n", track->rv_kf_base);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2898 kf = timestamp;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2899 } else {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2900 // P/B frame, merge timestamps:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2901 int tmp = timestamp - track->rv_kf_base;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2902 kf |= tmp & (~0x1fff); // combine with packet timestamp
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2903 if (kf < (tmp - 4096)) // workaround wrap-around problems
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2904 kf += 8192;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2905 else if (kf > (tmp + 4096))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2906 kf -= 8192;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2907 kf += track->rv_kf_base;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2908 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2909 if (pict_type != 3) { // P || I frame -> swap timestamps
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2910 int tmp = kf;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2911 kf = track->rv_kf_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2912 track->rv_kf_pts = tmp;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2913 }
20921
b22dfe3ddfaa Don't spam the console with timestamps (non-error messages printed every
rtogni
parents: 20920
diff changeset
2914 mp_msg(MSGT_DEMUX, MSGL_DBG2, "\nTS: %08X -> %08X (%04X) %d %02X %02X %02X "
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2915 "%02X %5d\n", timestamp, kf, orig_kf, pict_type, s[0], s[1], s[2],
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2916 s[3], kf - (int)(1000.0 * track->rv_pts));
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2917 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2918 v_pts = kf * 0.001f;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2919 track->rv_pts = v_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2920
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2921 return v_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2922 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2923
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2924 static void
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2925 handle_realvideo (demuxer_t *demuxer, mkv_track_t *track, uint8_t *buffer,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2926 uint32_t size, int block_bref)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2927 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2928 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2929 demux_packet_t *dp;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2930 dp_hdr_t *hdr;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2931 uint8_t chunks;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2932 int isize;
17923
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2933 #ifdef WORDS_BIGENDIAN
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2934 uint8_t *p;
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2935 int i;
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2936 #endif
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2937
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2938 chunks = *buffer++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2939 isize = --size - (chunks+1)*8;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2940 dp = new_demux_packet (sizeof (*hdr) + size);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2941 memcpy (dp->buffer + sizeof(*hdr), buffer + (chunks+1)*8, isize);
17923
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2942 #ifdef WORDS_BIGENDIAN
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2943 p = (uint8_t *)(dp->buffer + sizeof(*hdr) + isize);
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2944 for (i = 0; i<(chunks+1)*8; i+=4) {
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2945 p[i] = *((uint8_t *)buffer+i+3);
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2946 p[i+1] = *((uint8_t *)buffer+i+2);
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2947 p[i+2] = *((uint8_t *)buffer+i+1);
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2948 p[i+3] = *((uint8_t *)buffer+i);
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2949 }
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2950 #else
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2951 memcpy (dp->buffer + sizeof(*hdr) + isize, buffer, (chunks+1)*8);
17923
ad7675dee42c Fix for playing RealVideo on PPC/big endian processors. Patch by Emanuele Giaquinta (emanuele ! giaquinta () gmail ! com).
mosu
parents: 17695
diff changeset
2952 #endif
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2953
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2954 hdr = (dp_hdr_t *) dp->buffer;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2955 hdr->len = isize;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2956 hdr->chunks = chunks;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2957 hdr->timestamp = mkv_d->last_pts * 1000;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2958 hdr->chunktab = sizeof(*hdr) + isize;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2959
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2960 dp->len = sizeof(*hdr) + size;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2961 if (mkv_d->v_skip_to_keyframe)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2962 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2963 dp->pts = mkv_d->last_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2964 track->rv_kf_base = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2965 track->rv_kf_pts = hdr->timestamp;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2966 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2967 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2968 dp->pts = real_fix_timestamp (track, dp->buffer + sizeof(*hdr),
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2969 hdr->timestamp);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2970 dp->pos = demuxer->filepos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2971 dp->flags = block_bref ? 0 : 0x10;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2972
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2973 ds_add_packet(demuxer->video, dp);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2974 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2975
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2976 static void
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2977 handle_realaudio (demuxer_t *demuxer, mkv_track_t *track, uint8_t *buffer,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2978 uint32_t size, int block_bref)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2979 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
2980 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
18036
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2981 int sps = track->sub_packet_size;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2982 int sph = track->sub_packet_h;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2983 int cfs = track->coded_framesize;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2984 int w = track->audiopk_size;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2985 int spc = track->sub_packet_cnt;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2986 demux_packet_t *dp;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2987 int x;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2988
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2989 if ((track->a_formattag == mmioFOURCC('2', '8', '_', '8')) ||
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2990 (track->a_formattag == mmioFOURCC('c', 'o', 'o', 'k')) ||
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2991 (track->a_formattag == mmioFOURCC('a', 't', 'r', 'c')) ||
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2992 (track->a_formattag == mmioFOURCC('s', 'i', 'p', 'r')))
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2993 {
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2994 // if(!block_bref)
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2995 // spc = track->sub_packet_cnt = 0;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2996 switch (track->a_formattag) {
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2997 case mmioFOURCC('2', '8', '_', '8'):
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2998 for (x = 0; x < sph / 2; x++)
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
2999 memcpy(track->audio_buf + x * 2 * w + spc * cfs, buffer + cfs * x, cfs);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3000 break;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3001 case mmioFOURCC('c', 'o', 'o', 'k'):
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3002 case mmioFOURCC('a', 't', 'r', 'c'):
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3003 for (x = 0; x < w / sps; x++)
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3004 memcpy(track->audio_buf + sps * (sph * x + ((sph + 1) / 2) * (spc & 1) + (spc >> 1)), buffer + sps * x, sps);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3005 break;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3006 case mmioFOURCC('s', 'i', 'p', 'r'):
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3007 memcpy(track->audio_buf + spc * w, buffer, w);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3008 if (spc == sph - 1)
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3009 {
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3010 int n;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3011 int bs = sph * w * 2 / 96; // nibbles per subpacket
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3012 // Perform reordering
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3013 for(n=0; n < 38; n++)
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3014 {
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3015 int j;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3016 int i = bs * sipr_swaps[n][0];
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3017 int o = bs * sipr_swaps[n][1];
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3018 // swap nibbles of block 'i' with 'o' TODO: optimize
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3019 for(j = 0;j < bs; j++)
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3020 {
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3021 int x = (i & 1) ? (track->audio_buf[i >> 1] >> 4) : (track->audio_buf[i >> 1] & 0x0F);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3022 int y = (o & 1) ? (track->audio_buf[o >> 1] >> 4) : (track->audio_buf[o >> 1] & 0x0F);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3023 if(o & 1)
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3024 track->audio_buf[o >> 1] = (track->audio_buf[o >> 1] & 0x0F) | (x << 4);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3025 else
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3026 track->audio_buf[o >> 1] = (track->audio_buf[o >> 1] & 0xF0) | x;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3027 if(i & 1)
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3028 track->audio_buf[i >> 1] = (track->audio_buf[i >> 1] & 0x0F) | (y << 4);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3029 else
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3030 track->audio_buf[i >> 1] = (track->audio_buf[i >> 1] & 0xF0) | y;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3031 ++i; ++o;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3032 }
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3033 }
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3034 }
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3035 break;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3036 }
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3037 track->audio_timestamp[track->sub_packet_cnt] = (track->ra_pts == mkv_d->last_pts) ? 0 : (mkv_d->last_pts);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3038 track->ra_pts = mkv_d->last_pts;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3039 if (track->sub_packet_cnt == 0)
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3040 track->audio_filepos = demuxer->filepos;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3041 if (++(track->sub_packet_cnt) == sph)
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3042 {
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3043 int apk_usize = ((WAVEFORMATEX*)((sh_audio_t*)demuxer->audio->sh)->wf)->nBlockAlign;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3044 track->sub_packet_cnt = 0;
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3045 // Release all the audio packets
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3046 for (x = 0; x < sph*w/apk_usize; x++)
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3047 {
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3048 dp = new_demux_packet(apk_usize);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3049 memcpy(dp->buffer, track->audio_buf + x * apk_usize, apk_usize);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3050 /* Put timestamp only on packets that correspond to original audio packets in file */
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3051 dp->pts = (x * apk_usize % w) ? 0 : track->audio_timestamp[x * apk_usize / w];
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3052 dp->pos = track->audio_filepos; // all equal
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3053 dp->flags = x ? 0 : 0x10; // Mark first packet as keyframe
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3054 ds_add_packet(demuxer->audio, dp);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3055 }
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3056 }
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3057 } else { // Not a codec that require reordering
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3058 dp = new_demux_packet (size);
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3059 memcpy(dp->buffer, buffer, size);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3060 if (track->ra_pts == mkv_d->last_pts && !mkv_d->a_skip_to_keyframe)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3061 dp->pts = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3062 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3063 dp->pts = mkv_d->last_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3064 track->ra_pts = mkv_d->last_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3065
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3066 dp->pos = demuxer->filepos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3067 dp->flags = block_bref ? 0 : 0x10;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3068 ds_add_packet (demuxer->audio, dp);
18036
3406a28698cf Fix RealAudio codecs (add descrambling)
rtognimp
parents: 17923
diff changeset
3069 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3070 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3071
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3072 /** Reorder timecodes and add cached demux packets to the queues.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3073 *
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3074 * Timecode reordering is needed if a video track contains B frames that
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3075 * are timestamped in display order (e.g. MPEG-1, MPEG-2 or "native" MPEG-4).
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3076 * MPlayer doesn't like timestamps in display order. This function adjusts
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3077 * the timestamp of cached frames (which are exactly one I/P frame followed
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3078 * by one or more B frames) so that they are in coding order again.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3079 *
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3080 * Example: The track with 25 FPS contains four frames with the timecodes
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3081 * I at 0ms, P at 120ms, B at 40ms and B at 80ms. As soon as the next I
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3082 * or P frame arrives these timecodes can be changed to I at 0ms, P at 40ms,
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3083 * B at 80ms and B at 120ms.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3084 *
16912
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3085 * This works for simple H.264 B-frame pyramids, but not for arbitrary orders.
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3086 *
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3087 * \param demuxer The Matroska demuxer struct for this instance.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3088 * \param track The track structure whose cache should be handled.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3089 */
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3090 static void
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3091 flush_cached_dps (demuxer_t *demuxer, mkv_track_t *track)
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3092 {
16912
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3093 int i, ok;
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3094
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3095 if (track->num_cached_dps == 0)
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3096 return;
16912
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3097
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3098 do {
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3099 ok = 1;
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3100 for (i = 1; i < track->num_cached_dps; i++)
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3101 if (track->cached_dps[i - 1]->pts > track->cached_dps[i]->pts) {
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3102 float tmp_pts = track->cached_dps[i - 1]->pts;
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3103 track->cached_dps[i - 1]->pts = track->cached_dps[i]->pts;
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3104 track->cached_dps[i]->pts = tmp_pts;
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3105 ok = 0;
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3106 }
4dea8b8f3b65 sort timestamps instead of assuming conventional B-frame order. (fixes x264 B-pyramid)
lorenm
parents: 16877
diff changeset
3107 } while (!ok);
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3108
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3109 for (i = 0; i < track->num_cached_dps; i++)
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3110 ds_add_packet (demuxer->video, track->cached_dps[i]);
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3111 track->num_cached_dps = 0;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3112 }
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3113
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3114 /** Cache video frames if timecodes have to be reordered.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3115 *
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3116 * Timecode reordering is needed if a video track contains B frames that
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3117 * are timestamped in display order (e.g. MPEG-1, MPEG-2 or "native" MPEG-4).
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3118 * This function takes in a Matroska block read from the file, allocates a
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3119 * demux packet for it, fills in its values, allocates space for storing
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3120 * pointers to the cached demux packets and adds the packet to it. If
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3121 * the packet contains an I or a P frame then ::flush_cached_dps is called
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3122 * in order to send the old cached frames downstream.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3123 *
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3124 * \param demuxer The Matroska demuxer struct for this instance.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3125 * \param track The packet is meant for this track.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3126 * \param buffer The actual frame contents.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3127 * \param size The frame size in bytes.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3128 * \param block_bref A relative timecode (backward reference). If it is \c 0
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3129 * then the frame is an I frame.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3130 * \param block_fref A relative timecode (forward reference). If it is \c 0
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3131 * then the frame is either an I frame or a P frame depending on the value
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3132 * of \a block_bref. Otherwise it's a B frame.
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3133 */
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3134 static void
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3135 handle_video_bframes (demuxer_t *demuxer, mkv_track_t *track, uint8_t *buffer,
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3136 uint32_t size, int block_bref, int block_fref)
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3137 {
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3138 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3139 demux_packet_t *dp;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3140
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3141 dp = new_demux_packet (size);
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3142 memcpy(dp->buffer, buffer, size);
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3143 dp->pos = demuxer->filepos;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3144 dp->pts = mkv_d->last_pts;
14515
35a6c4db00ae More support for AVC in Matroska.
mosu
parents: 14513
diff changeset
3145 if ((track->num_cached_dps > 0) && (dp->pts < track->max_pts))
35a6c4db00ae More support for AVC in Matroska.
mosu
parents: 14513
diff changeset
3146 block_fref = 1;
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3147 if (block_fref == 0) /* I or P frame */
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3148 flush_cached_dps (demuxer, track);
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3149 if (block_bref != 0) /* I frame, don't cache it */
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3150 dp->flags = 0x10;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3151 if ((track->num_cached_dps + 1) > track->num_allocated_dps)
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3152 {
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3153 track->cached_dps = (demux_packet_t **)
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3154 realloc(track->cached_dps, (track->num_cached_dps + 10) *
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3155 sizeof(demux_packet_t *));
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3156 track->num_allocated_dps += 10;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3157 }
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3158 track->cached_dps[track->num_cached_dps] = dp;
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3159 track->num_cached_dps++;
14515
35a6c4db00ae More support for AVC in Matroska.
mosu
parents: 14513
diff changeset
3160 if (dp->pts > track->max_pts)
35a6c4db00ae More support for AVC in Matroska.
mosu
parents: 14513
diff changeset
3161 track->max_pts = dp->pts;
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3162 }
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3163
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3164 static int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3165 handle_block (demuxer_t *demuxer, uint8_t *block, uint64_t length,
19977
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3166 uint64_t block_duration, int64_t block_bref, int64_t block_fref, uint8_t simpleblock)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3167 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3168 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3169 mkv_track_t *track = NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3170 demux_stream_t *ds = NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3171 uint64_t old_length;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3172 int64_t tc;
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
3173 uint32_t *lace_size;
19977
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3174 uint8_t laces, flags;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3175 int i, num, tmp, use_this_block = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3176 float current_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3177 int16_t time;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3178
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3179 /* first byte(s): track num */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3180 num = ebml_read_vlen_uint (block, &tmp);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3181 block += tmp;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3182 /* time (relative to cluster time) */
14489
ca9e98e6c10b Do not access word-sized elements on potentially unaligned memory addresses. RISC processors usually do not like that.
mosu
parents: 14461
diff changeset
3183 time = block[0] << 8 | block[1];
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3184 block += 2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3185 length -= tmp + 2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3186 old_length = length;
19977
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3187 flags = block[0];
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
3188 if (demux_mkv_read_block_lacing (block, &length, &laces, &lace_size))
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
3189 return 0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3190 block += old_length - length;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3191
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3192 tc = ((time*mkv_d->tc_scale+mkv_d->cluster_tc) /1000000.0 - mkv_d->first_tc);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3193 if (tc < 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3194 tc = 0;
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
3195 if (mkv_d->stop_timecode > 0 && tc > mkv_d->stop_timecode) {
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
3196 free(lace_size);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3197 return -1;
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
3198 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3199 current_pts = tc / 1000.0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3200
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3201 for (i=0; i<mkv_d->num_tracks; i++)
12721
44895a7161c8 Do not dereference NULL if no track could be found for a block.
mosu
parents: 12550
diff changeset
3202 if (mkv_d->tracks[i]->tnum == num) {
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3203 track = mkv_d->tracks[i];
12721
44895a7161c8 Do not dereference NULL if no track could be found for a block.
mosu
parents: 12550
diff changeset
3204 break;
44895a7161c8 Do not dereference NULL if no track could be found for a block.
mosu
parents: 12550
diff changeset
3205 }
44895a7161c8 Do not dereference NULL if no track could be found for a block.
mosu
parents: 12550
diff changeset
3206 if (track == NULL)
44895a7161c8 Do not dereference NULL if no track could be found for a block.
mosu
parents: 12550
diff changeset
3207 {
44895a7161c8 Do not dereference NULL if no track could be found for a block.
mosu
parents: 12550
diff changeset
3208 free(lace_size);
44895a7161c8 Do not dereference NULL if no track could be found for a block.
mosu
parents: 12550
diff changeset
3209 return 1;
44895a7161c8 Do not dereference NULL if no track could be found for a block.
mosu
parents: 12550
diff changeset
3210 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3211 if (num == demuxer->audio->id)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3212 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3213 ds = demuxer->audio;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3214
19977
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3215 if (mkv_d->a_skip_to_keyframe)
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3216 {
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3217 if (simpleblock)
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3218 {
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3219 if (!(flags&0x80)) /*current frame isn't a keyframe*/
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3220 use_this_block = 0;
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3221 }
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3222 else if (block_bref != 0)
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3223 use_this_block = 0;
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3224 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3225 else if (mkv_d->v_skip_to_keyframe)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3226 use_this_block = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3227
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3228 if (track->fix_i_bps && use_this_block)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3229 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3230 sh_audio_t *sh = (sh_audio_t *) ds->sh;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3231
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3232 if (block_duration != 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3233 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3234 sh->i_bps = length * 1000 / block_duration;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3235 track->fix_i_bps = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3236 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3237 else if (track->qt_last_a_pts == 0.0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3238 track->qt_last_a_pts = current_pts;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3239 else if(track->qt_last_a_pts != current_pts)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3240 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3241 sh->i_bps = length / (current_pts - track->qt_last_a_pts);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3242 track->fix_i_bps = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3243 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3244 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3245 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3246 else if (tc < mkv_d->skip_to_timecode)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3247 use_this_block = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3248 else if (num == demuxer->video->id)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3249 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3250 ds = demuxer->video;
19977
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3251 if (mkv_d->v_skip_to_keyframe)
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3252 {
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3253 if (simpleblock)
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3254 {
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3255 if (!(flags&0x80)) /*current frame isn't a keyframe*/
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3256 use_this_block = 0;
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3257 }
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3258 else if (block_bref != 0 || block_fref != 0)
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3259 use_this_block = 0;
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3260 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3261 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3262 else if (num == demuxer->sub->id)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3263 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3264 ds = demuxer->sub;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3265 if (track->subtitle_type != MATROSKA_SUBTYPE_VOBSUB)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3266 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3267 if (!mkv_d->v_skip_to_keyframe)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3268 handle_subtitles (demuxer, track, block, length,
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3269 block_duration, tc);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3270 use_this_block = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3271 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3272 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3273 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3274 use_this_block = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3275
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3276 if (use_this_block)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3277 {
15701
8816b33b8948 demux_stream_t.pts should not be assigned by the demuxer. Fixes playback of VFR files. Patch by Sam Dennis <sam () malfunction ! screaming ! net>
mosu
parents: 15533
diff changeset
3278 mkv_d->last_pts = current_pts;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3279 mkv_d->last_filepos = demuxer->filepos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3280
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3281 for (i=0; i < laces; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3282 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3283 if (ds == demuxer->video && track->realmedia)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3284 handle_realvideo (demuxer, track, block, lace_size[i], block_bref);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3285 else if (ds == demuxer->audio && track->realmedia)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3286 handle_realaudio (demuxer, track, block, lace_size[i], block_bref);
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3287 else if (ds == demuxer->video && track->reorder_timecodes)
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3288 handle_video_bframes (demuxer, track, block, lace_size[i],
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3289 block_bref, block_fref);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3290 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3291 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3292 int modified, size = lace_size[i];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3293 demux_packet_t *dp;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3294 uint8_t *buffer;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3295 modified = demux_mkv_decode (track, block, &buffer, &size, 1);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3296 if (buffer)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3297 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3298 dp = new_demux_packet (size);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3299 memcpy (dp->buffer, buffer, size);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3300 if (modified)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3301 free (buffer);
18096
f92a441c0442 10l, keyframes must have tag 0x10, not 1.
reimar
parents: 18036
diff changeset
3302 dp->flags = (block_bref == 0 && block_fref == 0) ? 0x10 : 0;
18236
d239a79a0002 Do not give bogus timestamps for laced packets with no default duration. Patch by Uoti Urpala ( uoti ! urpala () pp1 ! inet ! fi ).
mosu
parents: 18096
diff changeset
3303 /* If default_duration is 0, assume no pts value is known
d239a79a0002 Do not give bogus timestamps for laced packets with no default duration. Patch by Uoti Urpala ( uoti ! urpala () pp1 ! inet ! fi ).
mosu
parents: 18096
diff changeset
3304 * for packets after the first one (rather than all pts
d239a79a0002 Do not give bogus timestamps for laced packets with no default duration. Patch by Uoti Urpala ( uoti ! urpala () pp1 ! inet ! fi ).
mosu
parents: 18096
diff changeset
3305 * values being the same) */
d239a79a0002 Do not give bogus timestamps for laced packets with no default duration. Patch by Uoti Urpala ( uoti ! urpala () pp1 ! inet ! fi ).
mosu
parents: 18096
diff changeset
3306 if (i == 0 || track->default_duration)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3307 dp->pts = mkv_d->last_pts + i * track->default_duration;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3308 ds_add_packet (ds, dp);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3309 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3310 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3311 block += lace_size[i];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3312 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3313
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3314 if (ds == demuxer->video)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3315 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3316 mkv_d->v_skip_to_keyframe = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3317 mkv_d->skip_to_timecode = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3318 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3319 else if (ds == demuxer->audio)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3320 mkv_d->a_skip_to_keyframe = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3321
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
3322 free(lace_size);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3323 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3324 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3325
12065
cabb28717cd6 Removed the limitation to max. eight laced blocks.
mosu
parents: 12041
diff changeset
3326 free(lace_size);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3327 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3328 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3329
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3330 static int
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3331 demux_mkv_fill_buffer (demuxer_t *demuxer, demux_stream_t *ds)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3332 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3333 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3334 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3335 uint64_t l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3336 int il, tmp;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3337
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3338 while (1)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3339 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3340 while (mkv_d->cluster_size > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3341 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3342 uint64_t block_duration = 0, block_length = 0;
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3343 int64_t block_bref = 0, block_fref = 0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3344 uint8_t *block = NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3345
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3346 while (mkv_d->blockgroup_size > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3347 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3348 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3349 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3350 case MATROSKA_ID_BLOCKDURATION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3351 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3352 block_duration = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3353 if (block_duration == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3354 return 0;
19810
7dfc3d2bb54b Fix block duration calculation in mkv demuxer.
eugeni
parents: 19809
diff changeset
3355 block_duration *= mkv_d->tc_scale / 1000000.0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3356 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3357 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3358
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3359 case MATROSKA_ID_BLOCK:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3360 block_length = ebml_read_length (s, &tmp);
20155
c903e0d80f02 More possible memleaks.
reimar
parents: 20154
diff changeset
3361 free(block);
22081
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
3362 if (block_length > SIZE_MAX - LZO_INPUT_PADDING) return 0;
fde1ddcc04c7 Make mkv demuxer use ffmpeg LZO as well.
reimar
parents: 22011
diff changeset
3363 block = malloc (block_length + LZO_INPUT_PADDING);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3364 demuxer->filepos = stream_tell (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3365 if (stream_read (s,block,block_length) != (int) block_length)
20155
c903e0d80f02 More possible memleaks.
reimar
parents: 20154
diff changeset
3366 {
c903e0d80f02 More possible memleaks.
reimar
parents: 20154
diff changeset
3367 free(block);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3368 return 0;
20155
c903e0d80f02 More possible memleaks.
reimar
parents: 20154
diff changeset
3369 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3370 l = tmp + block_length;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3371 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3372
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3373 case MATROSKA_ID_REFERENCEBLOCK:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3374 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3375 int64_t num = ebml_read_int (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3376 if (num == EBML_INT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3377 return 0;
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3378 if (num <= 0)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3379 block_bref = num;
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3380 else
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3381 block_fref = num;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3382 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3383 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3384
11934
bef061911390 Exit when an invalid EBML ID has been read (e.g. for files that have been cut off).
mosu
parents: 11901
diff changeset
3385 case EBML_ID_INVALID:
bef061911390 Exit when an invalid EBML ID has been read (e.g. for files that have been cut off).
mosu
parents: 11901
diff changeset
3386 return 0;
bef061911390 Exit when an invalid EBML ID has been read (e.g. for files that have been cut off).
mosu
parents: 11901
diff changeset
3387
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3388 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3389 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3390 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3391 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3392 mkv_d->blockgroup_size -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3393 mkv_d->cluster_size -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3394 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3395
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3396 if (block)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3397 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3398 int res = handle_block (demuxer, block, block_length,
19977
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3399 block_duration, block_bref, block_fref, 0);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3400 free (block);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3401 if (res < 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3402 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3403 if (res)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3404 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3405 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3406
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3407 if (mkv_d->cluster_size > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3408 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3409 switch (ebml_read_id (s, &il))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3410 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3411 case MATROSKA_ID_CLUSTERTIMECODE:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3412 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3413 uint64_t num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3414 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3415 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3416 if (!mkv_d->has_first_tc)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3417 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3418 mkv_d->first_tc = num * mkv_d->tc_scale / 1000000.0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3419 mkv_d->has_first_tc = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3420 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3421 mkv_d->cluster_tc = num * mkv_d->tc_scale;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3422 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3423 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3424
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3425 case MATROSKA_ID_BLOCKGROUP:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3426 mkv_d->blockgroup_size = ebml_read_length (s, &tmp);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3427 l = tmp;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3428 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3429
19977
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3430 case MATROSKA_ID_SIMPLEBLOCK:
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3431 {
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3432 int res;
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3433 block_length = ebml_read_length (s, &tmp);
20128
47c45cd077d4 Remove unneeded casts for malloc/realloc calls
reimar
parents: 19977
diff changeset
3434 block = malloc (block_length);
19977
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3435 demuxer->filepos = stream_tell (s);
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3436 if (stream_read (s,block,block_length) != (int) block_length)
20155
c903e0d80f02 More possible memleaks.
reimar
parents: 20154
diff changeset
3437 {
c903e0d80f02 More possible memleaks.
reimar
parents: 20154
diff changeset
3438 free(block);
19977
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3439 return 0;
20155
c903e0d80f02 More possible memleaks.
reimar
parents: 20154
diff changeset
3440 }
19977
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3441 l = tmp + block_length;
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3442 res = handle_block (demuxer, block, block_length,
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3443 block_duration, block_bref, block_fref, 1);
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3444 free (block);
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3445 mkv_d->cluster_size -= l + il;
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3446 if (res < 0)
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3447 return 0;
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3448 else if (res)
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3449 return 1;
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3450 else mkv_d->cluster_size += l + il;
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3451 break;
8ada6970000a Add matroska v2 (SimpleBlock) support.
eugeni
parents: 19812
diff changeset
3452 }
11934
bef061911390 Exit when an invalid EBML ID has been read (e.g. for files that have been cut off).
mosu
parents: 11901
diff changeset
3453 case EBML_ID_INVALID:
bef061911390 Exit when an invalid EBML ID has been read (e.g. for files that have been cut off).
mosu
parents: 11901
diff changeset
3454 return 0;
bef061911390 Exit when an invalid EBML ID has been read (e.g. for files that have been cut off).
mosu
parents: 11901
diff changeset
3455
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3456 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3457 ebml_read_skip (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3458 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3459 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3460 mkv_d->cluster_size -= l + il;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3461 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3462 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3463
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3464 if (ebml_read_id (s, &il) != MATROSKA_ID_CLUSTER)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3465 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3466 add_cluster_position(mkv_d, stream_tell(s)-il);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3467 mkv_d->cluster_size = ebml_read_length (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3468 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3469
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3470 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3471 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3472
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3473 static void
17695
3f20b096782d Add audio_delay argument to demux_mkv_seek.
corey
parents: 17308
diff changeset
3474 demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3475 {
14054
53ea955d19fa Added support for MPEG-1 and MPEG-2 in Matroska.
mosu
parents: 14046
diff changeset
3476 free_cached_dps (demuxer);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3477 if (!(flags & 2)) /* time in secs */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3478 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3479 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3480 stream_t *s = demuxer->stream;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3481 int64_t target_timecode = 0, diff, min_diff=0xFFFFFFFL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3482 int i;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3483
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3484 if (!(flags & 1)) /* relative seek */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3485 target_timecode = (int64_t) (mkv_d->last_pts * 1000.0);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3486 target_timecode += (int64_t)(rel_seek_secs * 1000.0);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3487 if (target_timecode < 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3488 target_timecode = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3489
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3490 if (mkv_d->indexes == NULL) /* no index was found */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3491 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3492 uint64_t target_filepos, cluster_pos, max_pos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3493
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3494 target_filepos = (uint64_t) (target_timecode * mkv_d->last_filepos
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3495 / (mkv_d->last_pts * 1000.0));
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3496
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3497 max_pos = mkv_d->cluster_positions[mkv_d->num_cluster_pos-1];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3498 if (target_filepos > max_pos)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3499 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3500 if ((off_t) max_pos > stream_tell (s))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3501 stream_seek (s, max_pos);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3502 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3503 stream_seek (s, stream_tell (s) + mkv_d->cluster_size);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3504 /* parse all the clusters upto target_filepos */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3505 while (!s->eof && stream_tell(s) < (off_t) target_filepos)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3506 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3507 switch (ebml_read_id (s, &i))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3508 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3509 case MATROSKA_ID_CLUSTER:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3510 add_cluster_position(mkv_d, (uint64_t) stream_tell(s)-i);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3511 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3512
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3513 case MATROSKA_ID_CUES:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3514 demux_mkv_read_cues (demuxer);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3515 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3516 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3517 ebml_read_skip (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3518 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3519 if (s->eof)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3520 stream_reset(s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3521 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3522
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3523 if (mkv_d->indexes == NULL)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3524 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3525 cluster_pos = mkv_d->cluster_positions[0];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3526 /* Let's find the nearest cluster */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3527 for (i=0; i < mkv_d->num_cluster_pos; i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3528 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3529 diff = mkv_d->cluster_positions[i] - target_filepos;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3530 if (rel_seek_secs < 0 && diff < 0 && -diff < min_diff)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3531 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3532 cluster_pos = mkv_d->cluster_positions[i];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3533 min_diff = -diff;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3534 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3535 else if (rel_seek_secs > 0
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3536 && (diff < 0 ? -1 * diff : diff) < min_diff)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3537 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3538 cluster_pos = mkv_d->cluster_positions[i];
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3539 min_diff = diff < 0 ? -1 * diff : diff;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3540 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3541 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3542 mkv_d->cluster_size = mkv_d->blockgroup_size = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3543 stream_seek (s, cluster_pos);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3544 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3545 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3546 else
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3547 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3548 mkv_index_t *index = NULL;
20712
e3f4ad403fff Fix index-based seeking in audio-only files, fixes bug #621
reimar
parents: 20680
diff changeset
3549 int seek_id = (demuxer->video->id < 0) ? demuxer->audio->id : demuxer->video->id;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3550
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3551 /* let's find the entry in the indexes with the smallest */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3552 /* difference to the wanted timecode. */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3553 for (i=0; i < mkv_d->num_indexes; i++)
20712
e3f4ad403fff Fix index-based seeking in audio-only files, fixes bug #621
reimar
parents: 20680
diff changeset
3554 if (mkv_d->indexes[i].tnum == seek_id)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3555 {
19811
ed853180b3b9 Fix seeking in Matroska files with non-default TimecodeScale value.
eugeni
parents: 19810
diff changeset
3556 diff = target_timecode + mkv_d->first_tc -
ed853180b3b9 Fix seeking in Matroska files with non-default TimecodeScale value.
eugeni
parents: 19810
diff changeset
3557 (int64_t) mkv_d->indexes[i].timecode * mkv_d->tc_scale / 1000000.0;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3558
22616
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3559 if ((flags & 1 || target_timecode <= mkv_d->last_pts*1000)) {
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3560 // Absolute seek or seek backward: find the last index
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3561 // position before target time
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3562 if (diff < 0 || diff >= min_diff)
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3563 continue;
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3564 }
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3565 else {
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3566 // Relative seek forward: find the first index position
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3567 // after target time. If no such index exists, find last
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3568 // position between current position and target time.
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3569 if (diff <= 0) {
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3570 if (min_diff <= 0 && diff <= min_diff)
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3571 continue;
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3572 }
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3573 else if (diff >= FFMIN(target_timecode - mkv_d->last_pts,
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3574 min_diff))
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3575 continue;
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3576 }
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3577 min_diff = diff;
09dc129234a0 Matroska seeking fixes
uau
parents: 22606
diff changeset
3578 index = mkv_d->indexes + i;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3579 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3580
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3581 if (index) /* We've found an entry. */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3582 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3583 mkv_d->cluster_size = mkv_d->blockgroup_size = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3584 stream_seek (s, index->filepos);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3585 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3586 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3587
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3588 if (demuxer->video->id >= 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3589 mkv_d->v_skip_to_keyframe = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3590 if (rel_seek_secs > 0.0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3591 mkv_d->skip_to_timecode = target_timecode;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3592 mkv_d->a_skip_to_keyframe = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3593
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3594 demux_mkv_fill_buffer(demuxer, NULL);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3595 }
12073
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3596 else if ((demuxer->movi_end <= 0) || !(flags & 1))
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3597 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] seek unsupported flags\n");
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3598 else
12073
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3599 {
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3600 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3601 stream_t *s = demuxer->stream;
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3602 uint64_t target_filepos;
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3603 mkv_index_t *index = NULL;
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3604 int i;
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3605
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3606 if (mkv_d->indexes == NULL) /* no index was found */
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3607 { /* I'm lazy... */
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3608 mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] seek unsupported flags\n");
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3609 return;
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3610 }
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3611
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3612 target_filepos = (uint64_t)(demuxer->movi_end * rel_seek_secs);
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3613 for (i=0; i < mkv_d->num_indexes; i++)
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3614 if (mkv_d->indexes[i].tnum == demuxer->video->id)
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3615 if ((index == NULL) ||
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3616 ((mkv_d->indexes[i].filepos >= target_filepos) &&
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3617 ((index->filepos < target_filepos) ||
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3618 (mkv_d->indexes[i].filepos < index->filepos))))
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3619 index = &mkv_d->indexes[i];
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3620
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3621 if (!index)
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3622 return;
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3623
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3624 mkv_d->cluster_size = mkv_d->blockgroup_size = 0;
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3625 stream_seek (s, index->filepos);
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3626
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3627 if (demuxer->video->id >= 0)
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3628 mkv_d->v_skip_to_keyframe = 1;
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3629 mkv_d->skip_to_timecode = index->timecode;
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3630 mkv_d->a_skip_to_keyframe = 1;
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3631
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3632 demux_mkv_fill_buffer(demuxer, NULL);
12073
0ef56fc11e4e Implemented "seek to position".
mosu
parents: 12065
diff changeset
3633 }
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3634 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3635
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3636 static int
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3637 demux_mkv_control (demuxer_t *demuxer, int cmd, void *arg)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3638 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3639 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3640
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3641 switch (cmd)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3642 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3643 case DEMUXER_CTRL_GET_TIME_LENGTH:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3644 if (mkv_d->duration == 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3645 return DEMUXER_CTRL_DONTKNOW;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3646
16346
6ff303d2876b Make -identify's 'ID_LENGTH=' print a float and not an integer.. The
ods15
parents: 16302
diff changeset
3647 *((double *)arg) = (double)mkv_d->duration;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3648 return DEMUXER_CTRL_OK;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3649
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3650 case DEMUXER_CTRL_GET_PERCENT_POS:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3651 if (mkv_d->duration == 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3652 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3653 return DEMUXER_CTRL_DONTKNOW;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3654 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3655
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3656 *((int *) arg) = (int) (100 * mkv_d->last_pts / mkv_d->duration);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3657 return DEMUXER_CTRL_OK;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3658
15154
898f68adad2b Online audio switching now supports Matroska too. Patch by Michael Behrisch
gpoirier
parents: 14843
diff changeset
3659 case DEMUXER_CTRL_SWITCH_AUDIO:
898f68adad2b Online audio switching now supports Matroska too. Patch by Michael Behrisch
gpoirier
parents: 14843
diff changeset
3660 if (demuxer->audio && demuxer->audio->sh) {
19645
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3661 sh_audio_t *sh = demuxer->a_streams[demuxer->audio->id];
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3662 int aid = *(int*)arg;
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3663 if (aid < 0)
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3664 aid = (sh->aid + 1) % mkv_d->last_aid;
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3665 if (aid != sh->aid) {
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3666 mkv_track_t *track = demux_mkv_find_track_by_num (mkv_d, aid, MATROSKA_TRACK_AUDIO);
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3667 if (track) {
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3668 demuxer->audio->id = track->tnum;
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3669 sh = demuxer->a_streams[demuxer->audio->id];
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3670 ds_free_packs(demuxer->audio);
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3671 }
15285
39eb8a327ea9 adds a parameter to the switch_audio command to directly select a track.
reimar
parents: 15154
diff changeset
3672 }
19645
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3673 *(int*)arg = sh->aid;
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3674 } else
da6ec282d26c Fix crash on DEMUXER_CTRL_SWITCH_AUDIO introduced by aid_vid_mismatch patch
reimar
parents: 19643
diff changeset
3675 *(int*)arg = -2;
15154
898f68adad2b Online audio switching now supports Matroska too. Patch by Michael Behrisch
gpoirier
parents: 14843
diff changeset
3676 return DEMUXER_CTRL_OK;
898f68adad2b Online audio switching now supports Matroska too. Patch by Michael Behrisch
gpoirier
parents: 14843
diff changeset
3677
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3678 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3679 return DEMUXER_CTRL_NOTIMPL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3680 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3681 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
3682
13126
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3683 /** \brief Change the current subtitle track and return its ID.
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3684
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3685 Changes the current subtitle track. If the new subtitle track is a
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3686 VobSub track then the SPU decoder will be re-initialized.
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3687
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3688 \param demuxer The demuxer whose subtitle track will be changed.
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3689 \param new_num The number of the new subtitle track. The number must be
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3690 between 0 and demux_mkv_num_subs - 1.
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3691
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3692 \returns The Matroska track number of the newly selected track.
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3693 */
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3694 int
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3695 demux_mkv_change_subs (demuxer_t *demuxer, int new_num)
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3696 {
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3697 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3698 mkv_track_t *track;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3699 int i, num;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3700
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3701 num = 0;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3702 track = NULL;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3703 for (i = 0; i < mkv_d->num_tracks; i++)
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3704 {
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3705 if ((mkv_d->tracks[i]->type == MATROSKA_TRACK_SUBTITLE) &&
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3706 (mkv_d->tracks[i]->subtitle_type != MATROSKA_SUBTYPE_UNKNOWN))
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3707 num++;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3708 if (num == (new_num + 1))
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3709 {
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3710 track = mkv_d->tracks[i];
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3711 break;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3712 }
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3713 }
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3714 if (track == NULL)
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3715 return -1;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3716
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3717 if (demuxer->sub->sh == NULL)
18934
a3788ff5d0b6 Rename mkv_sh_sub_t to sh_sub_t, move it to demuxer.h.
eugeni
parents: 18917
diff changeset
3718 demuxer->sub->sh = malloc(sizeof(sh_sub_t));
13126
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3719 if (demuxer->sub->sh != NULL)
18934
a3788ff5d0b6 Rename mkv_sh_sub_t to sh_sub_t, move it to demuxer.h.
eugeni
parents: 18917
diff changeset
3720 memcpy(demuxer->sub->sh, &track->sh_sub, sizeof(sh_sub_t));
13126
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3721
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3722 return track->tnum;
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3723 }
b59e16a8dfc7 Support for subtitle switching in Matroska.
mosu
parents: 12909
diff changeset
3724
13129
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3725 /** \brief Get the language code for a subtitle track.
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3726
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3727 Retrieves the language code for a subtitle track if it is known.
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3728 If the language code is "und" then do not copy it ("und" = "undefined").
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3729
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3730 \param demuxer The demuxer to work on
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3731 \param track_num The n'th subtitle track to get the language from
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3732 \param lang Store the language here
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3733 \param maxlen The maximum number of characters to copy into lang
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3734 */
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3735 void
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3736 demux_mkv_get_sub_lang(demuxer_t *demuxer, int track_num, char *lang,
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3737 int maxlen)
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3738 {
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3739 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
20173
30d56afbf584 Simplify demux_mkv_get_sub_lang
reimar
parents: 20168
diff changeset
3740 mkv_track_t *track = demux_mkv_find_track_by_num (mkv_d, track_num, MATROSKA_TRACK_SUBTITLE);
20176
31d504bf45f4 Cosmetics
reimar
parents: 20175
diff changeset
3741 if (track->language && strcmp(track->language, "und"))
31d504bf45f4 Cosmetics
reimar
parents: 20175
diff changeset
3742 strlcpy(lang, track->language, maxlen);
13129
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3743 }
cfce549da2f0 Display the language code for subtitles from Matroska files.
mosu
parents: 13126
diff changeset
3744
20156
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3745 /** \brief Get the language code for an audio track.
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3746
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3747 Retrieves the language code for an audio track if it is known.
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3748 If the language code is "und" then do not copy it ("und" = "undefined").
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3749
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3750 \param demuxer The demuxer to work on
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3751 \param track_num The n'th audio track to get the language from
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3752 \param lang Store the language here
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3753 \param maxlen The maximum number of characters to copy into lang
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3754 */
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3755 void
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3756 demux_mkv_get_audio_lang(demuxer_t *demuxer, int track_num, char *lang,
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3757 int maxlen)
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3758 {
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3759 mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
20168
0ba2a57c95a6 modifications pointed out by reimar doffinger
ptt
parents: 20156
diff changeset
3760 mkv_track_t *track = demux_mkv_find_track_by_num (mkv_d, track_num, MATROSKA_TRACK_AUDIO);
20176
31d504bf45f4 Cosmetics
reimar
parents: 20175
diff changeset
3761 if (track->language && strcmp(track->language, "und"))
20168
0ba2a57c95a6 modifications pointed out by reimar doffinger
ptt
parents: 20156
diff changeset
3762 strlcpy(lang, track->language, maxlen);
20156
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3763 }
42b46a42f83b added OSD audio switching visualization
ptt
parents: 20155
diff changeset
3764
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3765
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3766 demuxer_desc_t demuxer_desc_matroska = {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3767 "Matroska demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3768 "mkv",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3769 "Matroska",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3770 "Aurelien Jacobs",
21997
59a9255117db Remove comment printed by -demuxer help, it belongs in the copyright header.
diego
parents: 21827
diff changeset
3771 "",
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3772 DEMUXER_TYPE_MATROSKA,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3773 1, // safe autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3774 demux_mkv_open,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3775 demux_mkv_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3776 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3777 demux_close_mkv,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3778 demux_mkv_seek,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3779 demux_mkv_control
6b86089c2edd Demuxer modularization
rtognimp
parents: 15701
diff changeset
3780 };