]> git.sesse.net Git - mlt/commitdiff
pango colour handling
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 9 Feb 2004 08:33:59 +0000 (08:33 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 9 Feb 2004 08:33:59 +0000 (08:33 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@126 d19143bc-622f-0410-bfdd-b5b2a6649095

docs/services.txt
src/modules/gtk2/producer_pango.c

index 37b3b9efc34245f591f135c09ad6b65311e11d9a..87bb1d4269e8b8243dd07c04e90e141266edb089 100644 (file)
@@ -46,78 +46,90 @@ Producers
                        mpeg seeking is inaccurate - doesn't seek to i-frames so you may
                        get junk for a few frames.
 
-       ffmpeg
+       fezzik
 
                Description
 
-                       Test case pipe based producer for video and audio.
+                       A friendly giant that likes to rhyme and throw rocks
 
                Constructor Argument
 
                        'file'  - produce a/v from file
-                       v4l             - produce a/v from video4linux and dsp device
 
                Initialisation Properties
 
-                       string video_type - "file" or "v4l"
-                       string video_file - file or v4l device
-                       string video_size - WxH of video to produce (default: "")
-                       int video_loop - loop video until audio exhausted (default: 0)
-                       string audio_type - "file" or "dsp"
-                       string audio_file - file or dsp device
-                       int audio_rate - audio frequency (default: 48000)
-                       int audio_channels - audio channels (default: 2)
-                       int audio_track - audio track to use (default: 0)
-                       int audio_loop - loop audio until video exhausted (default: 0)
                        int in - in point
                        int out - out point
-                       double fps - output frames per second (default: 25)
-                       double aspect_ratio - aspect ratio of video
+                       + all producer initialising properties
 
                Read Only Properties
 
-                       string resource - file or "v4l"
-                       int end_of_clip - holds 1 when input is exhausted
+                       string resource - file location
+                       + all producer read only properties
+
+               Details
+
+                       This producer is has two roles:
+
+                       1. it handles the mappings of all file names to the other
+                       producers;
+                       2. it attaches normalising filters (rescale, resize and resample)
+                       to the producers (when necessary).
+
+                       This producer simplifies many aspects of use. Essentially, it
+                       ensures that a consumer will receive images and audio precisely as
+                       they request them. 
 
                Dependencies
 
-                       ffmpeg executable.
+                       all.
 
                Known Bugs
 
-                       in point setting is broken.
-
-                       Implementation does not allow fast random access.
+                       None.
 
-       fezzik
+       ffmpeg
 
                Description
 
-                       A freindly giant that likes to throw rocks
+                       Test case pipe based producer for video and audio.
 
                Constructor Argument
 
                        'file'  - produce a/v from file
+                       v4l             - produce a/v from video4linux and dsp device
 
                Initialisation Properties
 
+                       string video_type - "file" or "v4l"
+                       string video_file - file or v4l device
+                       string video_size - WxH of video to produce (default: "")
+                       int video_loop - loop video until audio exhausted (default: 0)
+                       string audio_type - "file" or "dsp"
+                       string audio_file - file or dsp device
+                       int audio_rate - audio frequency (default: 48000)
+                       int audio_channels - audio channels (default: 2)
+                       int audio_track - audio track to use (default: 0)
+                       int audio_loop - loop audio until video exhausted (default: 0)
                        int in - in point
                        int out - out point
+                       double fps - output frames per second (default: 25)
+                       double aspect_ratio - aspect ratio of video
 
                Read Only Properties
 
-                       string resource - file location
-                       double fps - output frames per second
-                       double aspect_ratio - aspect ratio of video]
-                       int length - duration of resource (in frames)
+                       string resource - file or "v4l"
+                       int end_of_clip - holds 1 when input is exhausted
 
                Dependencies
 
-                       all.
+                       ffmpeg executable.
 
                Known Bugs
 
-                       None.
+                       in point setting is broken.
+
+                       Implementation does not allow fast random access.
 
        libdv
 
@@ -178,8 +190,7 @@ Producers
 
                Known Bugs
 
-                       Can be problematic with source NTSC DV files? really? yes - try
-                       playing pond.dv...
+                       Can be problematic with some NTSC DV files?
 
        mcmpeg
 
@@ -239,8 +250,8 @@ Producers
                                        http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupFormat.html
                                      - requires xml-like encoding special chars: <, >, & to &lt;, &gt;, &amp;
 
-                       int fgcolor - an rgba color specification of the text (i.e. 0xrrggbbaa)
-                       int bgcolor - an rgba color of the background rectangle
+                       string fgcolour - an rgba colour specification of the text (i.e. 0xrrggbbaa)
+                       string bgcolour - an rgba colour of the background rectangle
                        int align - paragraph alignment: 0 = left, 1 = center, 2 = right
                        int pad - the number of pixels to pad the background rectangle beyond edges of text
                                  default 0
@@ -248,12 +259,6 @@ Producers
                        string text - non-markup text (can contain markup chars un-encoded)
                        string font - the default typeface to use when not using markup
                                      default "Sans 48"
-                       int x - the horizontal position of the title on the frame
-                               default 0
-                       int y - the vertical position of the title on the frame
-                               default 0
-                       double mix - the overall opacity control of the generated title
-                                    default 1.0
 
                Read Only Properties
 
@@ -296,11 +301,6 @@ Producers
                                             PAL = 0, NTSC = 1
                                             this determines proper pixel aspect ratio
                        double ttl - how long (seconds) to repeat each picture in file sequences
-                       int x - the horizontal offset from the left edge of the frame
-                       int y - the vertical offset from the top edge of the frame
-                       double mix - the opacity factor to apply to the second frame
-                                    (used in addition to alpha channel).
-
 
                Read Only Properties
 
@@ -427,7 +427,7 @@ Filters
        
                Description
 
-                       Use ffmpeg executable to substitute audio stream.
+                   Use ffmpeg executable to substitute audio stream.
                
                Constructor Argument
 
@@ -483,7 +483,7 @@ Filters
        
                Description
 
-                       Convert color image to greyscale
+                       Convert colour image to greyscale
                        
                Constructor Argument
 
index 523238982053e7787d68871ac3df11db80c8efd1..90d68183dd7407a91b005e1a4ffe7f03202a7a31 100644 (file)
@@ -33,8 +33,8 @@ struct producer_pango_s
        int height;
        uint8_t *image;
        uint8_t *alpha;
-       int   fgcolor;
-       int   bgcolor;
+       char *fgcolor;
+       char *bgcolor;
        int   align;
        int   pad;
        char *markup;
@@ -73,15 +73,12 @@ mlt_producer producer_pango_init( const char *filename )
 
                // 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( properties, "fgcolour", "0xffffffff" );
+               mlt_properties_set( properties, "bgcolour", "0x00000000" );
                mlt_properties_set_int( properties, "align", pango_align_left );
                mlt_properties_set_int( properties, "pad", 0 );
                mlt_properties_set( properties, "text", "" );
                mlt_properties_set( properties, "font", "Sans 48" );
-               mlt_properties_set_int( properties, "x", 0 );
-               mlt_properties_set_int( properties, "y", 0 );
-               mlt_properties_set_double( properties, "mix", 1.0 );
 
                if ( filename == NULL )
                {
@@ -143,6 +140,68 @@ mlt_producer producer_pango_init( const char *filename )
        return NULL;
 }
 
+static void set_string( char **string, char *value, char *fallback )
+{
+       if ( value != NULL )
+       {
+               free( *string );
+               *string = strdup( value );
+       }
+       else if ( *string == NULL && fallback != NULL )
+       {
+               *string = strdup( fallback );
+       }
+       else if ( *string != NULL && fallback == NULL )
+       {
+               free( *string );
+               *string = NULL;
+       }
+}
+
+rgba_color parse_color( char *color )
+{
+       rgba_color result = { 0xff, 0xff, 0xff, 0xff };
+
+       if ( !strncmp( color, "0x", 2 ) )
+       {
+               unsigned int temp = 0;
+               sscanf( color + 2, "%x", &temp );
+               result.r = ( temp >> 24 ) & 0xff;
+               result.g = ( temp >> 16 ) & 0xff;
+               result.b = ( temp >> 8 ) & 0xff;
+               result.a = ( temp ) & 0xff;
+       }
+       else if ( !strcmp( color, "red" ) )
+       {
+               result.r = 0xff;
+               result.g = 0x00;
+               result.b = 0x00;
+       }
+       else if ( !strcmp( color, "green" ) )
+       {
+               result.r = 0x00;
+               result.g = 0xff;
+               result.b = 0x00;
+       }
+       else if ( !strcmp( color, "blue" ) )
+       {
+               result.r = 0x00;
+               result.g = 0x00;
+               result.b = 0xff;
+       }
+       else
+       {
+               unsigned int temp = 0;
+               sscanf( color, "%d", &temp );
+               result.r = ( temp >> 24 ) & 0xff;
+               result.g = ( temp >> 16 ) & 0xff;
+               result.b = ( temp >> 8 ) & 0xff;
+               result.a = ( temp ) & 0xff;
+       }
+
+       return result;
+}
+
 static void refresh_image( mlt_frame frame, int width, int height )
 {
        // Pixbuf 
@@ -161,8 +220,8 @@ static void refresh_image( mlt_frame frame, int width, int height )
        mlt_properties producer_props = mlt_producer_properties( producer );
 
        // Get producer properties
-       int fg = mlt_properties_get_int( producer_props, "fgcolor" );
-       int bg = mlt_properties_get_int( producer_props, "bgcolor" );
+       char *fg = mlt_properties_get( producer_props, "fgcolour" );
+       char *bg = mlt_properties_get( producer_props, "bgcolour" );
        int align = mlt_properties_get_int( producer_props, "align" );
        int pad = mlt_properties_get_int( producer_props, "pad" );
        char *markup = mlt_properties_get( producer_props, "markup" );
@@ -170,8 +229,8 @@ static void refresh_image( mlt_frame frame, int width, int height )
        char *font = mlt_properties_get( producer_props, "font" );
 
        // See if any properties changed
-       int property_changed = ( fg != this->fgcolor );
-       property_changed = property_changed || ( bg != this->bgcolor );
+       int property_changed = ( this->fgcolor == NULL || strcmp( fg, this->fgcolor ) );
+       property_changed = property_changed || ( this->bgcolor == NULL || strcmp( bg, this->bgcolor ) );
        property_changed = property_changed || ( align != this->align );
        property_changed = property_changed || ( pad != this->pad );
        property_changed = property_changed || ( markup && this->markup && strcmp( markup, this->markup ) );
@@ -179,42 +238,18 @@ static void refresh_image( mlt_frame frame, int width, int height )
        property_changed = property_changed || ( font && this->font && strcmp( font, this->font ) );
 
        // Save the properties for next comparison
-       this->fgcolor = fg;
-       this->bgcolor = bg;
        this->align = align;
        this->pad = pad;
-       if ( markup != NULL )
-       {
-               free( this->markup );
-               this->markup = strdup( markup );
-       }
-       if ( text != NULL )
-       {
-               free( this->text );
-               this->text = strdup( text );
-       }
-       if ( font != NULL )
-       {
-               free( this->font );
-               this->font = strdup( font );
-       }
+       set_string( &this->fgcolor, fg, "0xffffffff" );
+       set_string( &this->bgcolor, bg, "0x00000000" );
+       set_string( &this->markup, markup, NULL );
+       set_string( &this->text, text, NULL );
+       set_string( &this->font, font, "Sans 48" );
 
        if ( property_changed )
        {
-               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 )
-               };
+               rgba_color fgcolor = parse_color( this->fgcolor );
+               rgba_color bgcolor = parse_color( this->bgcolor );
 
                // Render the title
                pixbuf = pango_get_pixbuf( markup, text, font, fgcolor, bgcolor, pad, align );
@@ -376,6 +411,8 @@ static void producer_close( mlt_producer parent )
        producer_pango this = parent->child;
        free( this->image );
        free( this->alpha );
+       free( this->fgcolor );
+       free( this->bgcolor );
        free( this->markup );
        free( this->text );
        free( this->font );