// Create an MltInput for an image with the given format and dimensions.
static MltInput* create_input( mlt_properties properties, mlt_image_format format, int aspect_width, int aspect_height, int width, int height )
{
- MltInput* input = new MltInput();
+ MltInput* input = new MltInput( format );
if ( format == mlt_image_rgb24a || format == mlt_image_opengl ) {
// TODO: Get the color space if available.
input->useFlatInput( FORMAT_RGBA_POSTMULTIPLIED_ALPHA, width, height );
if ( *format == mlt_image_glsl ) {
mlt_service leaf_service = (mlt_service) *image;
+ if ( leaf_service == (mlt_service) -1 ) {
+ // Something on the way requested conversion to mlt_glsl,
+ // but never added an effect. Don't build a Movit chain;
+ // just do the conversion and we're done.
+ mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
+ MltInput *input = GlslManager::get_input( producer, frame );
+ *image = GlslManager::get_input_pixel_pointer( producer, frame );
+ *format = input->get_format();
+ delete input;
+ GlslManager::get_instance()->unlock_service( frame );
+ return convert_on_cpu( frame, image, format, output_format );
+ }
+
// Construct the chain unless we already have a good one.
finalize_movit_chain( leaf_service, frame );
#ifndef MLT_MOVIT_INPUT_H
#define MLT_MOVIT_INPUT_H
+#include <framework/mlt_types.h>
+
#include <movit/flat_input.h>
#include <movit/ycbcr_input.h>
#include <movit/effect_chain.h>
class MltInput
{
public:
- MltInput();
+ MltInput( mlt_image_format format );
~MltInput();
void useFlatInput(movit::MovitPixelFormat pix_fmt, unsigned width, unsigned height);
void invalidate_pixel_data();
movit::Input *get_input() { return input; }
+ // The original pixel format that was used to create this MltInput,
+ // in case we change our mind later and want to convert on the CPU instead.
+ mlt_image_format get_format() const { return m_format; }
+
private:
+ mlt_image_format m_format;
unsigned m_width, m_height;
// Note: Owned by the EffectChain, so should not be deleted by us.
movit::Input *input;