]> git.sesse.net Git - mlt/commitdiff
Make the arg to avcolor_space filter a pointer.
authorDan Dennedy <dan@dennedy.org>
Sat, 23 Mar 2013 19:53:26 +0000 (12:53 -0700)
committerDan Dennedy <dan@dennedy.org>
Sat, 23 Mar 2013 19:53:26 +0000 (12:53 -0700)
Instead of passing an int cast as pointer.

src/modules/avformat/filter_avcolour_space.c
src/modules/core/consumer_multi.c
src/modules/core/producer_loader.c
src/modules/opengl/filter_movit_convert.cpp

index 44f47858674d2404c170aab663cd8a7337047dbf..3733733ec5aa748a8673e417e275e210cb254bbb 100644 (file)
@@ -324,13 +324,16 @@ mlt_filter filter_avcolour_space_init( void *arg )
        // Test to see if swscale accepts the arg as resolution
        if ( arg )
        {
-               int width = (int) arg;
-               struct SwsContext *context = sws_getContext( width, width, PIX_FMT_RGB32, 64, 64, PIX_FMT_RGB32, SWS_BILINEAR, NULL, NULL, NULL);
-               if ( context )
-                       sws_freeContext( context );
-               else
-                       return NULL;
-       }               
+               int *width = (int*) arg;
+               if ( *width > 0 )
+               {
+                       struct SwsContext *context = sws_getContext( *width, *width, PIX_FMT_RGB32, 64, 64, PIX_FMT_RGB32, SWS_BILINEAR, NULL, NULL, NULL);
+                       if ( context )
+                               sws_freeContext( context );
+                       else
+                               return NULL;
+               }
+       }
 #else
        return NULL;
 #endif
index 1781746a419fec89f9c0b2d5f6b13eebbbb00576..1cf6593a17ec45754ca5a60991d52d8f139f2fe2 100644 (file)
@@ -83,15 +83,21 @@ static void create_filter( mlt_profile profile, mlt_service service, char *effec
        if ( arg != NULL )
                *arg ++ = '\0';
 
-       // The swscale and avcolor_space filters require resolution as arg to test compatibility
-       if ( strncmp( effect, "swscale", 7 ) == 0 || strncmp( effect, "avcolo", 6 ) == 0 )
-               arg = (char*) mlt_properties_get_int( MLT_SERVICE_PROPERTIES( service ), "meta.media.width" );
-
        // We cannot use GLSL-based filters here.
        if ( strncmp( effect, "movit.", 6 ) && strncmp( effect, "glsl.", 5 ) )
        {
-               mlt_filter filter = mlt_factory_filter( profile, id, arg );
-               if ( filter != NULL )
+               mlt_filter filter;
+               // The swscale and avcolor_space filters require resolution as arg to test compatibility
+               if ( strncmp( effect, "swscale", 7 ) == 0 || strncmp( effect, "avcolo", 6 ) == 0 )
+               {
+                       int width = mlt_properties_get_int( MLT_SERVICE_PROPERTIES( service ), "meta.media.width" );
+                       filter = mlt_factory_filter( profile, id, &width );
+               }
+               else
+               {
+                       filter = mlt_factory_filter( profile, id, arg );
+               }
+               if ( filter )
                {
                        mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "_loader", 1 );
                        mlt_service_attach( service, filter );
index ccf2e4469fb337fd870ba1b4b1dd09eafc6d5511..017197ca3327f69ac505adaa227e19390bc19072 100644 (file)
@@ -162,6 +162,7 @@ static mlt_producer create_producer( mlt_profile profile, char *file )
 
 static void create_filter( mlt_profile profile, mlt_producer producer, char *effect, int *created )
 {
+       mlt_filter filter;
        char *id = strdup( effect );
        char *arg = strchr( id, ':' );
        if ( arg != NULL )
@@ -169,10 +170,15 @@ static void create_filter( mlt_profile profile, mlt_producer producer, char *eff
 
        // The swscale and avcolor_space filters require resolution as arg to test compatibility
        if ( strncmp( effect, "swscale", 7 ) == 0 || strncmp( effect, "avcolo", 6 ) == 0 )
-               arg = (char*) mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( producer ), "meta.media.width" );
-
-       mlt_filter filter = mlt_factory_filter( profile, id, arg );
-       if ( filter != NULL )
+       {
+               int width = mlt_properties_get_int( MLT_PRODUCER_PROPERTIES( producer ), "meta.media.width" );
+               filter = mlt_factory_filter( profile, id, &width );
+       }
+       else
+       {
+               filter = mlt_factory_filter( profile, id, arg );
+       }
+       if ( filter )
        {
                mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "_loader", 1 );
                mlt_producer_attach( producer, filter );
index e1d52e45800e7ab71bca8560af10cb81ee05a904..847d430cfec781aaf25196f077c2771b54bd02e9 100644 (file)
@@ -322,7 +322,7 @@ static mlt_frame process( mlt_filter filter, mlt_frame frame )
 
 static mlt_filter create_filter( mlt_profile profile, char *effect )
 {
-       mlt_filter filter = NULL;
+       mlt_filter filter;
        char *id = strdup( effect );
        char *arg = strchr( id, ':' );
        if ( arg != NULL )
@@ -330,9 +330,9 @@ static mlt_filter create_filter( mlt_profile profile, char *effect )
 
        // The swscale and avcolor_space filters require resolution as arg to test compatibility
        if ( !strcmp( effect, "avcolor_space" ) )
-               arg = (char*) profile->width;
-
-       filter = mlt_factory_filter( profile, id, arg );
+               filter = mlt_factory_filter( profile, id, &profile->width );
+       else
+               filter = mlt_factory_filter( profile, id, arg );
        if ( filter )
                mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "_loader", 1 );
        free( id );