Compile fixes on OSX.
[libmkv.git] / src / matroska.h
blob9fb13e58eca095eed24cb7732d90166dd28693b8
1 /*****************************************************************************
2 * matroska.h:
3 *****************************************************************************
4 * Copyright (C) 2005 x264 project
5 * $Id: $
7 * Authors: Mike Matsnev
8 * Nathan Caldwell
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
24 #ifndef _MATROSKA_H
25 #define _MATROSKA_H 1
27 #define _LARGEFILE_SOURCE
28 #define _FILE_OFFSET_BITS 64
30 #define CLSIZE 1048576
31 #define CHECK(x) do { if ((x) < 0) return -1; } while (0)
33 typedef struct mk_Context_s mk_Context;
34 typedef struct mk_Seek_s mk_Seek;
35 typedef struct mk_Chapter_s mk_Chapter;
37 struct mk_Context_s {
38 mk_Context *next, **prev, *parent;
39 mk_Writer *owner;
40 unsigned id;
42 void *data;
43 unsigned d_cur, d_max;
46 struct mk_Writer_s {
47 FILE *fp;
49 int64_t duration_ptr;
50 int64_t seekhead_ptr;
51 int64_t segment_ptr;
53 mk_Context *root;
54 mk_Context *freelist;
55 mk_Context *actlist;
56 mk_Context *chapters;
57 mk_Context *edition_entry;
58 mk_Context *tracks;
59 mk_Context *cues;
61 uint64_t def_duration;
62 uint64_t timescale;
64 uint8_t wrote_header;
66 uint8_t num_tracks;
67 mk_Track **tracks_arr;
69 struct {
70 int64_t segmentinfo;
71 int64_t seekhead;
72 int64_t tracks;
73 int64_t cues;
74 int64_t chapters;
75 int64_t attachments;
76 int64_t tags;
77 } seek_data;
79 struct {
80 mk_Context *context;
81 uint64_t timecode;
82 } cue_point;
84 struct {
85 mk_Context *context;
86 uint64_t block_count;
87 uint64_t count;
88 uint64_t pointer;
89 int64_t tc_scaled;
90 } cluster;
92 int chapter_uid;
93 uint8_t vlc_compat;
96 struct mk_Track_s {
97 uint8_t track_id;
99 // mk_Context *frame;
100 // int64_t frame_tc;
101 int64_t prev_frame_tc_scaled;
102 int64_t max_frame_tc;
103 uint8_t in_frame;
104 // uint8_t keyframe;
105 uint64_t default_duration;
106 uint8_t cue_flag;
108 struct {
109 mk_Context *data;
110 int64_t timecode;
111 uint8_t keyframe;
112 uint8_t lacing;
113 uint8_t lacing_num_frames;
114 int32_t *lacing_sizes;
115 } frame;
118 mk_Context *mk_createContext(mk_Writer *w, mk_Context *parent, unsigned id);
119 int mk_writeUInt(mk_Context *c, unsigned id, uint64_t ui);
120 int mk_writeFloat(mk_Context *c, unsigned id, float f);
121 int mk_writeStr(mk_Context *c, unsigned id, const char *str);
122 int mk_writeBin(mk_Context *c, unsigned id, const void *data, unsigned size);
123 int mk_flushContextData(mk_Context *c);
124 int mk_closeContext(mk_Context *c, int64_t *off);
125 int mk_writeSeek(mk_Writer *w, int64_t *pointer);
126 int mk_writeTracks(mk_Writer *w, mk_Context *tracks);
127 int mk_writeChapters(mk_Writer *w);
128 static unsigned mk_ebmlSizeSize(uint64_t s);
130 #endif