From c27fb53aea55a3ef8c52726e4f7f03b7ac768769 Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Wed, 20 Feb 2013 20:28:49 -0800 Subject: [PATCH] Let loader producer use new GLSL normalizing filters (opengl branch). --- src/framework/mlt_profile.c | 2 +- src/modules/avformat/filter_avcolour_space.c | 7 ++++--- src/modules/avformat/filter_swscale.c | 2 +- src/modules/avformat/producer_avformat.c | 4 ++++ src/modules/core/consumer_multi.c | 16 ++++++++++------ src/modules/core/filter_crop.c | 7 ------- src/modules/core/filter_fieldorder.c | 7 ++----- src/modules/core/filter_imageconvert.c | 3 ++- src/modules/core/loader.ini | 6 +++--- src/modules/core/producer_loader.c | 3 +++ 10 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/framework/mlt_profile.c b/src/framework/mlt_profile.c index a0ae6480..06fa2c32 100644 --- a/src/framework/mlt_profile.c +++ b/src/framework/mlt_profile.c @@ -403,7 +403,7 @@ void mlt_profile_from_producer( mlt_profile profile, mlt_producer producer ) { mlt_frame fr = NULL; uint8_t *buffer; - mlt_image_format fmt = mlt_image_yuv422; + mlt_image_format fmt = mlt_image_none; mlt_properties p; int w = profile->width; int h = profile->height; diff --git a/src/modules/avformat/filter_avcolour_space.c b/src/modules/avformat/filter_avcolour_space.c index 5bf53ea4..9b5cfbc8 100644 --- a/src/modules/avformat/filter_avcolour_space.c +++ b/src/modules/avformat/filter_avcolour_space.c @@ -65,7 +65,7 @@ static int convert_mlt_to_av_cs( mlt_image_format format ) case mlt_image_yuv420p: value = PIX_FMT_YUV420P; break; - case mlt_image_none: + default: mlt_log_error( NULL, "[filter avcolor_space] Invalid format\n" ); break; } @@ -303,8 +303,9 @@ static mlt_frame filter_process( mlt_filter filter, mlt_frame frame ) if ( mlt_properties_get_int( properties, "colorspace" ) <= 0 ) mlt_properties_set_int( properties, "colorspace", mlt_service_profile( MLT_FILTER_SERVICE(filter) )->colorspace ); - frame->convert_image = convert_image; - + if ( !frame->convert_image ) + frame->convert_image = convert_image; + // Not working yet - see comment for get_image() above. // mlt_frame_push_service( frame, mlt_service_profile( MLT_FILTER_SERVICE( filter ) ) ); // mlt_frame_push_get_image( frame, get_image ); diff --git a/src/modules/avformat/filter_swscale.c b/src/modules/avformat/filter_swscale.c index ac7840f4..8e88f7c6 100644 --- a/src/modules/avformat/filter_swscale.c +++ b/src/modules/avformat/filter_swscale.c @@ -55,7 +55,7 @@ static inline int convert_mlt_to_av_cs( mlt_image_format format ) case mlt_image_yuv420p: value = PIX_FMT_YUV420P; break; - case mlt_image_none: + default: fprintf( stderr, "Invalid format...\n" ); break; } diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c index 89643505..8f7094ab 100644 --- a/src/modules/avformat/producer_avformat.c +++ b/src/modules/avformat/producer_avformat.c @@ -1426,6 +1426,10 @@ static int allocate_buffer( mlt_frame frame, AVCodecContext *codec_context, uint if ( codec_context->width == 0 || codec_context->height == 0 ) return size; + + if ( *format == mlt_image_glsl ) + *format = pick_pix_format( codec_context->pix_fmt ); + *width = codec_context->width; *height = codec_context->height; size = mlt_image_format_size( *format, *width, *height, NULL ); diff --git a/src/modules/core/consumer_multi.c b/src/modules/core/consumer_multi.c index 653547e0..38ef9519 100644 --- a/src/modules/core/consumer_multi.c +++ b/src/modules/core/consumer_multi.c @@ -87,13 +87,17 @@ static void create_filter( mlt_profile profile, mlt_service service, char *effec if ( strncmp( effect, "swscale", 7 ) == 0 || strncmp( effect, "avcolo", 6 ) == 0 ) arg = (char*) mlt_properties_get_int( MLT_SERVICE_PROPERTIES( service ), "meta.media.width" ); - mlt_filter filter = mlt_factory_filter( profile, id, arg ); - if ( filter != NULL ) + // We cannot use GLSL-based filters here. + if ( strncmp( effect, "movit.", 6 ) && strncmp( effect, "glsl.", 5 ) ) { - mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "_loader", 1 ); - mlt_service_attach( service, filter ); - mlt_filter_close( filter ); - *created = 1; + mlt_filter filter = mlt_factory_filter( profile, id, arg ); + if ( filter != NULL ) + { + mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "_loader", 1 ); + mlt_service_attach( service, filter ); + mlt_filter_close( filter ); + *created = 1; + } } free( id ); } diff --git a/src/modules/core/filter_crop.c b/src/modules/core/filter_crop.c index 1969fdb1..8f3b7765 100644 --- a/src/modules/core/filter_crop.c +++ b/src/modules/core/filter_crop.c @@ -96,13 +96,6 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format mlt_log_debug( NULL, "[filter crop] %s %dx%d -> %dx%d\n", mlt_image_format_name(*format), *width, *height, owidth, oheight); - // Provides a manual override for misreported field order - if ( mlt_properties_get( properties, "meta.top_field_first" ) ) - { - mlt_properties_set_int( properties, "top_field_first", mlt_properties_get_int( properties, "meta.top_field_first" ) ); - mlt_properties_set_int( properties, "meta.top_field_first", 0 ); - } - if ( top % 2 ) mlt_properties_set_int( properties, "top_field_first", !mlt_properties_get_int( properties, "top_field_first" ) ); diff --git a/src/modules/core/filter_fieldorder.c b/src/modules/core/filter_fieldorder.c index 79223757..a0a571f0 100644 --- a/src/modules/core/filter_fieldorder.c +++ b/src/modules/core/filter_fieldorder.c @@ -47,11 +47,8 @@ static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format mlt_properties_get_int( properties, "progressive" ) == 0 ) { // We only work with non-planar formats - if ( *format == mlt_image_yuv420p ) - { - *format = mlt_image_yuv422; - mlt_frame_get_image( frame, image, format, width, height, writable ); - } + if ( *format == mlt_image_yuv420p && frame->convert_image ) + error = frame->convert_image( frame, image, format, mlt_image_yuv422 ); // Make a new image int bpp; diff --git a/src/modules/core/filter_imageconvert.c b/src/modules/core/filter_imageconvert.c index f651f172..33c93880 100644 --- a/src/modules/core/filter_imageconvert.c +++ b/src/modules/core/filter_imageconvert.c @@ -372,7 +372,8 @@ static int convert_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *f static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) { - frame->convert_image = convert_image; + if ( !frame->convert_image ) + frame->convert_image = convert_image; return frame; } diff --git a/src/modules/core/loader.ini b/src/modules/core/loader.ini index 168bbda6..c586a176 100644 --- a/src/modules/core/loader.ini +++ b/src/modules/core/loader.ini @@ -8,10 +8,10 @@ # image filters deinterlace=deinterlace,avdeinterlace -crop=crop:1 -rescaler=swscale,gtkrescale,rescale fieldorder=fieldorder -resizer=resize +crop=movit.crop,crop:1 +rescaler=movit.resample,swscale,gtkrescale,rescale +resizer=movit.resize,resize # audio filters channels=audiochannels diff --git a/src/modules/core/producer_loader.c b/src/modules/core/producer_loader.c index c74aebfa..52016a32 100644 --- a/src/modules/core/producer_loader.c +++ b/src/modules/core/producer_loader.c @@ -222,6 +222,9 @@ mlt_producer producer_loader_init( mlt_profile profile, mlt_service_type type, c { // Always let the image and audio be converted int created = 0; + create_filter( profile, producer, "movit.convert", &created ); + // glsl.csc skips setting the frame->convert_image pointer if GLSL cannot be used. + // avcolor_space and imageconvert only set frame->convert_image if it has not been set. create_filter( profile, producer, "avcolor_space", &created ); if ( !created ) create_filter( profile, producer, "imageconvert", &created ); -- 2.39.2