mlt 0.7.6
Public Member Functions | Data Fields | Private Attributes

mlt_frame_s Struct Reference

Frame class. More...

#include <mlt_frame.h>

Inheritance diagram for mlt_frame_s:
mlt_properties_s

Public Member Functions

const char * mlt_audio_format_name (mlt_audio_format format)
 Get the short name for an audio format.
int mlt_audio_format_size (mlt_audio_format format, int samples, int channels)
 Get the amount of bytes needed for a block of audio.
mlt_frame mlt_frame_clone (mlt_frame self, int is_deep)
 Make a copy of a frame.
void mlt_frame_close (mlt_frame self)
 Destroy the frame.
uint8_t * mlt_frame_get_alpha_mask (mlt_frame self)
 Get the alpha channel associated to the frame.
double mlt_frame_get_aspect_ratio (mlt_frame self)
 Get the sample aspect ratio of the frame.
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.
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.
mlt_producer mlt_frame_get_original_producer (mlt_frame self)
 Get the end service that produced self frame.
mlt_position mlt_frame_get_position (mlt_frame self)
 Get the time position of this frame.
unsigned char * mlt_frame_get_waveform (mlt_frame self, int w, int h)
 Get audio on a frame as a waveform image.
mlt_frame mlt_frame_init (mlt_service service)
 Construct a frame object.
int mlt_frame_is_test_audio (mlt_frame self)
 Determine if the frame will produce audio from a test card.
int mlt_frame_is_test_card (mlt_frame self)
 Determine if the frame will produce a test card image.
void * mlt_frame_pop_audio (mlt_frame self)
 Pop an audio item from the stack.
mlt_frame mlt_frame_pop_frame (mlt_frame self)
 Pop a frame.
mlt_get_image mlt_frame_pop_get_image (mlt_frame self)
 Pop a get_image callback.
void * mlt_frame_pop_service (mlt_frame self)
 Pop a service.
int mlt_frame_pop_service_int (mlt_frame self)
 Pop a number.
mlt_properties mlt_frame_properties (mlt_frame self)
 Get a frame's properties.
int mlt_frame_push_audio (mlt_frame self, void *that)
 Push an audio item on the stack.
int mlt_frame_push_frame (mlt_frame self, mlt_frame that)
 Push a frame.
int mlt_frame_push_get_image (mlt_frame self, mlt_get_image get_image)
 Stack a get_image callback.
int mlt_frame_push_service (mlt_frame self, void *that)
 Push a service.
int mlt_frame_push_service_int (mlt_frame self, int that)
 Push a number.
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.
mlt_deque mlt_frame_service_stack (mlt_frame self)
 Return the service stack.
int mlt_frame_set_alpha (mlt_frame self, uint8_t *alpha, int size, mlt_destructor destroy)
 Set a new alpha channel on the frame.
int mlt_frame_set_aspect_ratio (mlt_frame self, double value)
 Set the sample aspect ratio of the frame.
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.
int mlt_frame_set_image (mlt_frame self, uint8_t *image, int size, mlt_destructor destroy)
 Set a new image on the frame.
int mlt_frame_set_position (mlt_frame self, mlt_position value)
 Set the time position of this frame.
mlt_properties mlt_frame_unique_properties (mlt_frame self, mlt_service service)
 Get or create a properties object unique to this service instance.
const char * mlt_image_format_name (mlt_image_format format)
 Get the short name for an image format.
int mlt_image_format_size (mlt_image_format format, int width, int height, int *bpp)
 Get the number of bytes needed for an image.
int mlt_sample_calculator (float fps, int frequency, int64_t position)
 Determine the number of samples that belong in a frame at a time position.
int64_t mlt_sample_calculator_to_now (float fps, int frequency, int64_t position)
 Determine the number of samples that belong before a time position.

Data Fields

int(* convert_audio )(mlt_frame self, void **audio, mlt_audio_format *input, mlt_audio_format output)
 Convert the audio format (callback function).
int(* convert_image )(mlt_frame self, uint8_t **image, mlt_image_format *input, mlt_image_format output)
 Convert the image format (callback function).
uint8_t *(* get_alpha_mask )(mlt_frame self)
 Get the alpha channel (callback function).

