MLT  7.24.0
mlt_frame.h
Go to the documentation of this file.
1 
23 #ifndef MLT_FRAME_H
24 #define MLT_FRAME_H
25 
26 #include "mlt_audio.h"
27 #include "mlt_deque.h"
28 #include "mlt_image.h"
29 #include "mlt_properties.h"
30 #include "mlt_service.h"
31 
36 typedef int (*mlt_get_image)(mlt_frame self,
37  uint8_t **buffer,
38  mlt_image_format *format,
39  int *width,
40  int *height,
41  int writable);
42 
47 typedef int (*mlt_get_audio)(mlt_frame self,
48  void **buffer,
49  mlt_audio_format *format,
50  int *frequency,
51  int *channels,
52  int *samples);
53 
90 {
91  struct mlt_properties_s parent;
101  uint8_t **image,
102  mlt_image_format *input,
103  mlt_image_format output);
104 
113  void **audio,
114  mlt_audio_format *input,
115  mlt_audio_format output);
116 
121 };
122 
123 #define MLT_FRAME_PROPERTIES(frame) (&(frame)->parent)
124 #define MLT_FRAME_SERVICE_STACK(frame) ((frame)->stack_service)
125 #define MLT_FRAME_IMAGE_STACK(frame) ((frame)->stack_image)
126 #define MLT_FRAME_AUDIO_STACK(frame) ((frame)->stack_audio)
127 
133 extern int mlt_frame_set_aspect_ratio(mlt_frame self, double value);
137 extern int mlt_frame_set_image(mlt_frame self, uint8_t *image, int size, mlt_destructor destroy);
138 extern int mlt_frame_set_alpha(mlt_frame self, uint8_t *alpha, int size, mlt_destructor destroy);
140  mlt_frame self, uint8_t *image, mlt_image_format format, int width, int height);
142  uint8_t **buffer,
143  mlt_image_format *format,
144  int *width,
145  int *height,
146  int writable);
147 extern uint8_t *mlt_frame_get_alpha(mlt_frame self);
148 extern uint8_t *mlt_frame_get_alpha_size(mlt_frame self, int *size);
150  void **buffer,
151  mlt_audio_format *format,
152  int *frequency,
153  int *channels,
154  int *samples);
156  mlt_frame self, void *buffer, mlt_audio_format, int size, mlt_destructor);
157 extern unsigned char *mlt_frame_get_waveform(mlt_frame self, int w, int h);
160 extern int mlt_frame_push_frame(mlt_frame self, mlt_frame that);
162 extern int mlt_frame_push_service(mlt_frame self, void *that);
163 extern void *mlt_frame_pop_service(mlt_frame self);
164 extern int mlt_frame_push_service_int(mlt_frame self, int that);
166 extern int mlt_frame_push_audio(mlt_frame self, void *that);
167 extern void *mlt_frame_pop_audio(mlt_frame self);
170 extern void mlt_frame_close(mlt_frame self);
173 extern mlt_frame mlt_frame_clone(mlt_frame self, int is_deep);
174 extern mlt_frame mlt_frame_clone_audio(mlt_frame self, int is_deep);
175 extern mlt_frame mlt_frame_clone_image(mlt_frame self, int is_deep);
176 
177 /* convenience functions */
178 extern void mlt_frame_write_ppm(mlt_frame frame);
179 
181 #define RGB2YUV_601_SCALED(r, g, b, y, u, v) \
182  y = ((263 * r + 516 * g + 100 * b) >> 10) + 16; \
183  u = ((-152 * r - 300 * g + 450 * b) >> 10) + 128; \
184  v = ((450 * r - 377 * g - 73 * b) >> 10) + 128;
186 #define RGB2UV_601_SCALED(r, g, b, u, v) \
187  u = ((-152 * r - 300 * g + 450 * b) >> 10) + 128; \
188  v = ((450 * r - 377 * g - 73 * b) >> 10) + 128;
189 
191 #define YUV2RGB_601_SCALED(y, u, v, r, g, b) \
192  r = ((1192 * (y - 16) + 1634 * (v - 128)) >> 10); \
193  g = ((1192 * (y - 16) - 832 * (v - 128) - 401 * (u - 128)) >> 10); \
194  b = ((1192 * (y - 16) + 2066 * (u - 128)) >> 10); \
195  r = r < 0 ? 0 : r > 255 ? 255 : r; \
196  g = g < 0 ? 0 : g > 255 ? 255 : g; \
197  b = b < 0 ? 0 : b > 255 ? 255 : b;
198 
199 #endif
Audio class.
double ended queue
void mlt_frame_write_ppm(mlt_frame frame)
Definition: mlt_frame.c:834
int(* mlt_get_image)(mlt_frame self, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable)
Callback function to get video data.
Definition: mlt_frame.h:36
int(* mlt_get_audio)(mlt_frame self, void **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples)
Callback function to get audio data.
Definition: mlt_frame.h:47
Image class.
Properties class declaration.
interface declaration for all service classes
int32_t mlt_position
Definition: mlt_types.h:217
void(* mlt_destructor)(void *)
pointer to destructor function
Definition: mlt_types.h:269
mlt_image_format
The set of supported image formats.
Definition: mlt_types.h:44
mlt_audio_format
The set of supported audio formats.
Definition: mlt_types.h:60
Double-Ended Queue (deque) class.
Definition: mlt_deque.c:48
Frame class.
Definition: mlt_frame.h:90
mlt_position mlt_frame_get_position(mlt_frame self)
Get the time position of this frame.
Definition: mlt_frame.c:150
uint8_t * mlt_frame_get_alpha_size(mlt_frame self, int *size)
Get the alpha channel associated to the frame and its size.
Definition: mlt_frame.c:575
double mlt_frame_get_aspect_ratio(mlt_frame self)
Get the sample aspect ratio of the frame.
Definition: mlt_frame.c:120
int mlt_frame_set_alpha(mlt_frame self, uint8_t *alpha, int size, mlt_destructor destroy)
Set a new alpha channel on the frame.
Definition: mlt_frame.c:349
int mlt_frame_push_audio(mlt_frame self, void *that)
Push an audio item on the stack.
Definition: mlt_frame.c:295
mlt_properties mlt_frame_unique_properties(mlt_frame self, mlt_service service)
Get or create a properties object unique to this service instance.
Definition: mlt_frame.c:871
int mlt_frame_is_test_card(mlt_frame self)
Determine if the frame will produce a test card image.
Definition: mlt_frame.c:90
mlt_frame mlt_frame_clone(mlt_frame self, int is_deep)
Make a copy of a frame.
Definition: mlt_frame.c:928
int mlt_frame_set_aspect_ratio(mlt_frame self, double value)
Set the sample aspect ratio of the frame.
Definition: mlt_frame.c:133
mlt_frame mlt_frame_pop_frame(mlt_frame self)
Pop a frame.
Definition: mlt_frame.c:232
int mlt_frame_set_image(mlt_frame self, uint8_t *image, int size, mlt_destructor destroy)
Set a new image on the frame.
Definition: mlt_frame.c:334
mlt_frame mlt_frame_init(mlt_service service)
Construct a frame object.
Definition: mlt_frame.c:41
int mlt_frame_is_test_audio(mlt_frame self)
Determine if the frame will produce audio from a test card.
Definition: mlt_frame.c:105
mlt_deque stack_service
a general purpose data stack
Definition: mlt_frame.h:119
mlt_frame mlt_frame_clone_audio(mlt_frame self, int is_deep)
Make a copy of a frame and audio.
Definition: mlt_frame.c:1031
int(* convert_image)(mlt_frame self, uint8_t **image, mlt_image_format *input, mlt_image_format output)
Convert the image format (callback function).
Definition: mlt_frame.h:100
int mlt_frame_set_position(mlt_frame self, mlt_position value)
Set the time position of this frame.
Definition: mlt_frame.c:179
mlt_properties mlt_frame_properties(mlt_frame self)
Get a frame's properties.
Definition: mlt_frame.c:78
int is_processing
indicates if a frame is or was processed by the parallel consumer
Definition: mlt_frame.h:120
void mlt_frame_close(mlt_frame self)
Destroy the frame.
Definition: mlt_frame.c:819
void mlt_frame_replace_image(mlt_frame self, uint8_t *image, mlt_image_format format, int width, int height)
Replace image stack with the information provided.
Definition: mlt_frame.c:380
int mlt_frame_pop_service_int(mlt_frame self)
Pop a number.
Definition: mlt_frame.c:282
int mlt_frame_push_service_int(mlt_frame self, int that)
Push a number.
Definition: mlt_frame.c:270
int mlt_frame_push_get_image(mlt_frame self, mlt_get_image get_image)
Stack a get_image callback.
Definition: mlt_frame.c:195
mlt_producer mlt_frame_get_original_producer(mlt_frame self)
Get the end service that produced self frame.
Definition: mlt_frame.c:806
int mlt_frame_push_service(mlt_frame self, void *that)
Push a service.
Definition: mlt_frame.c:245
mlt_deque mlt_frame_service_stack(mlt_frame self)
Return the service stack.
Definition: mlt_frame.c:319
mlt_position mlt_frame_original_position(mlt_frame self)
Get the original time position of this frame.
Definition: mlt_frame.c:165
int mlt_frame_get_audio(mlt_frame self, void **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples)
Get the audio associated to the frame.
Definition: mlt_frame.c:614
void * mlt_frame_pop_service(mlt_frame self)
Pop a service.
Definition: mlt_frame.c:257
mlt_properties mlt_frame_get_unique_properties(mlt_frame self, mlt_service service)
Get a properties object unique to this service instance.
Definition: mlt_frame.c:909
struct mlt_properties_s parent
A frame extends properties.
Definition: mlt_frame.h:91
int mlt_frame_get_image(mlt_frame self, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable)
Get the image associated to the frame.
Definition: mlt_frame.c:500
mlt_deque stack_image
the image processing stack of operations and data
Definition: mlt_frame.h:117
int mlt_frame_set_audio(mlt_frame self, void *buffer, mlt_audio_format format, int size, mlt_destructor destructor)
Set the audio on a frame.
Definition: mlt_frame.c:701
mlt_get_image mlt_frame_pop_get_image(mlt_frame self)
Pop a get_image callback.
Definition: mlt_frame.c:207
int(* convert_audio)(mlt_frame self, void **audio, mlt_audio_format *input, mlt_audio_format output)
Convert the audio format (callback function).
Definition: mlt_frame.h:112
mlt_deque stack_audio
the audio processing stack of operations and data
Definition: mlt_frame.h:118
mlt_frame mlt_frame_clone_image(mlt_frame self, int is_deep)
Make a copy of a frame and image.
Definition: mlt_frame.c:1103
unsigned char * mlt_frame_get_waveform(mlt_frame self, int w, int h)
Get audio on a frame as a waveform image.
Definition: mlt_frame.c:727
int mlt_frame_push_frame(mlt_frame self, mlt_frame that)
Push a frame.
Definition: mlt_frame.c:220
void * mlt_frame_pop_audio(mlt_frame self)
Pop an audio item from the stack.
Definition: mlt_frame.c:307
uint8_t * mlt_frame_get_alpha(mlt_frame self)
Get the alpha channel associated to the frame (without creating if it has not).
Definition: mlt_frame.c:550
Producer abstract service class.
Definition: mlt_producer.h:70
Properties class.
Definition: mlt_properties.h:40
Service abstract base class.
Definition: mlt_service.h:58