From bc867545373cd429653dfa6d44ada29b9039c158 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 8 Apr 2014 00:07:40 +0200 Subject: [PATCH] Convert on CPU if we are asked to finalize an empty Movit chain. This fixes an issue with interlaced content and no resize or other normalizers in actual use. --- src/modules/opengl/filter_movit_convert.cpp | 15 ++++++++++++++- src/modules/opengl/mlt_movit_input.cpp | 5 +++-- src/modules/opengl/mlt_movit_input.h | 9 ++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/modules/opengl/filter_movit_convert.cpp b/src/modules/opengl/filter_movit_convert.cpp index 46d640c7..f9954eba 100644 --- a/src/modules/opengl/filter_movit_convert.cpp +++ b/src/modules/opengl/filter_movit_convert.cpp @@ -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 ); diff --git a/src/modules/opengl/mlt_movit_input.cpp b/src/modules/opengl/mlt_movit_input.cpp index 89a2d84d..1fb6704a 100644 --- a/src/modules/opengl/mlt_movit_input.cpp +++ b/src/modules/opengl/mlt_movit_input.cpp @@ -21,8 +21,9 @@ using namespace movit; -MltInput::MltInput() - : input(0) +MltInput::MltInput( mlt_image_format format ) + : m_format(format) + , input(0) , isRGB(true) { } diff --git a/src/modules/opengl/mlt_movit_input.h b/src/modules/opengl/mlt_movit_input.h index c200cc67..109194f0 100644 --- a/src/modules/opengl/mlt_movit_input.h +++ b/src/modules/opengl/mlt_movit_input.h @@ -20,6 +20,8 @@ #ifndef MLT_MOVIT_INPUT_H #define MLT_MOVIT_INPUT_H +#include + #include #include #include @@ -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; -- 2.39.2