Private Attributes

int is_processing
 indicates if a frame is or was processed by the parallel consumer
struct mlt_properties_s parent
 A frame extends properties.
mlt_deque stack_audio
 the audio processing stack of operations and data
mlt_deque stack_image
 the image processing stack of operations and data
mlt_deque stack_service
 a general purpose data stack

Detailed Description

Frame class.

The frame is the primary data object that gets passed around to and through services.

Property:
test_image set if the frame holds a "test card" image
Property:
test_audio set if the frame holds "test card" audio
Property:
_producer holds a reference to the frame's end producer
Property:
_speed the current speed of the producer that generated the frame
Property:
_position the position of the frame
Property:
meta.* holds metadata
Property:
hide set to 1 to hide the video, 2 to mute the audio
Property:
last_track a flag to indicate an end-of-tracks frame
Property:
previous frame a reference to the unfiltered preceding frame (no speed factor applied, only available when _need_previous_next is set on the producer)
Property:
next frame a reference to the unfiltered following frame (no speed factor applied, only available when _need_previous_next is set on the producer)
Property:
colorspace the standard for luma coefficients
Property:
force_full_luma luma range handling, set to -1 for pass-through, 1 for full range, 0 for scaling
Property:
audio_frequency the sample rate of the audio
Property:
audio_channels the number of audio channels
Property:
audio_samples the number of audio samples
Property:
audio_format the mlt_audio_format for the audio on this frame
Property:
format the mlt_image_format of the image on this frame
Property:
width the horizontal resolution of the image
Property:
height the vertical resolution of the image
Property:
aspect_ratio the sample aspect ratio of the image

Member Function Documentation

const char * mlt_audio_format_name ( mlt_audio_format  format)

Get the short name for an audio format.

You do not need to deallocate the returned string.

Parameters:
formatan audio format enum
Returns:
a string for the name of the image format
int mlt_audio_format_size ( mlt_audio_format  format,
int  samples,
int  channels 
)

Get the amount of bytes needed for a block of audio.

Parameters:
formatan audio format enum
samplesthe number of samples per channel
channelsthe number of channels
Returns:
the number of bytes
mlt_frame mlt_frame_clone ( mlt_frame  self,
int  is_deep 
)

Make a copy of a frame.

This does not copy the get_image/get_audio processing stacks or any data properties other than the audio and image.

Parameters:
selfthe frame to clone
is_deepa boolean to indicate whether to make a deep copy of the audio and video data chunks or to make a shallow copy by pointing to the supplied frame
Returns:
a almost-complete copy of the frame
Todo:
copy the processing deques
void mlt_frame_close ( mlt_frame  self)

Destroy the frame.

Parameters:
selfa frame
uint8_t * mlt_frame_get_alpha_mask ( mlt_frame  self)

Get the alpha channel associated to the frame.

Parameters:
selfa frame
Returns:
the alpha channel
double mlt_frame_get_aspect_ratio ( mlt_frame  self)

Get the sample aspect ratio of the frame.

Parameters:
selfa frame
Returns:
the aspect ratio
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.

You should express the desired format, frequency, channels, and samples as inputs. As long as the loader producer was used to generate this or the audioconvert filter was attached, then you will get the audio back in the format you desire. However, you do not always get the channels and samples you request depending on properties and filters. You do not need to supply a pre-allocated buffer, but you should always supply the desired audio format. The audio is always in interleaved format. You should use the mlt_sample_calculator to determine the number of samples you want.

Parameters:
selfa frame
[out]bufferan audio buffer
[in,out]formatthe audio format
[in,out]frequencythe sample rate
[in,out]channels
[in,out]samplesthe number of samples per frame
Returns:
true if error
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.

You should express the desired format, width, and height as inputs. As long as the loader producer was used to generate this or the imageconvert filter was attached, then you will get the image back in the format you desire. However, you do not always get the width and height you request depending on properties and filters. You do not need to supply a pre-allocated buffer, but you should always supply the desired image format.

Parameters:
selfa frame
[out]bufferan image buffer
[in,out]formatthe image format
[in,out]widththe horizontal size in pixels
[in,out]heightthe vertical size in pixels
writablewhether or not you will need to be able to write to the memory returned in buffer
Returns:
true if error
Todo:
Better describe the width and height as inputs.
mlt_producer mlt_frame_get_original_producer ( mlt_frame  self)

