MLT  7.34.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_export.h"
29 #include "mlt_image.h"
30 #include "mlt_properties.h"
31 #include "mlt_service.h"
32 
37 typedef int (*mlt_get_image)(mlt_frame self,
38  uint8_t **buffer,
39  mlt_image_format *format,
40  int *width,
41  int *height,
42  int writable);
43 
48 typedef int (*mlt_get_audio)(mlt_frame self,
49  void **buffer,
50  mlt_audio_format *format,
51  int *frequency,
52  int *channels,
53  int *samples);
54 
91 {
92  struct mlt_properties_s parent;
102  uint8_t **image,
103  mlt_image_format *input,
104  mlt_image_format output);
105 
114  void **audio,
115  mlt_audio_format *input,
116  mlt_audio_format output);
117 
122 };
123 
124 #define MLT_FRAME_PROPERTIES(frame) (&(frame)->parent)
125 #define MLT_FRAME_SERVICE_STACK(frame) ((frame)->stack_service)
126 #define MLT_FRAME_IMAGE_STACK(frame) ((frame)->stack_image)
127 #define MLT_FRAME_AUDIO_STACK(frame) ((frame)->stack_audio)
128 
131 MLT_EXPORT int mlt_frame_is_test_card(mlt_frame self);
132 MLT_EXPORT int mlt_frame_is_test_audio(mlt_frame self);
133 MLT_EXPORT double mlt_frame_get_aspect_ratio(mlt_frame self);
134 MLT_EXPORT int mlt_frame_set_aspect_ratio(mlt_frame self, double value);
137 MLT_EXPORT int mlt_frame_set_position(mlt_frame self, mlt_position value);
138 MLT_EXPORT int mlt_frame_set_image(mlt_frame self, uint8_t *image, int size, mlt_destructor destroy);
139 MLT_EXPORT int mlt_frame_set_alpha(mlt_frame self, uint8_t *alpha, int size, mlt_destructor destroy);
140 MLT_EXPORT void mlt_frame_replace_image(
141  mlt_frame self, uint8_t *image, mlt_image_format format, int width, int height);
142 MLT_EXPORT int mlt_frame_get_image(mlt_frame self,
143  uint8_t **buffer,
144  mlt_image_format *format,
145  int *width,
146  int *height,
147  int writable);
148 MLT_EXPORT uint8_t *mlt_frame_get_alpha(mlt_frame self);
149 MLT_EXPORT uint8_t *mlt_frame_get_alpha_size(mlt_frame self, int *size);
150 MLT_EXPORT int mlt_frame_get_audio(mlt_frame self,
151  void **buffer,
152  mlt_audio_format *format,
153  int *frequency,
154  int *channels,
155  int *samples);
156 MLT_EXPORT int mlt_frame_set_audio(
157  mlt_frame self, void *buffer, mlt_audio_format, int size, mlt_destructor);
158 MLT_EXPORT unsigned char *mlt_frame_get_waveform(mlt_frame self, int w, int h);
159 MLT_EXPORT int mlt_frame_push_get_image(mlt_frame self, mlt_get_image get_image);
161 MLT_EXPORT int mlt_frame_push_frame(mlt_frame self, mlt_frame that);
163 MLT_EXPORT int mlt_frame_push_service(mlt_frame self, void *that);
164 MLT_EXPORT void *mlt_frame_pop_service(mlt_frame self);
165 MLT_EXPORT int mlt_frame_push_service_int(mlt_frame self, int that);
167 MLT_EXPORT int mlt_frame_push_audio(mlt_frame self, void *that);
168 MLT_EXPORT void *mlt_frame_pop_audio(mlt_frame self);
171 MLT_EXPORT void mlt_frame_close(mlt_frame self);
174 MLT_EXPORT mlt_frame mlt_frame_clone(mlt_frame self, int is_deep);
175 MLT_EXPORT mlt_frame mlt_frame_clone_audio(mlt_frame self, int is_deep);
176 MLT_EXPORT mlt_frame mlt_frame_clone_image(mlt_frame self, int is_deep);
177 
178 /* convenience functions */
179 MLT_EXPORT void mlt_frame_write_ppm(mlt_frame frame);
180 
182 #define RGB2YUV_601_SCALED(r, g, b, y, u, v) \
183  y = ((263 * r + 516 * g + 100 * b) >> 10) + 16; \
184  u = ((-152 * r - 300 * g + 450 * b) >> 10) + 128; \
185  v = ((450 * r - 377 * g - 73 * b) >> 10) + 128;
187 #define RGB2UV_601_SCALED(r, g, b, u, v) \
188  u = ((-152 * r - 300 * g + 450 * b) >> 10) + 128; \
189  v = ((450 * r - 377 * g - 73 * b) >> 10) + 128;
190 
192 #define YUV2RGB_601_SCALED(y, u, v, r, g, b) \
193  r = ((1192 * (y - 16) + 1634 * (v - 128)) >> 10); \
194  g = ((1192 * (y - 16) - 832 * (v - 128) - 401 * (u - 128)) >> 10); \
195  b = ((1192 * (y - 16) + 2066 * (u - 128)) >> 10); \
196  r = r < 0 ? 0 : r > 255 ? 255 : r; \
197  g = g < 0 ? 0 : g > 255 ? 255 : g; \
198  b = b < 0 ? 0 : b > 255 ? 255 : b;
199 
200 #endif
Audio class.
double ended queue
MLT_EXPORT void mlt_frame_write_ppm(mlt_frame frame)
Definition: mlt_frame.c:833
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:37
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:48
Image class.
Properties class declaration.
interface declaration for all service classes
int32_t mlt_position
Definition: mlt_types.h:255
void(* mlt_destructor)(void *)
pointer to destructor function
Definition: mlt_types.h:307
mlt_image_format
The set of supported image formats.
Definition: mlt_types.h:40
mlt_audio_format
The set of supported audio formats.
Definition: mlt_types.h:57
Double-Ended Queue (deque) class.
Definition: mlt_deque.c:48
Frame class.
Definition: mlt_frame.h:91
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:574
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:870
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:927
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:120
mlt_frame mlt_frame_clone_audio(mlt_frame self, int is_deep)
Make a copy of a frame and audio.
Definition: mlt_frame.c:1030
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:101
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:121
void mlt_frame_close(mlt_frame self)
Destroy the frame.
Definition: mlt_frame.c:818
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:805
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:613
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:908
struct mlt_properties_s parent
A frame extends properties.
Definition: mlt_frame.h:92
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:499
mlt_deque stack_image
the image processing stack of operations and data
Definition: mlt_frame.h:118
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:700
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:113
mlt_deque stack_audio
the audio processing stack of operations and data
Definition: mlt_frame.h:119
mlt_frame mlt_frame_clone_image(mlt_frame self, int is_deep)
Make a copy of a frame and image.
Definition: mlt_frame.c:1102
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:726
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:549
Producer abstract service class.
Definition: mlt_producer.h:71
Properties class.
Definition: mlt_properties.h:41
Service abstract base class.
Definition: mlt_service.h:59