Update subtitle codecIDs to match those found on http://www.matroska.org/technical...
[libmkv.git] / include / libmkv.h
blob28e7b7faf056ceb2d2449e31ff04ba11a380f79e
1 /*****************************************************************************
2 * libmkv.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 _LIBMKV_H
25 #define _LIBMKV_H 1
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
35 #ifdef HAVE_STDINT_H
36 #include <stdint.h>
37 #else
38 #include <inttypes.h>
39 #endif
41 /* Video codecs */
42 #define MK_VCODEC_RAW "V_UNCOMPRESSED"
43 #define MK_VCODEC_MPEG1 "V_MPEG1"
44 #define MK_VCODEC_MPEG2 "V_MPEG2"
45 #define MK_VCODEC_THEORA "V_THEORA"
46 #define MK_VCODEC_SNOW "V_SNOW"
47 #define MK_VCODEC_MP4SP "V_MPEG4/ISO/SP"
48 #define MK_VCODEC_MP4ASP "V_MPEG4/ISO/ASP"
49 #define MK_VCODEC_MP4AP "V_MPEG4/ISO/AP"
50 #define MK_VCODEC_MP4AVC "V_MPEG4/ISO/AVC"
51 #define MK_VCODEC_MSVCM "V_MS/VFW/FOURCC"
52 #define MK_VCODEC_MSMP4V3 "V_MPEG4/MS/V3"
53 #define MK_VCODEC_REAL "V_REAL"
54 #define MK_VCODEC_REAL10 MK_VCODEC_REAL "/RV10"
55 #define MK_VCODEC_REAL20 MK_VCODEC_REAL "/RV20"
56 #define MK_VCODEC_REAL30 MK_VCODEC_REAL "/RV30"
57 #define MK_VCODEC_REAL40 MK_VCODEC_REAL "/RV40"
58 #define MK_VCODEC_QUICKTIME "V_QUICKTIME"
60 /* Audio codecs */
61 #define MK_ACODEC_AC3 "A_AC3"
62 #define MK_ACODEC_AC3BSID9 "A_AC3/BSID9"
63 #define MK_ACODEC_AC3BSID10 "A_AC3/BSID10"
64 #define MK_ACODEC_MP3 "A_MPEG/L3"
65 #define MK_ACODEC_MP2 "A_MPEG/L2"
66 #define MK_ACODEC_MP1 "A_MPEG/L1"
67 #define MK_ACODEC_DTS "A_DTS"
68 #define MK_ACODEC_PCMINTLE "A_PCM/INT/LIT"
69 #define MK_ACODEC_PCMINTBE "A_PCM/INT/BIG"
70 #define MK_ACODEC_PCMFLTLE "A_PCM/FLOAT/IEEE"
71 #define MK_ACODEC_TTA1 "A_TTA1"
72 #define MK_ACODEC_WAVPACK "A_WAVPACK4"
73 #define MK_ACODEC_VORBIS "A_VORBIS"
74 #define MK_ACODEC_FLAC "A_FLAC"
75 #define MK_ACODEC_AAC "A_AAC"
76 #define MK_ACODEC_MPC "A_MPC"
77 #define MK_ACODEC_REAL1 "A_REAL/14_4"
78 #define MK_ACODEC_REAL2 "A_REAL/28_8"
79 #define MK_ACODEC_REALCOOK "A_REAL/COOK"
80 #define MK_ACODEC_REALSIPR "A_REAL/SIPR"
81 #define MK_ACODEC_REALRALF "A_REAL/RALF"
82 #define MK_ACODEC_REALATRC "A_REAL/ATRC"
83 #define MK_ACODEC_MSACM "A_MS/ACM"
84 #define MK_ACODEC_QUICKTIME "A_QUICKTIME"
85 #define MK_ACODEC_QDMC MK_ACODEC_QUICKTIME "/QDMC"
86 #define MK_ACODEC_QDM2 MK_ACODEC_QUICKTIME "/QDM2"
87 #define MK_ACODEC_TTA1 "A_TTA1"
88 #define MK_ACODEC_WAVPACK4 "A_WAVEPACK4"
90 /* Subtitles */
91 #define MK_SUBTITLE_ASCII "S_TEXT/ASCII"
92 #define MK_SUBTITLE_UTF8 "S_TEXT/UTF8"
93 #define MK_SUBTITLE_SSA "S_TEXT/SSA"
94 #define MK_SUBTITLE_ASS "S_TEXT/ASS"
95 #define MK_SUBTITLE_USF "S_TEXT/USF"
96 #define MK_SUBTITLE_VOBSUB "S_VOBSUB"
97 #define MK_SUBTITLE_BMP "S_IMAGE/BMP"
99 #define MK_TRACK_VIDEO 0x01
100 #define MK_TRACK_AUDIO 0x02
101 #define MK_TRACK_COMPLEX 0x03
102 #define MK_TRACK_LOGO 0x10
103 #define MK_TRACK_SUBTITLE 0x11
104 #define MK_TRACK_BUTTONS 0x12
105 #define MK_TRACK_CONTROL 0x20
107 typedef enum mk_LacingTypesEnum {
108 MK_LACING_NONE = 0x00,
109 MK_LACING_XIPH,
110 MK_LACING_FIXED,
111 MK_LACING_EBML
112 } mk_LacingTypes;
114 typedef struct mk_Writer_s mk_Writer;
115 typedef struct mk_Track_s mk_Track;
116 typedef struct mk_TrackConfig_s mk_TrackConfig;
118 struct mk_TrackConfig_s {
119 uint64_t trackUID; // Optional: Unique identifier for the track.
120 uint8_t trackType; // Required: 1 = Video, 2 = Audio.
121 int8_t flagEnabled; // Required: Set 1 if the track is used, 0 if unused. (Default: enabled)
122 int8_t flagDefault; // Required: Set 1 if this track is default, 0 if not default, -1 is undefined.
123 int8_t flagForced; // Optional: Set 1 if the track MUST be shown during playback (Default: disabled)
124 int8_t flagLacing; // Required: Set 1 if the track may contain blocks using lacing.
125 uint8_t minCache; // Optional: See Matroska spec. (Default: cache disabled)
126 uint8_t maxCache;
127 int64_t defaultDuration; // Optional: Number of nanoseconds per frame.
128 char *name;
129 char *language;
130 char *codecID; // Required: See codecs above.
131 void *codecPrivate;
132 unsigned codecPrivateSize;
133 char *codecName;
134 union {
135 struct {
136 char flagInterlaced;
137 unsigned pixelWidth; // Pixel width
138 unsigned pixelHeight; // Pixel height
139 unsigned pixelCrop[4]; // Pixel crop - 0 = bottom, 1 = top, 2 = left, 3 = right
140 unsigned displayWidth; // Display width
141 unsigned displayHeight; // Display height
142 char displayUnit; // Display Units - 0 = pixels, 1 = cm, 2 = in
143 } video;
144 struct {
145 float samplingFreq; // Sampling Frequency in Hz
146 unsigned channels; // Number of channels for this track
147 unsigned bitDepth; // Bits per sample (PCM)
148 } audio;
149 } extra;
152 mk_Writer *mk_createWriter(const char *filename, int64_t timescale, uint8_t vlc_compat);
153 /* vlc_compat writes the Seek entries at the top of the file because VLC stops parsing *
154 * once it finds the first cluster. However, this creates extra overhead in the file. */
155 mk_Track *mk_createTrack(mk_Writer *w, mk_TrackConfig *tc);
156 int mk_writeHeader(mk_Writer *w, const char *writingApp);
157 int mk_startFrame( mk_Writer *w, mk_Track *track );
158 int mk_addFrameData(mk_Writer *w, mk_Track *track, const void *data, unsigned size);
159 int mk_setFrameFlags(mk_Writer *w, mk_Track *track, int64_t timestamp, unsigned keyframe);
160 int mk_setFrameLacing(mk_Writer *w, mk_Track *track, mk_LacingTypes lacing, uint8_t num_frames, uint64_t sizes[]);
161 int mk_createChapterSimple(mk_Writer *w, uint64_t start, uint64_t end, char *name);
162 int mk_close( mk_Writer *w );
164 char *mk_laceXiph(uint64_t *sizes, uint8_t num_frames, uint64_t *output_size);
166 #ifdef __cplusplus
168 #endif /* __cplusplus */
170 #endif /* _LIBMKV_H */