codecs.conf: Use fourcc instead of format where appropriate
[mplayer.git] / libmpdemux / ebml.h
blob866e620c6109df8f282f2ed03f5ea1a50619e4fe
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_EBML_H
20 #define MPLAYER_EBML_H
22 #include <inttypes.h>
23 #include <stddef.h>
24 #include <stdbool.h>
26 #include "stream/stream.h"
27 #include "bstr.h"
30 /* EBML version supported */
31 #define EBML_VERSION 1
33 enum ebml_elemtype {
34 EBML_TYPE_SUBELEMENTS,
35 EBML_TYPE_UINT,
36 EBML_TYPE_SINT,
37 EBML_TYPE_FLOAT,
38 EBML_TYPE_STR,
39 EBML_TYPE_BINARY,
40 EBML_TYPE_EBML_ID,
43 struct ebml_field_desc {
44 uint32_t id;
45 bool multiple;
46 int offset;
47 int count_offset;
48 const struct ebml_elem_desc *desc;
51 struct ebml_elem_desc {
52 char *name;
53 enum ebml_elemtype type;
54 int size;
55 int field_count;
56 const struct ebml_field_desc *fields;
59 struct ebml_parse_ctx {
60 void *talloc_ctx;
61 int bytes_read;
62 bool has_errors;
63 bool no_error_messages;
66 #include "ebml_types.h"
68 #define EBML_ID_INVALID 0xffffffff
71 /* matroska track types */
72 #define MATROSKA_TRACK_VIDEO 0x01 /* rectangle-shaped pictures aka video */
73 #define MATROSKA_TRACK_AUDIO 0x02 /* anything you can hear */
74 #define MATROSKA_TRACK_COMPLEX 0x03 /* audio+video in same track used by DV */
75 #define MATROSKA_TRACK_LOGO 0x10 /* overlay-pictures displayed over video*/
76 #define MATROSKA_TRACK_SUBTITLE 0x11 /* text-subtitles */
77 #define MATROSKA_TRACK_CONTROL 0x20 /* control-codes for menu or other stuff*/
79 #ifndef UINT64_MAX
80 #define UINT64_MAX 18446744073709551615ULL
81 #endif
83 #ifndef INT64_MAX
84 #define INT64_MAX 9223372036854775807LL
85 #endif
87 #define EBML_UINT_INVALID UINT64_MAX
88 #define EBML_INT_INVALID INT64_MAX
89 #define EBML_FLOAT_INVALID -1000000000.0
92 uint32_t ebml_read_id (stream_t *s, int *length);
93 uint64_t ebml_read_vlen_uint (uint8_t *buffer, int *length);
94 int64_t ebml_read_vlen_int (uint8_t *buffer, int *length);
95 uint64_t ebml_read_length (stream_t *s, int *length);
96 uint64_t ebml_read_uint (stream_t *s, uint64_t *length);
97 int64_t ebml_read_int (stream_t *s, uint64_t *length);
98 double ebml_read_float (stream_t *s, uint64_t *length);
99 char *ebml_read_ascii (stream_t *s, uint64_t *length);
100 char *ebml_read_utf8 (stream_t *s, uint64_t *length);
101 int ebml_read_skip (stream_t *s, uint64_t *length);
102 uint32_t ebml_read_master (stream_t *s, uint64_t *length);
104 int ebml_read_element(struct stream *s, struct ebml_parse_ctx *ctx,
105 void *target, const struct ebml_elem_desc *desc);
107 #endif /* MPLAYER_EBML_H */