annotate libmpdemux/ebml.c @ 22422:dd99089c892b

Move/simplify some variable declarations
author reimar
date Sun, 04 Mar 2007 12:59:48 +0000
parents fa99b3d31d13
children 4d81dbdf46b9
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
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
10 #include <stdlib.h>
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
11
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
12 #include "stream.h"
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
13 #include "ebml.h"
21372
1767c271d710 Remove bswap.h, use libavutil/bswap.h instead.
diego
parents: 21344
diff changeset
14 #include "libavutil/common.h"
21507
fa99b3d31d13 Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents: 21388
diff changeset
15 #include "mpbswap.h"
21388
be5f168e42ae Use av_int2flt/av_int2dbl to read float values. This is simpler and more
reimar
parents: 21372
diff changeset
16 #include "libavutil/intfloat_readwrite.h"
11807
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
18671
8fb542b97815 Protect SIZE_MAX use
rtogni
parents: 18558
diff changeset
19 #ifndef SIZE_MAX
8fb542b97815 Protect SIZE_MAX use
rtogni
parents: 18558
diff changeset
20 #define SIZE_MAX ((size_t)-1)
8fb542b97815 Protect SIZE_MAX use
rtogni
parents: 18558
diff changeset
21 #endif
8fb542b97815 Protect SIZE_MAX use
rtogni
parents: 18558
diff changeset
22
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
23 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
24 * Read: the element content data ID.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
25 * Return: the ID.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
26 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
27 uint32_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
28 ebml_read_id (stream_t *s, int *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
29 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
30 int i, len_mask = 0x80;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
31 uint32_t id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
32
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
33 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
34 len_mask >>= 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
35 if (i >= 4)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
36 return EBML_ID_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
37 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
38 *length = i + 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
39 while (i--)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
40 id = (id << 8) | stream_read_char (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
41 return id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
42 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
43
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 * Read a variable length unsigned int.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
46 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
47 uint64_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
48 ebml_read_vlen_uint (uint8_t *buffer, int *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
49 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
50 int i, j, num_ffs = 0, len_mask = 0x80;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
51 uint64_t num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
52
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
53 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
54 len_mask >>= 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
55 if (i >= 8)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
56 return EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
57 j = i+1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
58 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
59 *length = j;
13131
ab937f4a17ad Cosmetics: fix some compiler warnings.
mosu
parents: 12376
diff changeset
60 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
61 num_ffs++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
62 while (i--)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
63 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
64 num = (num << 8) | *buffer++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
65 if ((num & 0xFF) == 0xFF)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
66 num_ffs++;
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 if (j == num_ffs)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
69 return EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
70 return num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
71 }
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 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
74 * Read a variable length signed int.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
75 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
76 int64_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
77 ebml_read_vlen_int (uint8_t *buffer, int *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
78 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
79 uint64_t unum;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
80 int l;
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 /* read as unsigned number first */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
83 unum = ebml_read_vlen_uint (buffer, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
84 if (unum == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
85 return EBML_INT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
86 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
87 *length = l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
88
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
89 return unum - ((1 << ((7 * l) - 1)) - 1);
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
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 * Read: element content length.
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 uint64_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
96 ebml_read_length (stream_t *s, int *length)
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 int i, j, num_ffs = 0, len_mask = 0x80;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
99 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
100
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
101 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
102 len_mask >>= 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
103 if (i >= 8)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
104 return EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
105 j = i+1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
106 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
107 *length = j;
13131
ab937f4a17ad Cosmetics: fix some compiler warnings.
mosu
parents: 12376
diff changeset
108 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
109 num_ffs++;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
110 while (i--)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
111 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
112 len = (len << 8) | stream_read_char (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
113 if ((len & 0xFF) == 0xFF)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
114 num_ffs++;
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 if (j == num_ffs)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
117 return EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
118 return len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
119 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
120
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 * Read the next element as an unsigned int.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
123 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
124 uint64_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
125 ebml_read_uint (stream_t *s, uint64_t *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
126 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
127 uint64_t len, value = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
128 int l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
129
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
130 len = ebml_read_length (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
131 if (len == EBML_UINT_INVALID || len < 1 || len > 8)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
132 return EBML_UINT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
133 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
134 *length = len + l;
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 while (len--)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
137 value = (value << 8) | stream_read_char (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
138
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
139 return value;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
140 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
141
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 * Read the next element as a signed int.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
144 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
145 int64_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
146 ebml_read_int (stream_t *s, uint64_t *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
147 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
148 int64_t value = 0;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
149 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
150 int l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
151
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
152 len = ebml_read_length (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
153 if (len == EBML_UINT_INVALID || len < 1 || len > 8)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
154 return EBML_INT_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
155 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
156 *length = len + l;
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 len--;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
159 l = stream_read_char (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
160 if (l & 0x80)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
161 value = -1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
162 value = (value << 8) | l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
163 while (len--)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
164 value = (value << 8) | stream_read_char (s);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
165
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
166 return value;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
167 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
168
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 * Read the next element as a float.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
171 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
172 long double
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
173 ebml_read_float (stream_t *s, uint64_t *length)
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 long double value;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
176 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
177 int l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
178
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
179 len = ebml_read_length (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
180 switch (len)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
181 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
182 case 4:
21388
be5f168e42ae Use av_int2flt/av_int2dbl to read float values. This is simpler and more
reimar
parents: 21372
diff changeset
183 value = av_int2flt(stream_read_dword(s));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
184 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
185
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
186 case 8:
21388
be5f168e42ae Use av_int2flt/av_int2dbl to read float values. This is simpler and more
reimar
parents: 21372
diff changeset
187 value = av_int2dbl(stream_read_qword(s));
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
188 break;
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 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
191 return EBML_FLOAT_INVALID;
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
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
194 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
195 *length = len + l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
196
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
197 return value;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
198 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
199
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 * Read the next element as an ASCII string.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
202 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
203 char *
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
204 ebml_read_ascii (stream_t *s, uint64_t *length)
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 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
207 char *str;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
208 int l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
209
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
210 len = ebml_read_length (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
211 if (len == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
212 return NULL;
18558
4928dd61f136 Fix potential integer overflows in memory allocation.
rtogni
parents: 18404
diff changeset
213 if (len > SIZE_MAX - 1)
4928dd61f136 Fix potential integer overflows in memory allocation.
rtogni
parents: 18404
diff changeset
214 return NULL;
11807
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
215 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
216 *length = len + l;
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 str = (char *) malloc (len+1);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
219 if (stream_read(s, str, len) != (int) len)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
220 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
221 free (str);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
222 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
223 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
224 str[len] = '\0';
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
225
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
226 return str;
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
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
229 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
230 * Read the next element as a UTF-8 string.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
231 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
232 char *
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
233 ebml_read_utf8 (stream_t *s, uint64_t *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
234 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
235 return ebml_read_ascii (s, length);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
236 }
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 * Skip the next element.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
240 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
241 int
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
242 ebml_read_skip (stream_t *s, uint64_t *length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
243 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
244 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
245 int l;
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 len = ebml_read_length (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
248 if (len == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
249 return 1;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
250 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
251 *length = len + l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
252
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
253 stream_skip(s, len);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
254
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
255 return 0;
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
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
258 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
259 * 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
260 * 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
261 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
262 uint32_t
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
263 ebml_read_master (stream_t *s, uint64_t *length)
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 uint64_t len;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
266 uint32_t id;
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 id = ebml_read_id (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
269 if (id == EBML_ID_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
270 return id;
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 len = ebml_read_length (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
273 if (len == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
274 return EBML_ID_INVALID;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
275 if (length)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
276 *length = len;
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 return id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
279 }
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
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
282 /*
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
283 * Read an EBML header.
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
284 */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
285 char *
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
286 ebml_read_header (stream_t *s, int *version)
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 uint64_t length, l, num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
289 uint32_t id;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
290 char *str = NULL;
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 if (ebml_read_master (s, &length) != EBML_ID_HEADER)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
293 return 0;
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 if (version)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
296 *version = 1;
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 while (length > 0)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
299 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
300 id = ebml_read_id (s, NULL);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
301 if (id == EBML_ID_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
302 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
303 length -= 2;
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 switch (id)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
306 {
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
307 /* is our read version uptodate? */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
308 case EBML_ID_EBMLREADVERSION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
309 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
310 if (num != EBML_VERSION)
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 break;
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 /* we only handle 8 byte lengths at max */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
315 case EBML_ID_EBMLMAXSIZELENGTH:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
316 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
317 if (num != sizeof (uint64_t))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
318 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
319 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
320
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
321 /* we handle 4 byte IDs at max */
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
322 case EBML_ID_EBMLMAXIDLENGTH:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
323 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
324 if (num != sizeof (uint32_t))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
325 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
326 break;
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 case EBML_ID_DOCTYPE:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
329 str = ebml_read_ascii (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
330 if (str == NULL)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
331 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
332 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
333
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
334 case EBML_ID_DOCTYPEREADVERSION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
335 num = ebml_read_uint (s, &l);
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
336 if (num == EBML_UINT_INVALID)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
337 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
338 if (version)
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
339 *version = num;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
340 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
341
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
342 /* 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
343 case EBML_ID_VOID:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
344 case EBML_ID_EBMLVERSION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
345 case EBML_ID_DOCTYPEVERSION:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
346 default:
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
347 if (ebml_read_skip (s, &l))
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
348 return NULL;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
349 break;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
350 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
351 length -= l;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
352 }
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
353
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
354 return str;
9a81d7b4c0b6 Added the new C based Matroska demuxer by Aurelien Jacobs.
mosu
parents:
diff changeset
355 }