1 /**
2  * \file mlt_types.h
3  * \brief Provides forward definitions of all public types
4  *
5  * Copyright (C) 2003-2019 Meltytech, LLC
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef MLT_TYPES_H
23 #define MLT_TYPES_H
24 
25 #ifndef GCC_VERSION
26 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
27 #endif
28 
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33 
34 #include <inttypes.h>
35 #include <limits.h>
36 #include <stdio.h>
37 #include "mlt_pool.h"
38 
39 #ifndef PATH_MAX
40 #define PATH_MAX 4096
41 #endif
42 
43 /** The set of supported image formats */
44 
45 typedef enum
46 {
47 	mlt_image_none = 0,/**< image not available */
48 	mlt_image_rgb24,   /**< 8-bit RGB */
49 	mlt_image_rgb24a,  /**< 8-bit RGB with alpha channel */
50 	mlt_image_yuv422,  /**< 8-bit YUV 4:2:2 packed */
51 	mlt_image_yuv420p, /**< 8-bit YUV 4:2:0 planar */
52 	mlt_image_opengl,  /**< (deprecated) suitable for OpenGL texture */
53 	mlt_image_glsl,    /**< for opengl module internal use only */
54 	mlt_image_glsl_texture, /**< an OpenGL texture name */
55 	mlt_image_yuv422p16, /**< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian */
56 	mlt_image_invalid
57 }
58 mlt_image_format;
59 
60 /** The set of supported audio formats */
61 
62 typedef enum
63 {
64 	mlt_audio_none = 0,/**< audio not available */
65 	mlt_audio_pcm = 1, /**< \deprecated signed 16-bit interleaved PCM */
66 	mlt_audio_s16 = 1, /**< signed 16-bit interleaved PCM */
67 	mlt_audio_s32,     /**< signed 32-bit non-interleaved PCM */
68 	mlt_audio_float,   /**< 32-bit non-interleaved floating point */
69 	mlt_audio_s32le,   /**< signed 32-bit interleaved PCM */
70 	mlt_audio_f32le,   /**< 32-bit interleaved floating point */
71 	mlt_audio_u8       /**< unsigned 8-bit interleaved PCM */
72 }
73 mlt_audio_format;
74 
75 typedef enum
76 {
77 	mlt_channel_auto = 0,      /**< MLT will determine the default configuration based on channel number */
78 	mlt_channel_independent,   /**< channels are not related */
79 	mlt_channel_mono,
80 	mlt_channel_stereo,
81 	mlt_channel_2p1,
82 	mlt_channel_3p0,
83 	mlt_channel_3p0_back,
84 	mlt_channel_4p0,
85 	mlt_channel_quad_back,
86 	mlt_channel_quad_side,
87 	mlt_channel_3p1,
88 	mlt_channel_5p0_back,
89 	mlt_channel_5p0,
90 	mlt_channel_4p1,
91 	mlt_channel_5p1_back,
92 	mlt_channel_5p1,
93 	mlt_channel_6p0,
94 	mlt_channel_6p0_front,
95 	mlt_channel_hexagonal,
96 	mlt_channel_6p1,
97 	mlt_channel_6p1_back,
98 	mlt_channel_6p1_front,
99 	mlt_channel_7p0,
100 	mlt_channel_7p0_front,
101 	mlt_channel_7p1,
102 	mlt_channel_7p1_wide_side,
103 	mlt_channel_7p1_wide_back,
104 }
105 mlt_channel_layout;
106 
107 /** The time string formats */
108 
109 typedef enum
110 {
111 	mlt_time_frames = 0, /**< frame count */
112 	mlt_time_clock,      /**< SMIL clock-value as [[hh:]mm:]ss[.fraction] */
113 	mlt_time_smpte_df,   /**< SMPTE timecode as [[[hh:]mm:]ss{:|;}]frames */
114 	mlt_time_smpte = mlt_time_smpte_df,   /**< Deprecated */
115 	mlt_time_smpte_ndf   /**< SMPTE NDF timecode as [[[hh:]mm:]ss:]frames */
116 }
117 mlt_time_format;
118 
119 /** Interpolation methods for animation keyframes */
120 
121 typedef enum {
122 	mlt_keyframe_discrete = 0, /**< non-interpolated; value changes instantaneously at the key frame */
123 	mlt_keyframe_linear,       /**< simple, constant pace from this key frame to the next */
124 	mlt_keyframe_smooth        /**< eased pacing from this keyframe to the next using a Catmull-Rom spline */
125 }
126 mlt_keyframe_type;
127 
128 /** The relative time qualifiers */
129 
130 typedef enum
131 {
132 	mlt_whence_relative_start = 0, /**< relative to the beginning */
133 	mlt_whence_relative_current,   /**< relative to the current position */
134 	mlt_whence_relative_end        /**< relative to the end */
135 }
136 mlt_whence;
137 
138 /** The recognized subclasses of mlt_service */
139 
140 typedef enum
141 {
142 	invalid_type = 0,           /**< invalid service */
143 	unknown_type,               /**< unknown class */
144 	producer_type,              /**< Producer class */
145 	tractor_type,               /**< Tractor class */
146 	playlist_type,              /**< Playlist class */
147 	multitrack_type,            /**< Multitrack class */
148 	filter_type,                /**< Filter class */
149 	transition_type,            /**< Transition class */
150 	consumer_type,              /**< Consumer class */
151 	field_type                  /**< Field class */
152 }
153 mlt_service_type;
154 
155 /* I don't want to break anyone's applications without warning. -Zach */
156 #ifdef DOUBLE_MLT_POSITION
157 #define MLT_POSITION_FMT "%f"
158 #define MLT_POSITION_MOD(A, B) ((A) - (B) * ((int)((A) / (B))))
159 typedef double mlt_position;
160 #else
161 #define MLT_POSITION_MOD(A, B) ((A) % (B))
162 #define MLT_POSITION_FMT "%d"
163 typedef int32_t mlt_position;
164 #endif
165 
166 /** A rectangle type with coordinates, size, and opacity */
167 
168 typedef struct {
169 	double x; /**< X coordinate */
170 	double y; /**< Y coordinate */
171 	double w; /**< width */
172 	double h; /**< height */
173 	double o; /**< opacity / mix-level */
174 }
175 mlt_rect;
176 
177 /** A tuple of color components */
178 
179 typedef struct {
180 	uint8_t r; /**< red */
181 	uint8_t g; /**< green */
182 	uint8_t b; /**< blue */
183 	uint8_t a; /**< alpha */
184 }
185 mlt_color;
186 
187 typedef struct mlt_audio_s *mlt_audio;                  /**< pointer to Audio object */
188 typedef struct mlt_frame_s *mlt_frame, **mlt_frame_ptr; /**< pointer to Frame object */
189 typedef struct mlt_property_s *mlt_property;            /**< pointer to Property object */
190 typedef struct mlt_properties_s *mlt_properties;        /**< pointer to Properties object */
191 typedef struct mlt_event_struct *mlt_event;             /**< pointer to Event object */
192 typedef struct mlt_service_s *mlt_service;              /**< pointer to Service object */
193 typedef struct mlt_producer_s *mlt_producer;            /**< pointer to Producer object */
194 typedef struct mlt_playlist_s *mlt_playlist;            /**< pointer to Playlist object */
195 typedef struct mlt_multitrack_s *mlt_multitrack;        /**< pointer to Multitrack object */
196 typedef struct mlt_filter_s *mlt_filter;                /**< pointer to Filter object */
197 typedef struct mlt_transition_s *mlt_transition;        /**< pointer to Transition object */
198 typedef struct mlt_tractor_s *mlt_tractor;              /**< pointer to Tractor object */
199 typedef struct mlt_field_s *mlt_field;                  /**< pointer to Field object */
200 typedef struct mlt_consumer_s *mlt_consumer;            /**< pointer to Consumer object */
201 typedef struct mlt_parser_s *mlt_parser;                /**< pointer to Properties object */
202 typedef struct mlt_deque_s *mlt_deque;                  /**< pointer to Deque object */
203 typedef struct mlt_geometry_s *mlt_geometry;            /**< pointer to Geometry object */
204 typedef struct mlt_geometry_item_s *mlt_geometry_item;  /**< pointer to Geometry Item object */
205 typedef struct mlt_profile_s *mlt_profile;              /**< pointer to Profile object */
206 typedef struct mlt_repository_s *mlt_repository;        /**< pointer to Repository object */
207 typedef struct mlt_cache_s *mlt_cache;                  /**< pointer to Cache object */
208 typedef struct mlt_cache_item_s *mlt_cache_item;        /**< pointer to CacheItem object */
209 typedef struct mlt_animation_s *mlt_animation;          /**< pointer to Property Animation object */
210 typedef struct mlt_slices_s *mlt_slices;                /**< pointer to Sliced processing context object */
211 
212 typedef void ( *mlt_destructor )( void * );             /**< pointer to destructor function */
213 typedef char *( *mlt_serialiser )( void *, int length );/**< pointer to serialization function */
214 
215 #define MLT_SERVICE(x)    ( ( mlt_service )( x ) )      /**< Cast to a Service pointer */
216 #define MLT_PRODUCER(x)   ( ( mlt_producer )( x ) )     /**< Cast to a Producer pointer */
217 #define MLT_MULTITRACK(x) ( ( mlt_multitrack )( x ) )   /**< Cast to a Multitrack pointer */
218 #define MLT_PLAYLIST(x)   ( ( mlt_playlist )( x ) )     /**< Cast to a Playlist pointer */
219 #define MLT_TRACTOR(x)    ( ( mlt_tractor )( x ) )      /**< Cast to a Tractor pointer */
220 #define MLT_FILTER(x)     ( ( mlt_filter )( x ) )       /**< Cast to a Filter pointer */
221 #define MLT_TRANSITION(x) ( ( mlt_transition )( x ) )   /**< Cast to a Transition pointer */
222 #define MLT_CONSUMER(x) ( ( mlt_consumer )( x ) )       /**< Cast to a Consumer pointer */
223 #define MLT_FRAME(x)      ( ( mlt_frame )( x ) )        /**< Cast to a Frame pointer */
224 
225 #ifndef MIN
226 #define MIN(x, y) ((x) < (y) ? (x) : (y))
227 #endif
228 #ifndef MAX
229 #define MAX(x, y) ((x) > (y) ? (x) : (y))
230 #endif
231 #ifndef CLAMP
232 #define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))
233 #endif
234 
235 #ifdef _WIN32
236 #include <pthread.h>
237 /* Win32 compatibility function declarations */
238 #if !defined(__MINGW32__)
239 extern int usleep(unsigned int useconds);
240 #endif
241 #ifndef WIN_PTHREADS_TIME_H
242 extern int nanosleep( const struct timespec * rqtp, struct timespec * rmtp );
243 #endif
244 extern int setenv(const char *name, const char *value, int overwrite);
245 extern char* getlocale();
246 extern FILE* win32_fopen(const char *filename_utf8, const char *mode_utf8);
247 #include <time.h>
248 extern char* strptime(const char *buf, const char *fmt, struct tm *tm);
249 #define mlt_fopen win32_fopen
250 #define MLT_DIRLIST_DELIMITER ";"
251 #else
252 #define mlt_fopen fopen
253 #define MLT_DIRLIST_DELIMITER ":"
254 #endif /* ifdef _WIN32 */
255 
256 #ifdef __cplusplus
257 }
258 #endif
259 
260 #endif
261