Get the end service that produced self frame.

This fetches the first producer of the frame and not any producers that encapsulate it.

Parameters:
selfa frame
Returns:
a producer
mlt_position mlt_frame_get_position ( mlt_frame  self)

Get the time position of this frame.

Parameters:
selfa frame
Returns:
the position
unsigned char * mlt_frame_get_waveform ( mlt_frame  self,
int  w,
int  h 
)

Get audio on a frame as a waveform image.

This generates an 8-bit grayscale image representation of the audio in a frame. Currently, this only really works for 2 channels. This allocates the bitmap using mlt_pool so you should release the return value with mlt_pool_release.

Parameters:
selfa frame
wthe width of the image
hthe height of the image to create
Returns:
a pointer to a new bitmap
mlt_frame mlt_frame_init ( mlt_service  service)

Construct a frame object.

Parameters:
servicethe pointer to any service that can provide access to the profile
Returns:
a frame object on success or NULL if there was an allocation error
int mlt_frame_is_test_audio ( mlt_frame  self)

Determine if the frame will produce audio from a test card.

Parameters:
selfa frame
Returns:
true (non-zero) if this will produce from a test card
int mlt_frame_is_test_card ( mlt_frame  self)

Determine if the frame will produce a test card image.

Parameters:
selfa frame
Returns:
true (non-zero) if this will produce from a test card
void * mlt_frame_pop_audio ( mlt_frame  self)

Pop an audio item from the stack.

Parameters:
selfa frame
Returns:
an opaque pointer to something that was pushed onto the frame's audio stack
mlt_frame mlt_frame_pop_frame ( mlt_frame  self)

Pop a frame.

Parameters:
selfa frame
Returns:
a frame that was previously pushed
mlt_get_image mlt_frame_pop_get_image ( mlt_frame  self)

Pop a get_image callback.

Parameters:
selfa frame
Returns:
the get_image callback
void * mlt_frame_pop_service ( mlt_frame  self)

Pop a service.

Parameters:
selfa frame
Returns:
an opaque pointer to something previously pushed
int mlt_frame_pop_service_int ( mlt_frame  self)

Pop a number.

Parameters:
selfa frame
Returns:
an integer that was previously pushed
mlt_properties mlt_frame_properties ( mlt_frame  self)

Get a frame's properties.

Parameters:
selfa frame
Returns:
the frame's properties or NULL if an invalid frame is supplied
int mlt_frame_push_audio ( mlt_frame  self,
void *  that 
)

Push an audio item on the stack.

Parameters:
selfa frame
thatan opaque pointer
Returns:
true if error
int mlt_frame_push_frame ( mlt_frame  self,
mlt_frame  that 
)

Push a frame.

Parameters:
selfa frame
thatthe frame to push onto self
Returns:
true if error
int mlt_frame_push_get_image ( mlt_frame  self,
mlt_get_image  get_image 
)

Stack a get_image callback.

Parameters:
selfa frame
theget_image callback
Returns:
true if error
int mlt_frame_push_service ( mlt_frame  self,
void *  that 
)

Push a service.

Parameters:
selfa frame
thatan opaque pointer
Returns:
true if error
int mlt_frame_push_service_int ( mlt_frame  self,
int  that 
)

Push a number.

Parameters:
selfa frame
thatan integer
Returns:
true if error
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.

This might prove to be unreliable and restrictive - the idea is that a transition which normally uses two images may decide to only use the b frame (ie: in the case of a composite where the b frame completely obscures the a frame).

The image must be writable and the destructor for the image itself must be taken care of on another frame and that frame cannot have a replace applied to it... Further it assumes that no alpha mask is in use.

For these reasons, it can only be used in a specific situation - when you have multiple tracks each with their own transition and these transitions are applied in a strictly reversed order (ie: highest numbered [lowest track] is processed first).

More reliable approach - the cases should be detected during the process phase and the upper tracks should simply not be invited to stack...

