From d8eef875f19feb30549855d3695a91df72c5c60f Mon Sep 17 00:00:00 2001 From: ddennedy Date: Tue, 23 Dec 2003 02:41:15 +0000 Subject: [PATCH] add video_standard enum to mlt_frame, add mlt_consumer_properties, add properties to gtk2 producers and bluefish consumer git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@12 d19143bc-622f-0410-bfdd-b5b2a6649095 --- mlt/src/framework/mlt_consumer.c | 8 ++++++ mlt/src/framework/mlt_consumer.h | 1 + mlt/src/framework/mlt_frame.h | 7 +++++ mlt/src/modules/gtk2/producer_pango.c | 42 +++++++++++++++++++++++++------ mlt/src/modules/gtk2/producer_pango.h | 8 +++++- mlt/src/modules/gtk2/producer_pixbuf.c | 16 ++++++++++- mlt/src/modules/gtk2/producer_pixbuf.h | 1 - mlt/src/tests/dan.c | 18 +++++++++++++- src/framework/mlt_consumer.c | 8 ++++++ src/framework/mlt_consumer.h | 1 + src/framework/mlt_frame.h | 7 +++++ src/modules/gtk2/producer_pango.c | 42 +++++++++++++++++++++++++------ src/modules/gtk2/producer_pango.h | 8 +++++- src/modules/gtk2/producer_pixbuf.c | 16 ++++++++++- src/modules/gtk2/producer_pixbuf.h | 1 - src/tests/dan.c | 18 +++++++++++++- 16 files changed, 176 insertions(+), 26 deletions(-) diff --git a/mlt/src/framework/mlt_consumer.c b/mlt/src/framework/mlt_consumer.c index 635ad65..f263a20 100644 --- a/mlt/src/framework/mlt_consumer.c +++ b/mlt/src/framework/mlt_consumer.c @@ -42,6 +42,14 @@ mlt_service mlt_consumer_service( mlt_consumer this ) return &this->parent; } +/** Get the consumer properties. +*/ + +mlt_properties mlt_consumer_properties( mlt_consumer this ) +{ + return mlt_service_properties( &this->parent ); +} + /** Connect the consumer to the producer. */ diff --git a/mlt/src/framework/mlt_consumer.h b/mlt/src/framework/mlt_consumer.h index cbe9078..d6a9637 100644 --- a/mlt/src/framework/mlt_consumer.h +++ b/mlt/src/framework/mlt_consumer.h @@ -44,6 +44,7 @@ struct mlt_consumer_s extern int mlt_consumer_init( mlt_consumer this, void *child ); extern mlt_service mlt_consumer_service( mlt_consumer this ); +extern mlt_properties mlt_consumer_properties( mlt_consumer this ); extern int mlt_consumer_connect( mlt_consumer this, mlt_service producer ); extern void mlt_consumer_close( mlt_consumer ); diff --git a/mlt/src/framework/mlt_frame.h b/mlt/src/framework/mlt_frame.h index fd86f23..e9bd69a 100644 --- a/mlt/src/framework/mlt_frame.h +++ b/mlt/src/framework/mlt_frame.h @@ -35,6 +35,13 @@ mlt_image_format; typedef enum { + mlt_video_standard_pal = 0, + mlt_video_standard_ntsc +} +mlt_video_standard; + +typedef enum +{ mlt_audio_none = 0, mlt_audio_pcm } diff --git a/mlt/src/modules/gtk2/producer_pango.c b/mlt/src/modules/gtk2/producer_pango.c index 85b7b39..d113ce6 100644 --- a/mlt/src/modules/gtk2/producer_pango.c +++ b/mlt/src/modules/gtk2/producer_pango.c @@ -49,9 +49,18 @@ mlt_producer producer_pango_init( const char *markup ) producer->close = producer_close; this->markup = strdup( markup ); - this->is_pal = 1; g_type_init(); + // Get the properties interface + mlt_properties properties = mlt_producer_properties( &this->parent ); + + // Set the default properties + mlt_properties_set_int( properties, "video_standard", mlt_video_standard_pal ); + mlt_properties_set_int( properties, "fgcolor", 0xffffffff ); + mlt_properties_set_int( properties, "bgcolor", 0x00000000 ); + mlt_properties_set_int( properties, "align", pango_align_left ); + mlt_properties_set_int( properties, "pad", 0 ); + return producer; } free( this ); @@ -133,21 +142,38 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i } else { - // the following four will be replaced by properties - rgba_color fg = { 0xff, 0xff, 0xff, 0xff }; - rgba_color bg = { 0, 0, 0, 0x7f }; - int pad = 8; - int align = 0; /* left */ + // Obtain properties of producer + mlt_properties props = mlt_producer_properties( producer ); + + // Get properties + int fg = mlt_properties_get_int( props, "fgcolor" ); + int bg = mlt_properties_get_int( props, "bgcolor" ); + int align = mlt_properties_get_int( props, "align" ); + int pad = mlt_properties_get_int( props, "pad" ); + rgba_color fgcolor = + { + ( fg & 0xff000000 ) >> 24, + ( fg & 0x00ff0000 ) >> 16, + ( fg & 0x0000ff00 ) >> 8, + ( fg & 0x000000ff ) + }; + rgba_color bgcolor = + { + ( bg & 0xff000000 ) >> 24, + ( bg & 0x00ff0000 ) >> 16, + ( bg & 0x0000ff00 ) >> 8, + ( bg & 0x000000ff ) + }; // Render the title - pixbuf = pango_get_pixbuf( this->markup, fg, bg, pad, align ); + pixbuf = pango_get_pixbuf( this->markup, fgcolor, bgcolor, pad, align ); } // If we have a pixbuf if ( pixbuf ) { // Scale to adjust for sample aspect ratio - if ( this->is_pal ) + if ( mlt_properties_get_int( properties, "video_standard" ) == mlt_video_standard_pal ) { GdkPixbuf *temp = pixbuf; GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf, diff --git a/mlt/src/modules/gtk2/producer_pango.h b/mlt/src/modules/gtk2/producer_pango.h index f067e7c..1e2b1c8 100644 --- a/mlt/src/modules/gtk2/producer_pango.h +++ b/mlt/src/modules/gtk2/producer_pango.h @@ -33,9 +33,15 @@ struct producer_pango_s int height; uint8_t *image; uint8_t *alpha; - int is_pal; }; +typedef enum +{ + pango_align_left = 0, + pango_align_center, + pango_align_right +} pango_align; + extern mlt_producer producer_pango_init( const char *markup ); #endif diff --git a/mlt/src/modules/gtk2/producer_pixbuf.c b/mlt/src/modules/gtk2/producer_pixbuf.c index 1ba370f..97a6fc3 100644 --- a/mlt/src/modules/gtk2/producer_pixbuf.c +++ b/mlt/src/modules/gtk2/producer_pixbuf.c @@ -28,6 +28,12 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index ); static void producer_close( mlt_producer parent ); +typedef enum +{ + SIGNAL_FORMAT_PAL, + SIGNAL_FORMAT_NTSC +} mlt_signal_format; + mlt_producer producer_pixbuf_init( const char *filename ) { producer_pixbuf this = calloc( sizeof( struct producer_pixbuf_s ), 1 ); @@ -40,7 +46,13 @@ mlt_producer producer_pixbuf_init( const char *filename ) this->filename = strdup( filename ); this->counter = -1; - this->is_pal = 1; + + // Get the properties interface + mlt_properties properties = mlt_producer_properties( &this->parent ); + + // Set the default properties + mlt_properties_set_int( properties, "video_standard", mlt_video_standard_pal ); + g_type_init(); return producer; @@ -147,7 +159,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i if ( pixbuf ) { // Scale to adjust for sample aspect ratio - if ( this->is_pal ) + if ( mlt_properties_get_int( properties, "video_stadnard" ) == mlt_video_standard_pal ) { GdkPixbuf *temp = pixbuf; GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf, diff --git a/mlt/src/modules/gtk2/producer_pixbuf.h b/mlt/src/modules/gtk2/producer_pixbuf.h index 04fb2f4..c7f76ef 100644 --- a/mlt/src/modules/gtk2/producer_pixbuf.h +++ b/mlt/src/modules/gtk2/producer_pixbuf.h @@ -34,7 +34,6 @@ struct producer_pixbuf_s int height; uint8_t *image; uint8_t *alpha; - int is_pal; }; extern mlt_producer producer_pixbuf_init( const char *filename ); diff --git a/mlt/src/tests/dan.c b/mlt/src/tests/dan.c index 208ee49..d22f0a9 100644 --- a/mlt/src/tests/dan.c +++ b/mlt/src/tests/dan.c @@ -17,15 +17,31 @@ int main( int argc, char **argv ) file2 = argv[ 2 ]; // Start the consumer... - mlt_consumer consumer = mlt_factory_consumer( "bluefish", NULL ); + int vstd = mlt_video_standard_ntsc; + mlt_consumer consumer = mlt_factory_consumer( "bluefish", &vstd ); + mlt_properties_set_int( mlt_consumer_properties( consumer ), "video_standard", mlt_video_standard_ntsc ); // Create the producer(s) mlt_producer dv1 = mlt_factory_producer( "mcmpeg", file1 ); +#if 0 + // Connect the tractor to the consumer + mlt_consumer_connect( consumer, mlt_producer_service( dv1 ) ); + + // Do stuff until we're told otherwise... + fprintf( stderr, "Press return to continue\n" ); + fgets( temp, 132, stdin ); + mlt_consumer_close( consumer ); + return 0; +#endif + //mlt_producer dv1 = producer_pixbuf_init( file1 ); //mlt_producer dv2 = producer_libdv_init( file2 ); //mlt_producer dv2 = mlt_factory_producer( "pixbuf", file2 ); mlt_producer dv2 = mlt_factory_producer( "pango", "Mutton Lettuce Tomato" ); + mlt_properties_set_int( mlt_producer_properties( dv2 ), "video_standard", mlt_video_standard_ntsc ); + mlt_properties_set_int( mlt_producer_properties( dv2 ), "bgcolor", 0x0000007f ); + mlt_properties_set_int( mlt_producer_properties( dv2 ), "pad", 8 ); // Register producers(s) with a multitrack object mlt_multitrack multitrack = mlt_multitrack_init( ); diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index 635ad65..f263a20 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -42,6 +42,14 @@ mlt_service mlt_consumer_service( mlt_consumer this ) return &this->parent; } +/** Get the consumer properties. +*/ + +mlt_properties mlt_consumer_properties( mlt_consumer this ) +{ + return mlt_service_properties( &this->parent ); +} + /** Connect the consumer to the producer. */ diff --git a/src/framework/mlt_consumer.h b/src/framework/mlt_consumer.h index cbe9078..d6a9637 100644 --- a/src/framework/mlt_consumer.h +++ b/src/framework/mlt_consumer.h @@ -44,6 +44,7 @@ struct mlt_consumer_s extern int mlt_consumer_init( mlt_consumer this, void *child ); extern mlt_service mlt_consumer_service( mlt_consumer this ); +extern mlt_properties mlt_consumer_properties( mlt_consumer this ); extern int mlt_consumer_connect( mlt_consumer this, mlt_service producer ); extern void mlt_consumer_close( mlt_consumer ); diff --git a/src/framework/mlt_frame.h b/src/framework/mlt_frame.h index fd86f23..e9bd69a 100644 --- a/src/framework/mlt_frame.h +++ b/src/framework/mlt_frame.h @@ -35,6 +35,13 @@ mlt_image_format; typedef enum { + mlt_video_standard_pal = 0, + mlt_video_standard_ntsc +} +mlt_video_standard; + +typedef enum +{ mlt_audio_none = 0, mlt_audio_pcm } diff --git a/src/modules/gtk2/producer_pango.c b/src/modules/gtk2/producer_pango.c index 85b7b39..d113ce6 100644 --- a/src/modules/gtk2/producer_pango.c +++ b/src/modules/gtk2/producer_pango.c @@ -49,9 +49,18 @@ mlt_producer producer_pango_init( const char *markup ) producer->close = producer_close; this->markup = strdup( markup ); - this->is_pal = 1; g_type_init(); + // Get the properties interface + mlt_properties properties = mlt_producer_properties( &this->parent ); + + // Set the default properties + mlt_properties_set_int( properties, "video_standard", mlt_video_standard_pal ); + mlt_properties_set_int( properties, "fgcolor", 0xffffffff ); + mlt_properties_set_int( properties, "bgcolor", 0x00000000 ); + mlt_properties_set_int( properties, "align", pango_align_left ); + mlt_properties_set_int( properties, "pad", 0 ); + return producer; } free( this ); @@ -133,21 +142,38 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i } else { - // the following four will be replaced by properties - rgba_color fg = { 0xff, 0xff, 0xff, 0xff }; - rgba_color bg = { 0, 0, 0, 0x7f }; - int pad = 8; - int align = 0; /* left */ + // Obtain properties of producer + mlt_properties props = mlt_producer_properties( producer ); + + // Get properties + int fg = mlt_properties_get_int( props, "fgcolor" ); + int bg = mlt_properties_get_int( props, "bgcolor" ); + int align = mlt_properties_get_int( props, "align" ); + int pad = mlt_properties_get_int( props, "pad" ); + rgba_color fgcolor = + { + ( fg & 0xff000000 ) >> 24, + ( fg & 0x00ff0000 ) >> 16, + ( fg & 0x0000ff00 ) >> 8, + ( fg & 0x000000ff ) + }; + rgba_color bgcolor = + { + ( bg & 0xff000000 ) >> 24, + ( bg & 0x00ff0000 ) >> 16, + ( bg & 0x0000ff00 ) >> 8, + ( bg & 0x000000ff ) + }; // Render the title - pixbuf = pango_get_pixbuf( this->markup, fg, bg, pad, align ); + pixbuf = pango_get_pixbuf( this->markup, fgcolor, bgcolor, pad, align ); } // If we have a pixbuf if ( pixbuf ) { // Scale to adjust for sample aspect ratio - if ( this->is_pal ) + if ( mlt_properties_get_int( properties, "video_standard" ) == mlt_video_standard_pal ) { GdkPixbuf *temp = pixbuf; GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf, diff --git a/src/modules/gtk2/producer_pango.h b/src/modules/gtk2/producer_pango.h index f067e7c..1e2b1c8 100644 --- a/src/modules/gtk2/producer_pango.h +++ b/src/modules/gtk2/producer_pango.h @@ -33,9 +33,15 @@ struct producer_pango_s int height; uint8_t *image; uint8_t *alpha; - int is_pal; }; +typedef enum +{ + pango_align_left = 0, + pango_align_center, + pango_align_right +} pango_align; + extern mlt_producer producer_pango_init( const char *markup ); #endif diff --git a/src/modules/gtk2/producer_pixbuf.c b/src/modules/gtk2/producer_pixbuf.c index 1ba370f..97a6fc3 100644 --- a/src/modules/gtk2/producer_pixbuf.c +++ b/src/modules/gtk2/producer_pixbuf.c @@ -28,6 +28,12 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index ); static void producer_close( mlt_producer parent ); +typedef enum +{ + SIGNAL_FORMAT_PAL, + SIGNAL_FORMAT_NTSC +} mlt_signal_format; + mlt_producer producer_pixbuf_init( const char *filename ) { producer_pixbuf this = calloc( sizeof( struct producer_pixbuf_s ), 1 ); @@ -40,7 +46,13 @@ mlt_producer producer_pixbuf_init( const char *filename ) this->filename = strdup( filename ); this->counter = -1; - this->is_pal = 1; + + // Get the properties interface + mlt_properties properties = mlt_producer_properties( &this->parent ); + + // Set the default properties + mlt_properties_set_int( properties, "video_standard", mlt_video_standard_pal ); + g_type_init(); return producer; @@ -147,7 +159,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i if ( pixbuf ) { // Scale to adjust for sample aspect ratio - if ( this->is_pal ) + if ( mlt_properties_get_int( properties, "video_stadnard" ) == mlt_video_standard_pal ) { GdkPixbuf *temp = pixbuf; GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf, diff --git a/src/modules/gtk2/producer_pixbuf.h b/src/modules/gtk2/producer_pixbuf.h index 04fb2f4..c7f76ef 100644 --- a/src/modules/gtk2/producer_pixbuf.h +++ b/src/modules/gtk2/producer_pixbuf.h @@ -34,7 +34,6 @@ struct producer_pixbuf_s int height; uint8_t *image; uint8_t *alpha; - int is_pal; }; extern mlt_producer producer_pixbuf_init( const char *filename ); diff --git a/src/tests/dan.c b/src/tests/dan.c index 208ee49..d22f0a9 100644 --- a/src/tests/dan.c +++ b/src/tests/dan.c @@ -17,15 +17,31 @@ int main( int argc, char **argv ) file2 = argv[ 2 ]; // Start the consumer... - mlt_consumer consumer = mlt_factory_consumer( "bluefish", NULL ); + int vstd = mlt_video_standard_ntsc; + mlt_consumer consumer = mlt_factory_consumer( "bluefish", &vstd ); + mlt_properties_set_int( mlt_consumer_properties( consumer ), "video_standard", mlt_video_standard_ntsc ); // Create the producer(s) mlt_producer dv1 = mlt_factory_producer( "mcmpeg", file1 ); +#if 0 + // Connect the tractor to the consumer + mlt_consumer_connect( consumer, mlt_producer_service( dv1 ) ); + + // Do stuff until we're told otherwise... + fprintf( stderr, "Press return to continue\n" ); + fgets( temp, 132, stdin ); + mlt_consumer_close( consumer ); + return 0; +#endif + //mlt_producer dv1 = producer_pixbuf_init( file1 ); //mlt_producer dv2 = producer_libdv_init( file2 ); //mlt_producer dv2 = mlt_factory_producer( "pixbuf", file2 ); mlt_producer dv2 = mlt_factory_producer( "pango", "Mutton Lettuce Tomato" ); + mlt_properties_set_int( mlt_producer_properties( dv2 ), "video_standard", mlt_video_standard_ntsc ); + mlt_properties_set_int( mlt_producer_properties( dv2 ), "bgcolor", 0x0000007f ); + mlt_properties_set_int( mlt_producer_properties( dv2 ), "pad", 8 ); // Register producers(s) with a multitrack object mlt_multitrack multitrack = mlt_multitrack_init( ); -- 1.7.4.4