X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fgtk2%2Fproducer_pixbuf.c;h=f1f1f45fe10d38cfce0342d7fe6e6a249e535acf;hb=9390e8b584f3f717f0a326893c0e37cf187a0a51;hp=484f83a38a075301d483a85f3a18016a6aeb5c79;hpb=e4c9ccbcef39cadaccbad655bc6e36e825bf3dde;p=melted diff --git a/src/modules/gtk2/producer_pixbuf.c b/src/modules/gtk2/producer_pixbuf.c index 484f83a..f1f1f45 100644 --- a/src/modules/gtk2/producer_pixbuf.c +++ b/src/modules/gtk2/producer_pixbuf.c @@ -29,6 +29,7 @@ #include #include #include +#include static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index ); static void producer_close( mlt_producer parent ); @@ -39,10 +40,19 @@ typedef enum SIGNAL_FORMAT_NTSC } mlt_signal_format; -mlt_producer producer_pixbuf_init( const char *filename ) +static int filter_files( const struct dirent *de ) +{ + if ( de->d_name[ 0 ] != '.' ) + return 1; + else + return 0; +} + + +mlt_producer producer_pixbuf_init( char *filename ) { producer_pixbuf this = calloc( sizeof( struct producer_pixbuf_s ), 1 ); - if ( this != NULL && mlt_producer_init( &this->parent, this ) == 0 ) + if ( filename != NULL && this != NULL && mlt_producer_init( &this->parent, this ) == 0 ) { mlt_producer producer = &this->parent; @@ -53,6 +63,7 @@ mlt_producer producer_pixbuf_init( const char *filename ) mlt_properties properties = mlt_producer_properties( &this->parent ); // Set the default properties + mlt_properties_set( properties, "resource", filename ); mlt_properties_set_int( properties, "video_standard", mlt_video_standard_pal ); mlt_properties_set_double( properties, "ttl", 5 ); @@ -79,11 +90,42 @@ mlt_producer producer_pixbuf_init( const char *filename ) gap ++; } } + mlt_properties_set_timecode( properties, "out", this->count ); + } + else if ( strstr( filename, "/.all." ) != NULL ) + { + char *dir_name = strdup( filename ); + char *extension = strrchr( filename, '.' ); + *( strstr( dir_name, "/.all." ) + 1 ) = '\0'; + char fullname[ 1024 ]; + strcpy( fullname, dir_name ); + struct dirent **de = NULL; + int n = scandir( fullname, &de, filter_files, alphasort ); + int i; + struct stat info; + + for (i = 0; i < n; i++ ) + { + snprintf( fullname, 1023, "%s%s", dir_name, de[i]->d_name ); + + if ( lstat( fullname, &info ) == 0 && + ( S_ISREG( info.st_mode ) || ( strstr( fullname, extension ) && info.st_mode | S_IXUSR ) ) ) + { + this->filenames = realloc( this->filenames, sizeof( char * ) * ( this->count + 1 ) ); + this->filenames[ this->count ++ ] = strdup( fullname ); + } + free( de[ i ] ); + } + + mlt_properties_set_timecode( properties, "out", this->count ); + free( de ); + free( dir_name ); } else { this->filenames = realloc( this->filenames, sizeof( char * ) * ( this->count + 1 ) ); this->filenames[ this->count ++ ] = strdup( filename ); + mlt_properties_set_timecode( properties, "out", 1 ); } // Initialise gobject types @@ -111,8 +153,12 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma *height = mlt_properties_get_int( properties, "height" ); // Clone if necessary - if ( writable ) + // NB: Cloning is necessary with this producer (due to processing of images ahead of use) + // The fault is not in the design of mlt, but in the implementation of pixbuf... + //if ( writable ) { + size = *width * *height * 2; + // Clone our image uint8_t *copy = malloc( size ); memcpy( copy, image, size ); @@ -176,7 +222,6 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Stack the get image callback mlt_frame_push_get_image( *frame, producer_get_image ); - } else { @@ -212,6 +257,8 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Store width and height this->width = gdk_pixbuf_get_width( pixbuf ); this->height = gdk_pixbuf_get_height( pixbuf ); + this->width -= this->width % 4; + this->height -= this->height % 2; // Allocate/define image and alpha uint8_t *image = malloc( this->width * this->height * 2 );