Parameters:
selfa frame
imagea new image
formatthe image format
widththe width of the new image
heightthe height of the new image
mlt_deque mlt_frame_service_stack ( mlt_frame  self)

Return the service stack.

Parameters:
selfa frame
Returns:
the service stack
int mlt_frame_set_alpha ( mlt_frame  self,
uint8_t *  alpha,
int  size,
mlt_destructor  destroy 
)

Set a new alpha channel on the frame.

Parameters:
selfa frame
alphaa pointer to the alpha channel
sizethe size of the alpha channel in bytes (optional)
destroya function to deallocate alpha when the frame is closed (optional)
Returns:
true if error
int mlt_frame_set_aspect_ratio ( mlt_frame  self,
double  value 
)

Set the sample aspect ratio of the frame.

Parameters:
selfa frame
valuethe new image sample aspect ratio
Returns:
true if error
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.

Parameters:
selfa frame
bufferan buffer containing audio samples
formatthe format of the audio in the buffer
sizethe total size of the buffer (optional)
destructora function that releases or deallocates the buffer
Returns:
true if error
int mlt_frame_set_image ( mlt_frame  self,
uint8_t *  image,
int  size,
mlt_destructor  destroy 
)

Set a new image on the frame.

Parameters:
selfa frame
imagea pointer to the raw image data
sizethe size of the image data in bytes (optional)
destroya function to deallocate image when the frame is closed (optional)
Returns:
true if error
int mlt_frame_set_position ( mlt_frame  self,
mlt_position  value 
)

Set the time position of this frame.

Parameters:
selfa frame
valuethe position
Returns:
true if error
mlt_properties mlt_frame_unique_properties ( mlt_frame  self,
mlt_service  service 
)

Get or create a properties object unique to this service instance.

Use this function to hold a service's processing parameters for this particular frame. Set the parameters in the service's process function. Then, get the parameters in the function it pushes to the frame's audio or image stack. This makes the service more parallel by reducing race conditions and less sensitive to multiple instances (by not setting a non-unique property on the frame). Creation and destruction of the properties object is handled automatically.

Parameters:
selfa frame
servicea service
Returns:
a properties object
const char * mlt_image_format_name ( mlt_image_format  format)

Get the short name for an image format.

Parameters:
formatthe image format
Returns:
a string
int mlt_image_format_size ( mlt_image_format  format,
int  width,
int  height,
int *  bpp 
)

Get the number of bytes needed for an image.

Parameters:
formatthe image format
widthwidth of the image in pixels
heightheight of the image in pixels
[out]bppthe number of bytes per pixel (optional)
Returns:
the number of bytes
int mlt_sample_calculator ( float  fps,
int  frequency,
int64_t  position 
)

Determine the number of samples that belong in a frame at a time position.

Parameters:
fpsthe frame rate
frequencythe sample rate
positionthe time position
Returns:
the number of samples per channel
int64_t mlt_sample_calculator_to_now ( float  fps,
int  frequency,
int64_t  position 
)

Determine the number of samples that belong before a time position.

Parameters:
fpsthe frame rate
frequencythe sample rate
positionthe time position
Returns:
the number of samples per channel
Bug:
Will this break when mlt_position is converted to double?

Field Documentation

int( * mlt_frame_s::convert_audio)(mlt_frame self, void **audio, mlt_audio_format *input, mlt_audio_format output)

Convert the audio format (callback function).

Parameters:
selfa frame
[in,out]audioa buffer of audio data
[in,out]inputthe audio format of supplied data
outputthe audio format to which to convert
Returns:
true if error
int( * mlt_frame_s::convert_image)(mlt_frame self, uint8_t **image, mlt_image_format *input, mlt_image_format output)

Convert the image format (callback function).

Parameters:
selfa frame
[in,out]imagea buffer of image data
[in,out]inputthe image format of supplied image data
outputthe image format to which to convert
Returns:
true if error

Get the alpha channel (callback function).

Parameters:
selfa frame
Returns:
the 8-bit alpha channel

indicates if a frame is or was processed by the parallel consumer

A frame extends properties.

the audio processing stack of operations and data

the image processing stack of operations and data

a general purpose data stack


The documentation for this struct was generated from the following files:
TWiki Appliance - Powered by TurnKey Linux