From ebbb877b4a3bb9040736ab4c11723da8f783f798 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 21 Jan 2014 23:46:04 +0100 Subject: [PATCH] Call invalidate_pixel_data() after frame rendering. This helps the input return its values back to the ResourcePool, which means we won't be allocating ever more textures as we get more clips on the timeline. --- src/modules/opengl/filter_movit_convert.cpp | 10 ++++++---- src/modules/opengl/mlt_movit_input.cpp | 12 ++++++++++++ src/modules/opengl/mlt_movit_input.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/modules/opengl/filter_movit_convert.cpp b/src/modules/opengl/filter_movit_convert.cpp index 8595173e..3f7b5879 100644 --- a/src/modules/opengl/filter_movit_convert.cpp +++ b/src/modules/opengl/filter_movit_convert.cpp @@ -307,22 +307,24 @@ static void set_movit_parameters( GlslChain *chain, mlt_service service, mlt_fra } } -static void dispose_pixel_pointers( mlt_service service, mlt_frame frame ) +static void dispose_pixel_pointers( GlslChain *chain, mlt_service service, mlt_frame frame ) { if ( service == (mlt_service) -1 ) { mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) ); + MltInput* input = (MltInput *) chain->effects[ MLT_PRODUCER_SERVICE( producer ) ]; + input->invalidate_pixel_data(); mlt_pool_release( GlslManager::get_input_pixel_pointer( producer, frame ) ); return; } mlt_service input_a = GlslManager::get_effect_input( service, frame ); - dispose_pixel_pointers( input_a, frame ); + dispose_pixel_pointers( chain, input_a, frame ); mlt_service input_b; mlt_frame frame_b; GlslManager::get_effect_secondary_input( service, frame, &input_b, &frame_b ); if ( input_b ) { - dispose_pixel_pointers( input_b, frame_b ); + dispose_pixel_pointers( chain, input_b, frame_b ); } } @@ -442,7 +444,7 @@ static int convert_image( mlt_frame frame, uint8_t **image, mlt_image_format *fo error = movit_render( chain->effect_chain, frame, format, output_format, width, height, image ); - dispose_pixel_pointers( leaf_service, frame ); + dispose_pixel_pointers( chain, leaf_service, frame ); } // If we've been asked to render some frame directly to a texture (without any diff --git a/src/modules/opengl/mlt_movit_input.cpp b/src/modules/opengl/mlt_movit_input.cpp index a75fe1ff..59306be4 100644 --- a/src/modules/opengl/mlt_movit_input.cpp +++ b/src/modules/opengl/mlt_movit_input.cpp @@ -120,3 +120,15 @@ void MltInput::set_pixel_data(const unsigned char* data) ycbcr->set_pixel_data(2, &data[m_width * m_height + (m_width / m_ycbcr_format.chroma_subsampling_x * m_height / m_ycbcr_format.chroma_subsampling_y)]); } } + +void MltInput::invalidate_pixel_data() +{ + assert(input); + if (isRGB) { + FlatInput* flat = (FlatInput*) input; + flat->invalidate_pixel_data(); + } else { + YCbCrInput* ycbcr = (YCbCrInput*) input; + ycbcr->invalidate_pixel_data(); + } +} diff --git a/src/modules/opengl/mlt_movit_input.h b/src/modules/opengl/mlt_movit_input.h index d7f64c55..16bed620 100644 --- a/src/modules/opengl/mlt_movit_input.h +++ b/src/modules/opengl/mlt_movit_input.h @@ -49,6 +49,7 @@ public: void useFlatInput(MovitPixelFormat pix_fmt, unsigned width, unsigned height); void useYCbCrInput(const ImageFormat& image_format, const YCbCrFormat& ycbcr_format, unsigned width, unsigned height); void set_pixel_data(const unsigned char* data); + void invalidate_pixel_data(); private: unsigned m_width, m_height; -- 2.39.2