X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fcore%2Ftransition_luma.c;h=9a180d1bfeaa89b952c6968c825f6b60183d2851;hb=6ff5549dc913d3976ef611d4c056b0fcb5d520e5;hp=e77999c41e9cbe46fab1c5d6d18ec2c5de46aab0;hpb=9671ab81bdb3a86155fbf8627e06f6de18e93fff;p=melted diff --git a/src/modules/core/transition_luma.c b/src/modules/core/transition_luma.c index e77999c..9a180d1 100644 --- a/src/modules/core/transition_luma.c +++ b/src/modules/core/transition_luma.c @@ -95,48 +95,24 @@ static float delta_calculate( mlt_transition this, mlt_frame frame ) return ( y - x ) / 2.0; } -static inline int dissolve_yuv( mlt_frame this, mlt_frame that, float weight, int *width, int *height ) +static inline int dissolve_yuv( mlt_frame this, mlt_frame that, float weight, int width, int height ) { int ret = 0; - int width_src = *width, height_src = *height; - int width_dest = *width, height_dest = *height; - mlt_image_format format_src = mlt_image_yuv422, format_dest = mlt_image_yuv422; + int width_src = width, height_src = height; + mlt_image_format format = mlt_image_yuv422; uint8_t *p_src, *p_dest; - int i, j; - int stride_src; - int stride_dest; - - format_src = mlt_image_yuv422; - format_dest = mlt_image_yuv422; - - mlt_frame_get_image( this, &p_dest, &format_dest, &width_dest, &height_dest, 1 /* writable */ ); - mlt_frame_get_image( that, &p_src, &format_src, &width_src, &height_src, 0 /* writable */ ); - - stride_src = width_src << 1; - stride_dest = width_dest << 1; - - uint8_t *p = p_src; - uint8_t *q = p_dest; - uint8_t *o = p_dest; - - uint8_t Y; - uint8_t UV; float weight_complement = 1 - weight; + uint8_t *p; + uint8_t *limit; - // now do the compositing only to cropped extents - for ( i = 0; i < height_src; i++ ) - { - p = &p_src[ i * stride_src ]; - o = q = &p_dest[ i * stride_dest ]; + mlt_frame_get_image( this, &p_dest, &format, &width, &height, 1 /* writable */ ); + mlt_frame_get_image( that, &p_src, &format, &width_src, &height_src, 0 /* writable */ ); + + p = p_dest; + limit = p_dest + height_src * width_src * 2; - for ( j = 0; j < width_src; j ++ ) - { - Y = *p ++; - UV = *p ++; - *o ++ = (uint8_t)( Y * weight + *q++ * weight_complement ); - *o ++ = (uint8_t)( UV * weight + *q++ * weight_complement ); - } - } + while ( p < limit ) + *p_dest++ = ( uint8_t )( *p_src++ * weight + *p++ * weight_complement ); return ret; } @@ -184,7 +160,7 @@ static void luma_composite( mlt_frame a_frame, mlt_frame b_frame, int luma_width uint8_t y; uint8_t uv; - float value; + float value; float x_diff = ( float )luma_width / ( float )*width; float y_diff = ( float )luma_height / ( float )*height; @@ -259,7 +235,7 @@ static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_form luma_softness, progressive ? -1 : top_field_first, width, height ); else // Dissolve the frames using the time offset for mix value - dissolve_yuv( this, b_frame, mix, width, height ); + dissolve_yuv( this, b_frame, mix, *width, *height ); // Extract the a_frame image info *width = mlt_properties_get_int( a_props, "width" ); @@ -274,7 +250,6 @@ static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_form static void luma_read_pgm( FILE *f, float **map, int *width, int *height ) { - void *release = NULL; uint8_t *data = NULL; while (1) { @@ -329,7 +304,7 @@ static void luma_read_pgm( FILE *f, float **map, int *width, int *height ) bpp = maxval > 255 ? 2 : 1; // allocate temporary storage for the raw data - data = mlt_pool_allocate( *width * *height * bpp, &release ); + data = mlt_pool_alloc( *width * *height * bpp ); if ( data == NULL ) break; @@ -338,9 +313,7 @@ static void luma_read_pgm( FILE *f, float **map, int *width, int *height ) break; // allocate the luma bitmap - // IRRIGATE ME - // Difficult here - need to change the function prototype.... - *map = p = (float*) malloc( *width * *height * sizeof( float ) ); + *map = p = (float*)mlt_pool_alloc( *width * *height * sizeof( float ) ); if ( *map == NULL ) break; @@ -356,8 +329,8 @@ static void luma_read_pgm( FILE *f, float **map, int *width, int *height ) break; } - if ( release != NULL ) - mlt_pool_release( release ); + if ( data != NULL ) + mlt_pool_release( data ); } @@ -385,7 +358,7 @@ static mlt_frame transition_process( mlt_transition transition, mlt_frame a_fram pipe = fopen( luma_file, "r" ); if ( pipe != NULL ) { - free( this->bitmap ); + mlt_pool_release( this->bitmap ); luma_read_pgm( pipe, &this->bitmap, &this->width, &this->height ); fclose( pipe ); } @@ -430,7 +403,7 @@ mlt_transition transition_luma_init( char *lumafile ) static void transition_close( mlt_transition parent ) { transition_luma *this = (transition_luma*) parent->child; - free( this->bitmap ); + mlt_pool_release( this->bitmap ); free( this->filename ); free( this ); }