]> git.sesse.net Git - mlt/commitdiff
Convert on CPU if we are asked to finalize an empty Movit chain.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 7 Apr 2014 22:07:40 +0000 (00:07 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 7 Apr 2014 22:08:17 +0000 (00:08 +0200)
This fixes an issue with interlaced content and no resize or other
normalizers in actual use.

src/modules/opengl/filter_movit_convert.cpp
src/modules/opengl/mlt_movit_input.cpp
src/modules/opengl/mlt_movit_input.h

index 46d640c7fea569c2c33ab006e0458b8dccb74abd..f9954ebab3de3d0408334dda56aafc1fcbc5c7fa 100644 (file)
@@ -378,7 +378,7 @@ static int movit_render( EffectChain *chain, mlt_frame frame, mlt_image_format *
 // 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 );
@@ -464,6 +464,19 @@ static int convert_image( mlt_frame frame, uint8_t **image, mlt_image_format *fo
        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 );
 
index 89a2d84dbe5c65944c8180a6774c92c89ea775f8..1fb6704a3d3baba6493c87f6f95baeaa9ce95bc0 100644 (file)
@@ -21,8 +21,9 @@
 
 using namespace movit;
 
-MltInput::MltInput()
-       : input(0)
+MltInput::MltInput( mlt_image_format format )
+       : m_format(format)
+       , input(0)
        , isRGB(true)
 {
 }
index c200cc67f6c2e0536cb33ffb5979c93eee125307..109194f010ed468fbc65edfa34a99b2739f103b2 100644 (file)
@@ -20,6 +20,8 @@
 #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>
@@ -27,7 +29,7 @@
 class MltInput
 {
 public:
-       MltInput();
+       MltInput( mlt_image_format format );
        ~MltInput();
 
        void useFlatInput(movit::MovitPixelFormat pix_fmt, unsigned width, unsigned height);
@@ -36,7 +38,12 @@ public:
        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;