annotate libmpdemux/ebml.c @ 16045:aea67dddbdb5

small fixes.
author ods15
date Fri, 22 Jul 2005 08:50:49 +0000
parents 28b8fc8278e0
children e3379df74bcd
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 ebml reader for the 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 * Licence: GPL
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
6 */
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 #include "config.h"
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
9 #ifdef HAVE_MATROSKA
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
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
13 #include "stream.h"
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
14 #include "ebml.h"
15976
28b8fc8278e0 (hopefully) fixing remaining float endianness problems
reimar
parents: 15959
diff changeset
15 #include "bswap.h"
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
16
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
17
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
18 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
19 * Read: the element content data ID.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
20 * Return: the ID.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
21 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
22 uint32_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
23 ebml_read_id (stream_t *s, int *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
24 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
25 int i, len_mask = 0x80;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
26 uint32_t id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
27
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
28 for (i=0, id=stream_read_char (s); i<4 && !(id & len_mask); i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
29 len_mask >>= 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
30 if (i >= 4)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
31 return EBML_ID_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
32 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
33 *length = i + 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
34 while (i--)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
35 id = (id << 8) | stream_read_char (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
36 return id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
37 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
38
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
39 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
40 * Read a variable length unsigned int.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
41 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
42 uint64_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
43 ebml_read_vlen_uint (uint8_t *buffer, int *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
44 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
45 int i, j, num_ffs = 0, len_mask = 0x80;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
46 uint64_t num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
47
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
48 for (i=0, num=*buffer++; i<8 && !(num & len_mask); i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
49 len_mask >>= 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
50 if (i >= 8)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
51 return EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
52 j = i+1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
53 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
54 *length = j;
13131
ab937f4a17ad Cosmetics: fix some compiler warnings.
mosu
parents: 12376
diff changeset
55 if ((int)(num &= (len_mask - 1)) == len_mask - 1)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
56 num_ffs++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
57 while (i--)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
58 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
59 num = (num << 8) | *buffer++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
60 if ((num & 0xFF) == 0xFF)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
61 num_ffs++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
62 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
63 if (j == num_ffs)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
64 return EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
65 return num;
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
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
68 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
69 * Read a variable length signed int.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
70 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
71 int64_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
72 ebml_read_vlen_int (uint8_t *buffer, int *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
73 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
74 uint64_t unum;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
75 int l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
76
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
77 /* read as unsigned number first */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
78 unum = ebml_read_vlen_uint (buffer, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
79 if (unum == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
80 return EBML_INT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
81 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
82 *length = l;
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 return unum - ((1 << ((7 * l) - 1)) - 1);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
85 }
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 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
88 * Read: element content length.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
89 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
90 uint64_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
91 ebml_read_length (stream_t *s, int *length)
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 i, j, num_ffs = 0, len_mask = 0x80;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
94 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
95
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
96 for (i=0, len=stream_read_char (s); i<8 && !(len & len_mask); i++)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
97 len_mask >>= 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
98 if (i >= 8)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
99 return EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
100 j = i+1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
101 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
102 *length = j;
13131
ab937f4a17ad Cosmetics: fix some compiler warnings.
mosu
parents: 12376
diff changeset
103 if ((int)(len &= (len_mask - 1)) == len_mask - 1)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
104 num_ffs++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
105 while (i--)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
106 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
107 len = (len << 8) | stream_read_char (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
108 if ((len & 0xFF) == 0xFF)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
109 num_ffs++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
110 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
111 if (j == num_ffs)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
112 return EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
113 return len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
114 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
115
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
116 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
117 * Read the next element as an unsigned int.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
118 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
119 uint64_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
120 ebml_read_uint (stream_t *s, uint64_t *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
121 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
122 uint64_t len, value = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
123 int l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
124
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
125 len = ebml_read_length (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
126 if (len == EBML_UINT_INVALID || len < 1 || len > 8)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
127 return EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
128 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
129 *length = len + l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
130
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
131 while (len--)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
132 value = (value << 8) | stream_read_char (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
133
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
134 return value;
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
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 * Read the next element as a signed int.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
139 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
140 int64_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
141 ebml_read_int (stream_t *s, uint64_t *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
142 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
143 int64_t value = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
144 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
145 int l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
146
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
147 len = ebml_read_length (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
148 if (len == EBML_UINT_INVALID || len < 1 || len > 8)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
149 return EBML_INT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
150 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
151 *length = len + l;
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 len--;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
154 l = stream_read_char (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
155 if (l & 0x80)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
156 value = -1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
157 value = (value << 8) | l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
158 while (len--)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
159 value = (value << 8) | stream_read_char (s);
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 return value;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
162 }
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 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
165 * Read the next element as a float.
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 long double
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
168 ebml_read_float (stream_t *s, uint64_t *length)
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 long double value;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
171 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
172 int l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
173
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
174 len = ebml_read_length (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
175 switch (len)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
176 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
177 case 4:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
178 {
15959
dcb042d5500d Fix for gcc 4 and strict-aliasing. Patch by Uoti A Urpala ( urpala () cc ! helsinki ! fi ).
mosu
parents: 14490
diff changeset
179 union {uint32_t i; float f;} u;
dcb042d5500d Fix for gcc 4 and strict-aliasing. Patch by Uoti A Urpala ( urpala () cc ! helsinki ! fi ).
mosu
parents: 14490
diff changeset
180 u.i = stream_read_dword (s);
dcb042d5500d Fix for gcc 4 and strict-aliasing. Patch by Uoti A Urpala ( urpala () cc ! helsinki ! fi ).
mosu
parents: 14490
diff changeset
181 value = u.f;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
182 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
183 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
184
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
185 case 8:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
186 {
15959
dcb042d5500d Fix for gcc 4 and strict-aliasing. Patch by Uoti A Urpala ( urpala () cc ! helsinki ! fi ).
mosu
parents: 14490
diff changeset
187 union {uint64_t i; double d;} u;
dcb042d5500d Fix for gcc 4 and strict-aliasing. Patch by Uoti A Urpala ( urpala () cc ! helsinki ! fi ).
mosu
parents: 14490
diff changeset
188 u.i = stream_read_qword (s);
dcb042d5500d Fix for gcc 4 and strict-aliasing. Patch by Uoti A Urpala ( urpala () cc ! helsinki ! fi ).
mosu
parents: 14490
diff changeset
189 value = u.d;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
190 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
191 }
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 case 10:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
194 {
15959
dcb042d5500d Fix for gcc 4 and strict-aliasing. Patch by Uoti A Urpala ( urpala () cc ! helsinki ! fi ).
mosu
parents: 14490
diff changeset
195 union {uint8_t data[10]; long double ld;} u;
dcb042d5500d Fix for gcc 4 and strict-aliasing. Patch by Uoti A Urpala ( urpala () cc ! helsinki ! fi ).
mosu
parents: 14490
diff changeset
196 if (stream_read (s, u.data, 10) != 10)
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
197 return EBML_FLOAT_INVALID;
15976
28b8fc8278e0 (hopefully) fixing remaining float endianness problems
reimar
parents: 15959
diff changeset
198 value = be2me_ldbl(u.ld);
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
199 break;
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
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
202 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
203 return EBML_FLOAT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
204 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
205
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
206 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
207 *length = len + l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
208
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
209 return value;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
210 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
211
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
212 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
213 * Read the next element as an ASCII string.
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 char *
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
216 ebml_read_ascii (stream_t *s, uint64_t *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
217 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
218 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
219 char *str;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
220 int l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
221
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
222 len = ebml_read_length (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
223 if (len == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
224 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
225 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
226 *length = len + l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
227
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
228 str = (char *) malloc (len+1);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
229 if (stream_read(s, str, len) != (int) len)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
230 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
231 free (str);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
232 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
233 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
234 str[len] = '\0';
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
235
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
236 return str;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
237 }
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 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
240 * Read the next element as a UTF-8 string.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
241 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
242 char *
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
243 ebml_read_utf8 (stream_t *s, uint64_t *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
244 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
245 return ebml_read_ascii (s, length);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
246 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
247
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
248 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
249 * Skip the next element.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
250 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
251 int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
252 ebml_read_skip (stream_t *s, uint64_t *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
253 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
254 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
255 int l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
256
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
257 len = ebml_read_length (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
258 if (len == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
259 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
260 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
261 *length = len + l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
262
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
263 stream_skip(s, len);
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 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
266 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
267
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
268 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
269 * Read the next element, but only the header. The contents
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
270 * are supposed to be sub-elements which can be read separately.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
271 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
272 uint32_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
273 ebml_read_master (stream_t *s, uint64_t *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
274 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
275 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
276 uint32_t id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
277
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
278 id = ebml_read_id (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
279 if (id == EBML_ID_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
280 return id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
281
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
282 len = ebml_read_length (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
283 if (len == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
284 return EBML_ID_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
285 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
286 *length = len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
287
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
288 return id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
289 }
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
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 * Read an EBML header.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
294 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
295 char *
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
296 ebml_read_header (stream_t *s, int *version)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
297 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
298 uint64_t length, l, num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
299 uint32_t id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
300 char *str = NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
301
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
302 if (ebml_read_master (s, &length) != EBML_ID_HEADER)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
303 return 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
304
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
305 if (version)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
306 *version = 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
307
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
308 while (length > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
309 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
310 id = ebml_read_id (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
311 if (id == EBML_ID_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
312 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
313 length -= 2;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
314
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
315 switch (id)
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 /* is our read version uptodate? */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
318 case EBML_ID_EBMLREADVERSION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
319 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
320 if (num != EBML_VERSION)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
321 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
322 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
323
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
324 /* we only handle 8 byte lengths at max */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
325 case EBML_ID_EBMLMAXSIZELENGTH:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
326 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
327 if (num != sizeof (uint64_t))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
328 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
329 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
330
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
331 /* we handle 4 byte IDs at max */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
332 case EBML_ID_EBMLMAXIDLENGTH:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
333 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
334 if (num != sizeof (uint32_t))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
335 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
336 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
337
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
338 case EBML_ID_DOCTYPE:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
339 str = ebml_read_ascii (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
340 if (str == NULL)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
341 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
342 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
343
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
344 case EBML_ID_DOCTYPEREADVERSION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
345 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
346 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
347 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
348 if (version)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
349 *version = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
350 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
351
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
352 /* we ignore these two, they don't tell us anything we care about */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
353 case EBML_ID_VOID:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
354 case EBML_ID_EBMLVERSION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
355 case EBML_ID_DOCTYPEVERSION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
356 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
357 if (ebml_read_skip (s, &l))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
358 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
359 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
360 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
361 length -= l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
362 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
363
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
364 return str;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
365 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
366
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
367 #endif /* HAVE_MATROSKA */