Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #45 from jliljebl/anim-props-fix-batch-3

Anim props fix batch 3
  • Loading branch information...
commit a8d1086a6eeb2c5b540303d76f2bf4a19182e00c 2 parents 9b7b5df + 0f06314
@ddennedy ddennedy authored
View
14 src/modules/core/filter_greyscale.c
@@ -27,10 +27,10 @@
/** Do it :-).
*/
-static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
*format = mlt_image_yuv422;
- int error = mlt_frame_get_image( this, image, format, width, height, 1 );
+ int error = mlt_frame_get_image( frame, image, format, width, height, 1 );
if ( error == 0 )
{
uint8_t *p = *image;
@@ -44,7 +44,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
/** Filter processing.
*/
-static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
{
mlt_frame_push_get_image( frame, filter_get_image );
return frame;
@@ -55,9 +55,9 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
mlt_filter filter_greyscale_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = mlt_filter_new( );
- if ( this != NULL )
- this->process = filter_process;
- return this;
+ mlt_filter filter = mlt_filter_new( );
+ if ( filter != NULL )
+ filter->process = filter_process;
+ return filter;
}
View
11 src/modules/core/filter_imageconvert.c
@@ -361,7 +361,7 @@ static int convert_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *f
/** Filter processing.
*/
-static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
{
if ( !frame->convert_image )
frame->convert_image = convert_image;
@@ -373,10 +373,11 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
mlt_filter filter_imageconvert_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = calloc( 1, sizeof( struct mlt_filter_s ) );
- if ( mlt_filter_init( this, this ) == 0 )
+ mlt_filter filter = calloc( 1, sizeof( struct mlt_filter_s ) );
+ if ( mlt_filter_init( filter, filter ) == 0 )
{
- this->process = filter_process;
+ filter->process = filter_process;
}
- return this;
+ return filter;
}
+
View
29 src/modules/core/filter_luma.c
@@ -32,10 +32,10 @@
/** Do it :-).
*/
-static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
int error = 0;
- mlt_filter filter = mlt_frame_pop_service( this );
+ mlt_filter filter = mlt_frame_pop_service( frame );
mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
@@ -46,7 +46,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
int out = mlt_properties_get_int( properties, "period" );
int cycle = mlt_properties_get_int( properties, "cycle" );
int duration = mlt_properties_get_int( properties, "duration" );
- mlt_position position = mlt_filter_get_position( filter, this );
+ mlt_position position = mlt_filter_get_position( filter, frame );
out = out? out + 1 : 25;
if ( cycle )
@@ -84,19 +84,19 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
{
mlt_properties luma_properties = MLT_TRANSITION_PROPERTIES( luma );
mlt_properties_pass( luma_properties, properties, "luma." );
- int in = position / out * out + mlt_frame_get_position( this ) - position;
+ int in = position / out * out + mlt_frame_get_position( frame ) - position;
mlt_properties_set_int( luma_properties, "in", in );
mlt_properties_set_int( luma_properties, "out", in + duration - 1 );
- mlt_transition_process( luma, this, b_frame );
+ mlt_transition_process( luma, frame, b_frame );
}
- error = mlt_frame_get_image( this, image, format, width, height, 1 );
+ error = mlt_frame_get_image( frame, image, format, width, height, 1 );
// We only need a copy of the last frame in the cycle, but we could miss it
// with realtime frame-dropping, so we copy the last several frames of the cycle.
if ( error == 0 && modulo_pos > out - duration )
{
- mlt_properties a_props = MLT_FRAME_PROPERTIES( this );
+ mlt_properties a_props = MLT_FRAME_PROPERTIES( frame );
int size = 0;
uint8_t *src = mlt_properties_get_data( a_props, "image", &size );
uint8_t *dst = mlt_pool_alloc( size );
@@ -121,10 +121,10 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
/** Filter processing.
*/
-static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
{
// Push the filter on to the stack
- mlt_frame_push_service( frame, this );
+ mlt_frame_push_service( frame, filter );
// Push the get_image on to the stack
mlt_frame_push_get_image( frame, filter_get_image );
@@ -137,13 +137,14 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
mlt_filter filter_luma_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = mlt_filter_new( );
- if ( this != NULL )
+ mlt_filter filter = mlt_filter_new( );
+ if ( filter != NULL )
{
- mlt_properties properties = MLT_FILTER_PROPERTIES( this );
- this->process = filter_process;
+ mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
+ filter->process = filter_process;
if ( arg != NULL )
mlt_properties_set( properties, "resource", arg );
}
- return this;
+ return filter;
}
+
View
14 src/modules/core/filter_mirror.c
@@ -298,10 +298,10 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
/** Filter processing.
*/
-static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
{
// Push the service on to the stack
- mlt_frame_push_service( frame, this );
+ mlt_frame_push_service( frame, filter );
// Push the filter method on to the stack
mlt_frame_push_service( frame, filter_get_image );
@@ -315,22 +315,22 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
mlt_filter filter_mirror_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
// Construct a new filter
- mlt_filter this = mlt_filter_new( );
+ mlt_filter filter = mlt_filter_new( );
// If we have a filter, initialise it
- if ( this != NULL )
+ if ( filter != NULL )
{
// Get the properties
- mlt_properties properties = MLT_FILTER_PROPERTIES( this );
+ mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
// Set the default mirror type
mlt_properties_set_or_default( properties, "mirror", arg, "horizontal" );
// Assign the process method
- this->process = filter_process;
+ filter->process = filter_process;
}
// Return the filter
- return this;
+ return filter;
}
View
17 src/modules/core/filter_mono.c
@@ -144,9 +144,9 @@ static int filter_get_audio( mlt_frame frame, void **buffer, mlt_audio_format *f
/** Filter processing.
*/
-static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
{
- mlt_properties properties = MLT_FILTER_PROPERTIES( this );
+ mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
mlt_properties frame_props = MLT_FRAME_PROPERTIES( frame );
// Propogate the parameters
@@ -163,14 +163,15 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
mlt_filter filter_mono_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = mlt_filter_new( );
- if ( this != NULL )
+ mlt_filter filter = mlt_filter_new( );
+ if ( filter != NULL )
{
- this->process = filter_process;
+ filter->process = filter_process;
if ( arg != NULL )
- mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "channels", atoi( arg ) );
+ mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "channels", atoi( arg ) );
else
- mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "channels", -1 );
+ mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "channels", -1 );
}
- return this;
+ return filter;
}
+
View
34 src/modules/core/filter_watermark.c
@@ -37,12 +37,12 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
int error = 0;
// Get the watermark filter object
- mlt_filter this = mlt_frame_pop_service( frame );
+ mlt_filter filter = mlt_frame_pop_service( frame );
// Get the properties of the filter
- mlt_properties properties = MLT_FILTER_PROPERTIES( this );
+ mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
- mlt_service_lock( MLT_FILTER_SERVICE( this ) );
+ mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
// Get the producer from the filter
mlt_producer producer = mlt_properties_get_data( properties, "producer", NULL );
@@ -60,7 +60,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
if ( composite == NULL )
{
// Create composite via the factory
- mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( this ) );
+ mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( filter ) );
composite = mlt_factory_transition( profile, "composite", NULL );
// Register the composite for reuse/destruction
@@ -91,7 +91,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
char *factory = mlt_properties_get( properties, "factory" );
// Create the producer
- mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( this ) );
+ mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( filter ) );
producer = mlt_factory_producer( profile, factory, resource );
// If we have one
@@ -117,7 +117,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
mlt_properties_pass( producer_properties, properties, "producer." );
}
- mlt_service_unlock( MLT_FILTER_SERVICE( this ) );
+ mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
// Only continue if we have both producer and composite
if ( composite != NULL && producer != NULL )
@@ -129,7 +129,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
mlt_frame b_frame = NULL;
// Get the original producer position
- mlt_position position = mlt_filter_get_position( this, frame );
+ mlt_position position = mlt_filter_get_position( filter, frame );
// Make sure the producer is in the correct position
mlt_producer_seek( producer, position );
@@ -166,7 +166,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
if ( mlt_properties_get_int( properties, "reverse" ) == 0 )
{
// Apply all filters that are attached to this filter to the b frame
- mlt_service_apply_filters( MLT_FILTER_SERVICE( this ), b_frame, 0 );
+ mlt_service_apply_filters( MLT_FILTER_SERVICE( filter ), b_frame, 0 );
// Process the frame
mlt_transition_process( composite, frame, b_frame );
@@ -187,7 +187,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
mlt_properties_set_int( b_props, "consumer_deinterlace", 1 );
mlt_properties_set( a_props, "rescale.interp", rescale );
mlt_properties_set( b_props, "rescale.interp", rescale );
- mlt_service_apply_filters( MLT_FILTER_SERVICE( this ), b_frame, 0 );
+ mlt_service_apply_filters( MLT_FILTER_SERVICE( filter ), b_frame, 0 );
error = mlt_frame_get_image( b_frame, image, format, width, height, 1 );
alpha = mlt_frame_get_alpha_mask( b_frame );
mlt_frame_set_image( frame, *image, *width * *height * 2, NULL );
@@ -218,16 +218,16 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
/** Filter processing.
*/
-static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
{
// Get the properties of the frame
mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
// Assign the frame out point to the filter (just in case we need it later)
- mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "_out", mlt_properties_get_int( properties, "out" ) );
+ mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "_out", mlt_properties_get_int( properties, "out" ) );
// Push the filter on to the stack
- mlt_frame_push_service( frame, this );
+ mlt_frame_push_service( frame, filter );
// Push the get_image on to the stack
mlt_frame_push_get_image( frame, filter_get_image );
@@ -240,17 +240,17 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
mlt_filter filter_watermark_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = mlt_filter_new( );
- if ( this != NULL )
+ mlt_filter filter = mlt_filter_new( );
+ if ( filter != NULL )
{
- mlt_properties properties = MLT_FILTER_PROPERTIES( this );
- this->process = filter_process;
+ mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
+ filter->process = filter_process;
mlt_properties_set( properties, "factory", mlt_environment( "MLT_PRODUCER" ) );
if ( arg != NULL )
mlt_properties_set( properties, "resource", arg );
// Ensure that attached filters are handled privately
mlt_properties_set_int( properties, "_filter_private", 1 );
}
- return this;
+ return filter;
}
View
191 src/modules/oldfilm/filter_dust.c
@@ -17,8 +17,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-//#include <framework/mlt_filter.h>
-//#include <framework/mlt_frame.h>
#include <framework/mlt.h>
#include <stdio.h>
@@ -27,31 +25,36 @@
#include <string.h>
#include <time.h>
-static void overlay_image(uint8_t *src, int src_width, int src_height , uint8_t * overlay, int overlay_width, int overlay_height, uint8_t * alpha , int xpos, int ypos, int upsidedown , int mirror ){
+static void overlay_image(uint8_t *src, int src_width, int src_height , uint8_t *overlay, int overlay_width, int overlay_height, uint8_t * alpha , int xpos, int ypos, int upsidedown , int mirror )
+{
int x,y;
- for (y=ypos;y<src_height ; y++){
- if ( y>=0 && (y-ypos)<overlay_height ){
- uint8_t *scanline_image=src+src_width*y*2;
+ for ( y = ypos; y < src_height; y++)
+ {
+ if ( y >= 0 && (y - ypos) < overlay_height )
+ {
+ uint8_t *scanline_image = src + src_width * y * 2;
int overlay_y = upsidedown ? ( overlay_height - ( y - ypos ) - 1 ) : ( y - ypos );
uint8_t *scanline_overlay=overlay + overlay_width * 2 * overlay_y;
- for ( x = xpos ; x < src_width && x-xpos < overlay_width ;x++){
- if ( x>0 ){
+ for ( x = xpos ; x < src_width && x - xpos < overlay_width ;x++ )
+ {
+ if ( x > 0 )
+ {
int overlay_x = mirror ? overlay_width - ( x - xpos ) -1 : ( x - xpos );
- double alp=(double)*(alpha+ overlay_width * overlay_y + overlay_x )/255.0;
+ double alp = (double) * (alpha + overlay_width * overlay_y + overlay_x ) / 255.0;
uint8_t* image_pixel = scanline_image + x * 2;
uint8_t* overlay_pixel = scanline_overlay + overlay_x * 2;
- *image_pixel=(double)(*overlay_pixel)*alp+ (double)*image_pixel*(1.0-alp) ;
- if (xpos%2==0)
+ *image_pixel = (double)(*overlay_pixel) * alp + (double) *image_pixel * (1.0-alp) ;
+ if ( xpos % 2 == 0 )
image_pixel++;
else
- image_pixel+=3;
+ image_pixel += 3;
- mirror? overlay_pixel-- : overlay_pixel++;
+ mirror ? overlay_pixel-- : overlay_pixel++;
- *image_pixel=(double)(*(overlay_pixel))*alp + (double)(*image_pixel )*(1.0-alp) ;
+ *image_pixel = (double) (*(overlay_pixel)) * alp + (double)(*image_pixel) * ( 1.0 - alp );
}
}
@@ -59,58 +62,62 @@ static void overlay_image(uint8_t *src, int src_width, int src_height , uint8_t
}
}
-static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
- mlt_filter filter = mlt_frame_pop_service( this );
+ mlt_filter filter = (mlt_filter) mlt_frame_pop_service( frame );
+ mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
+ mlt_position pos = mlt_filter_get_position( filter, frame );
+ mlt_position len = mlt_filter_get_length2( filter, frame );
- int maxdia = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "maxdiameter" );
- int maxcount = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "maxcount" );
+ int maxdia = mlt_properties_anim_get_int( properties, "maxdiameter", pos, len );
+ int maxcount = mlt_properties_anim_get_int( properties, "maxcount", pos, len );
*format = mlt_image_yuv422;
- int error = mlt_frame_get_image( this, image, format, width, height, 1 );
- // load svg
- mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
+ int error = mlt_frame_get_image( frame, image, format, width, height, 1 );
+
+ // Load svg
char *factory = mlt_properties_get( properties, "factory" );
- char temp[1204]="";
+ char temp[1204] = "";
sprintf( temp, "%s/oldfilm/", mlt_environment( "MLT_DATA" ) );
- mlt_properties direntries=mlt_properties_new();
- mlt_properties_dir_list(direntries,temp,"dust*.svg",1);
+ mlt_properties direntries = mlt_properties_new();
+ mlt_properties_dir_list( direntries, temp,"dust*.svg",1 );
if (!maxcount)
return 0;
- double position = mlt_filter_get_progress( filter, this );
- srand(position*10000);
+ double position = mlt_filter_get_progress( filter, frame );
+ srand( position * 10000 );
mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
- int im=rand()%maxcount;
- int piccount=mlt_properties_count(direntries);
- while (im-- && piccount){
-
- int picnum=rand()%piccount;
+ int im = rand() % maxcount;
+ int piccount = mlt_properties_count( direntries );
+ while ( im-- && piccount )
+ {
+ int picnum = rand() % piccount;
- int y1=rand()%*height;
- int x1=rand()%*width;
- char resource[1024]="";
- char savename[1024]="",savename1[1024]="", cachedy[100];
- int dx=(*width*maxdia/100);
- int luma_width,luma_height;
+ int y1 = rand() % *height;
+ int x1 = rand() % *width;
+ char resource[1024] = "";
+ char savename[1024] = "", savename1[1024] = "", cachedy[100];
+ int dx = ( *width * maxdia / 100);
+ int luma_width, luma_height;
uint8_t *luma_image = NULL;
- uint8_t *alpha =NULL;
- int updown= rand()%2;
- int mirror=rand()%2;
+ uint8_t *alpha = NULL;
+ int updown = rand() % 2;
+ int mirror = rand() % 2;
- sprintf(resource,"%s",mlt_properties_get_value(direntries,picnum));
- sprintf(savename,"cache-%d-%d",picnum,dx);
- sprintf(savename1,"cache-alpha-%d-%d",picnum,dx);
- sprintf(cachedy,"cache-dy-%d-%d",picnum,dx);
+ sprintf( resource, "%s", mlt_properties_get_value(direntries,picnum) );
+ sprintf( savename, "cache-%d-%d", picnum,dx );
+ sprintf( savename1, "cache-alpha-%d-%d", picnum, dx );
+ sprintf( cachedy, "cache-dy-%d-%d", picnum,dx );
- luma_image= mlt_properties_get_data( properties , savename , NULL );
- alpha= mlt_properties_get_data( properties , savename1 , NULL );
+ luma_image = mlt_properties_get_data( properties , savename , NULL );
+ alpha = mlt_properties_get_data( properties , savename1 , NULL );
- if (luma_image == NULL || alpha == NULL ){
+ if ( luma_image == NULL || alpha == NULL )
+ {
mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( filter ) );
mlt_producer producer = mlt_factory_producer( profile, factory, resource );
@@ -121,8 +128,8 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
mlt_properties_set( producer_properties, "eof", "loop" );
mlt_frame luma_frame = NULL;
- if ( mlt_service_get_frame( MLT_PRODUCER_SERVICE( producer ), &luma_frame, 0 ) == 0 ){
-
+ if ( mlt_service_get_frame( MLT_PRODUCER_SERVICE( producer ), &luma_frame, 0 ) == 0 )
+ {
mlt_image_format luma_format = mlt_image_yuv422;
luma_width = dx;
luma_height = luma_width * mlt_properties_get_int( MLT_FRAME_PROPERTIES ( luma_frame ) , "height" ) / mlt_properties_get_int( MLT_FRAME_PROPERTIES ( luma_frame ) , "width" );
@@ -130,27 +137,30 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
mlt_properties_set( MLT_FRAME_PROPERTIES( luma_frame ), "rescale.interp", "best" );// none/nearest/tiles/hyper
mlt_frame_get_image( luma_frame, &luma_image, &luma_format, &luma_width, &luma_height, 0 );
- alpha =mlt_frame_get_alpha_mask(luma_frame);
+ alpha = mlt_frame_get_alpha_mask (luma_frame );
- uint8_t* savealpha=mlt_pool_alloc ( luma_width * luma_height );
- uint8_t* savepic=mlt_pool_alloc ( luma_width * luma_height * 2);
+ uint8_t* savealpha = mlt_pool_alloc( luma_width * luma_height );
+ uint8_t* savepic = mlt_pool_alloc( luma_width * luma_height * 2);
- if (savealpha && savepic ){
- memcpy (savealpha, alpha , luma_width * luma_height );
- memcpy (savepic, luma_image , luma_width * luma_height * 2);
+ if ( savealpha && savepic )
+ {
+ memcpy( savealpha, alpha , luma_width * luma_height );
+ memcpy( savepic, luma_image , luma_width * luma_height * 2 );
- mlt_properties_set_data ( properties , savename , savepic , sizeof(savepic) , mlt_pool_release, NULL );
- mlt_properties_set_data ( properties , savename1 , savealpha , sizeof(savealpha) , mlt_pool_release, NULL );
- mlt_properties_set_int ( properties , cachedy , luma_height );
+ mlt_properties_set_data( properties, savename, savepic, sizeof(savepic), mlt_pool_release, NULL );
+ mlt_properties_set_data( properties, savename1, savealpha, sizeof(savealpha), mlt_pool_release, NULL );
+ mlt_properties_set_int( properties, cachedy, luma_height );
- overlay_image(*image,*width,*height,luma_image,luma_width,luma_height, alpha, x1, y1 , updown , mirror );
+ overlay_image( *image, *width, *height, luma_image, luma_width, luma_height, alpha, x1, y1, updown, mirror );
}
mlt_frame_close( luma_frame );
}
mlt_producer_close( producer );
}
- }else {
- overlay_image ( *image , *width, *height , luma_image , dx , mlt_properties_get_int ( properties , cachedy ) , alpha , x1 , y1 , updown , mirror );
+ }
+ else
+ {
+ overlay_image ( *image, *width, *height, luma_image, dx, mlt_properties_get_int ( properties, cachedy ), alpha, x1, y1, updown, mirror );
}
}
@@ -163,61 +173,64 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
int h = *height;
int w = *width;
- int im=rand()%maxcount;
+ int im = rand() % maxcount;
- while (im-- ){
- int type=im%2;
- int y1=rand()%h;
- int x1=rand()%w;
- int dx=rand()%maxdia;
- int dy=rand()%maxdia;
- int x=0,y=0;//,v=0;
- double v=0.0;
+ while ( im-- )
+ {
+ int type = im % 2;
+ int y1 = rand() % h;
+ int x1 = rand() % w;
+ int dx = rand() % maxdia;
+ int dy = rand() % maxdia;
+ int x=0, y=0;
+ double v = 0.0;
for ( x = -dx ; x < dx ; x++ )
- for ( y = -dy ; y < dy ; y++ ) {
- if ( x1+x < w && x1+x > 0 && y1+y < h && y1+y > 0 ){
- uint8_t *pix=*image+(y+y1)*w*2+(x+x1)*2;
- //v=(1.0-fabs(x)/dx)*(1.0-fabs(y)/dy);
- v=pow((double)x/(double)dx*5.0,2.0)+pow((double)y/(double)dy*5.0,2.0);
+ {
+ for ( y = -dy ; y < dy ; y++ )
+ {
+ if ( x1 + x < w && x1 + x > 0 && y1 + y < h && y1 + y > 0 ){
+ uint8_t *pix = *image + (y+y1) * w * 2 + (x + x1) * 2;
+
+ v=pow((double) x /(double)dx * 5.0, 2.0) + pow((double)y / (double)dy * 5.0, 2.0);
if (v>10)
v=10;
- v=1.0-(v/10.0);
+ v = 1.0 - ( v / 10.0 );
- switch(type){
+ switch(type)
+ {
case 0:
- *pix-=(*pix)*v;
+ *pix -= (*pix) * v;
break;
case 1:
- *pix+=(255-*pix)*v;
+ *pix += ( 255-*pix ) * v;
break;
}
}
}
+ }
}
}
return error;
}
-static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
{
-
- mlt_frame_push_service( frame, this );
+ mlt_frame_push_service( frame, filter );
mlt_frame_push_get_image( frame, filter_get_image );
return frame;
}
-
mlt_filter filter_dust_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = mlt_filter_new( );
- if ( this != NULL )
+ mlt_filter filter = mlt_filter_new( );
+ if ( filter != NULL )
{
- this->process = filter_process;
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "maxdiameter", "2" );
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "maxcount", "10" );
+ filter->process = filter_process;
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "maxdiameter", "2" );
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "maxcount", "10" );
}
- return this;
+ return filter;
}
View
124 src/modules/oldfilm/filter_lines.c
@@ -24,113 +24,125 @@
#include <stdlib.h>
#include <math.h>
-static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
+ mlt_filter filter = (mlt_filter) mlt_frame_pop_service( frame );
+ mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
+ mlt_position pos = mlt_filter_get_position( filter, frame );
+ mlt_position len = mlt_filter_get_length2( filter, frame );
- mlt_filter filter = mlt_frame_pop_service( this );
*format = mlt_image_yuv422;
- int error = mlt_frame_get_image( this, image, format, width, height, 1 );
+ int error = mlt_frame_get_image( frame, image, format, width, height, 1 );
if ( error == 0 && *image )
{
int h = *height;
int w = *width;
- int line_width = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "line_width" );
- int num = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "num" );
- double maxdarker= (double)mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "darker" ) ;
- double maxlighter=(double)mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "lighter" ) ;
- //int frame = mlt_properties_get_int( this, "_position" );
+ int line_width = mlt_properties_anim_get_int( properties, "line_width", pos, len );
+ int num = mlt_properties_anim_get_int( properties, "num", pos, len );
+ double maxdarker = (double) mlt_properties_anim_get_int( properties, "darker", pos, len );
+ double maxlighter = (double) mlt_properties_anim_get_int( properties, "lighter", pos, len );
+
char buf[256];
char typebuf[256];
if ( line_width < 1 )
return 0;
- double position = mlt_filter_get_progress( filter, this );
+ double position = mlt_filter_get_progress( filter, frame );
srand(position*10000);
mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
- while (num--){
- int type=(rand()%3)+1;
- int x1=(double)w*rand()/RAND_MAX;
- int dx=rand()%line_width;
- int x=0,y=0;
- int ystart=rand()%h;
- int yend=rand()%h;
-
- sprintf(buf,"line%d",num);
- sprintf(typebuf,"typeline%d",num);
- maxlighter+=rand()%30-15;
- maxdarker+=rand()%30-15;
-
- if (mlt_properties_get_int(MLT_FILTER_PROPERTIES( filter ),buf)==0){
- mlt_properties_set_int(MLT_FILTER_PROPERTIES( filter ),buf,x1);
+ while ( num-- )
+ {
+ int type = (rand() % 3 ) + 1;
+ int x1 = (double)w * rand() / RAND_MAX;
+ int dx = rand() % line_width;
+ int x = 0, y = 0;
+ int ystart = rand() % h;
+ int yend = rand() % h;
+
+ sprintf( buf, "line%d", num);
+ sprintf( typebuf, "typeline%d", num);
+ maxlighter += rand() % 30 -15;
+ maxdarker += rand() % 30 -15;
+
+ if ( mlt_properties_get_int(MLT_FILTER_PROPERTIES( filter ),buf ) ==0 )
+ {
+ mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), buf, x1 );
}
-
- if (mlt_properties_get_int(MLT_FILTER_PROPERTIES( filter ),typebuf)==0 ){
+
+ if ( mlt_properties_get_int(MLT_FILTER_PROPERTIES( filter ),typebuf)==0 )
+ {
mlt_properties_set_int(MLT_FILTER_PROPERTIES( filter ),typebuf,type);
}
- x1=mlt_properties_get_int(MLT_FILTER_PROPERTIES( filter ),buf);
- type=mlt_properties_get_int(MLT_FILTER_PROPERTIES( filter ),typebuf);
- if (position!=mlt_properties_get_double(MLT_FILTER_PROPERTIES( filter ),"last_oldfilm_line_pos")){
- x1+=(rand()%11-5);
+ x1 = mlt_properties_get_int(MLT_FILTER_PROPERTIES( filter ), buf );
+ type = mlt_properties_get_int(MLT_FILTER_PROPERTIES( filter ), typebuf );
+ if ( position != mlt_properties_get_double(MLT_FILTER_PROPERTIES( filter ), "last_oldfilm_line_pos"))
+ {
+ x1 += (rand() % 11 - 5);
}
-
- if (yend<ystart){
+
+ if ( yend < ystart)
+ {
yend=h;
}
-
- for (x = -dx ; x < dx && dx != 0 ; x++ )
- for(y=ystart;y<yend;y++)
- if (x+x1<w && x+x1>0){
- uint8_t* pixel=(*image+(y)*w*2+(x+x1)*2);
- double diff=1.0-fabs(x)/dx;
- switch(type){
+
+ for ( x = -dx ; x < dx && dx != 0 ; x++ )
+ {
+ for( y = ystart; y < yend; y++ )
+ {
+ if ( x + x1 < w && x + x1 > 0)
+ {
+ uint8_t* pixel = (*image + (y) * w * 2 + ( x + x1) * 2);
+ double diff = 1.0 - fabs(x) / dx;
+ switch( type )
+ {
case 1: //blackline
- *pixel-=((double)*pixel*diff*maxdarker/100.0);
+ *pixel -= ((double) * pixel * diff * maxdarker / 100.0);
break;
case 2: //whiteline
- *pixel+=((255.0-(double)*pixel)*diff*maxlighter/100.0);
+ *pixel += ((255.0-(double)*pixel) * diff * maxlighter /100.0);
break;
case 3: //greenline
- *(pixel+1)-=((*(pixel+1))*diff*maxlighter/100.0);
+ *(pixel+1) -= ((*(pixel+1)) * diff * maxlighter / 100.0);
break;
}
+ }
}
- mlt_properties_set_int(MLT_FILTER_PROPERTIES( filter ),buf,x1);
+ }
+ mlt_properties_set_int(MLT_FILTER_PROPERTIES( filter ),buf , x1);
}
- mlt_properties_set_double(MLT_FILTER_PROPERTIES( filter ),"last_oldfilm_line_pos",position);
+ mlt_properties_set_double(MLT_FILTER_PROPERTIES( filter ),"last_oldfilm_line_pos", position);
mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
}
return error;
}
-static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
{
-
- mlt_frame_push_service( frame, this );
+ mlt_frame_push_service( frame, filter );
mlt_frame_push_get_image( frame, filter_get_image );
return frame;
}
mlt_filter filter_lines_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = mlt_filter_new( );
- if ( this != NULL )
+ mlt_filter filter = mlt_filter_new( );
+ if ( filter != NULL )
{
- this->process = filter_process;
- mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "line_width", 2 );
- mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "num", 5 );
- mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "darker" , 40 ) ;
- mlt_properties_set_int( MLT_FILTER_PROPERTIES( this ), "lighter" , 40 ) ;
+ filter->process = filter_process;
+ mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "line_width", 2 );
+ mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "num", 5 );
+ mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "darker" , 40 ) ;
+ mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "lighter" , 40 ) ;
}
- return this;
+ return filter;
}
-
View
219 src/modules/oldfilm/filter_oldfilm.c
@@ -23,144 +23,147 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-static double sinarr[]={
-// 0.0,0.125270029508395,0.2485664757507,0.3679468485397,0.481530353985902,
-// 0.587527525713892,0.684268417247276,0.770228911401552,0.84405473219009,0.904582780944473,
-// 0.95085946050647,0.982155698800724,0.997978435097294,0.99807838800221,0.982453982794196,
-// 0.951351376233828,0.90526057845426,0.844907733031696,0.771243676860277,0.685428960066342,
-// 0.588815561967795,0.48292559113694,0.369427305139443,0.250108827749629,0.12684997771773,
-// 0.00159265291648683,-0.123689763546002,-0.247023493251739,-0.366465458626247,-0.48013389541149,
-// -0.586237999170027,-0.683106138750633,-0.769212192222595,-0.84319959036574,-0.903902688919827,
-// -0.950365132881376,-0.981854923525203,-0.997875950775248,-0.998175809236459,-0.982749774749007,
-// -0.951840878815686,-0.905936079729926,-0.845758590726883,-0.772256486024771,-0.68658776426406,
-// -0.590102104664575,-0.484319603325524,-0.37090682467023,-0.251650545336281,-0.128429604166398,0.0
-0.0,0.0627587292804297,0.125270029508395,0.18728744713136,0.2485664757507,0.308865520098932,0.3679468485397,0.425577530335206,0.481530353985902,0.535584723021826,0.587527525713892,0.637153975276265,0.684268417247276,0.728685100865749,0.770228911401552,0.80873606055313,0.84405473219009,0.876045680894979,0.904582780944473,0.929553523565587,0.95085946050647,0.968416592172968,0.982155698800724,0.99202261335714,0.997978435097294,0.999999682931835,0.99807838800221,0.992222125098244,0.982453982794196,0.968812472421035,0.951351376233828,0.930139535372831,0.90526057845426,0.876812591860795,0.844907733031696,0.809671788277164,0.771243676860277,0.72977490330168,0.685428960066342,0.638380682987321,0.588815561967795,0.536929009678953,0.48292559113694,0.427018217196276,0.369427305139443,0.310379909672042,0.250108827749629,0.188851680765468,0.12684997771773,0.064348163049637,0.00159265291648683,-0.0611691363208864,-0.123689763546002,-0.18572273843423,-0.247023493251739,-0.307350347074556,-0.366465458626247,-0.424135763977612,-0.48013389541149,-0.534239077829989,-0.586237999170027,-0.635925651395529,-0.683106138750633,-0.727593450087328,-0.769212192222595,-0.807798281433749,-0.84319959036574,-0.875276547799941,-0.903902688919827,-0.928965153904073,-0.950365132881376,-0.968018255492714,-0.981854923525203,-0.991820585306115,-0.997875950775248,-0.999997146387718,-0.998175809236459,-0.992419120023356,-0.982749774749007,-0.969205895232745,-0.951840878815686,-0.930723187839362,-0.905936079729926,-0.877577278752084,-0.845758590726883,-0.810605462232336,-0.772256486024771,-0.730862854630786,-0.68658776426406,-0.639605771417098,-0.590102104664575,-0.538271934391528,-0.484319603325524,-0.428457820906457,-0.37090682467023,-0.311893511952568,-0.251650545336281,-0.190415435368805,-0.128429604166398,-0.0659374335968388,0.0,
+static double sinarr[] = {
+0.0,0.0627587292804297,0.125270029508395,0.18728744713136,0.2485664757507,0.308865520098932,
+0.3679468485397,0.425577530335206,0.481530353985902,0.535584723021826,0.587527525713892,0.637153975276265,
+0.684268417247276,0.728685100865749,0.770228911401552,0.80873606055313,0.84405473219009,0.876045680894979,
+0.904582780944473,0.929553523565587,0.95085946050647,0.968416592172968,0.982155698800724,0.99202261335714,
+0.997978435097294,0.999999682931835,0.99807838800221,0.992222125098244,0.982453982794196,0.968812472421035,
+0.951351376233828,0.930139535372831,0.90526057845426,0.876812591860795,0.844907733031696,0.809671788277164,
+0.771243676860277,0.72977490330168,0.685428960066342,0.638380682987321,0.588815561967795,0.536929009678953,
+0.48292559113694,0.427018217196276,0.369427305139443,0.310379909672042,0.250108827749629,0.188851680765468,
+0.12684997771773,0.064348163049637,0.00159265291648683,-0.0611691363208864,-0.123689763546002,-0.18572273843423,
+-0.247023493251739,-0.307350347074556,-0.366465458626247,-0.424135763977612,-0.48013389541149,-0.534239077829989,
+-0.586237999170027,-0.635925651395529,-0.683106138750633,-0.727593450087328,-0.769212192222595,-0.807798281433749,
+-0.84319959036574,-0.875276547799941,-0.903902688919827,-0.928965153904073,-0.950365132881376,-0.968018255492714,
+-0.981854923525203,-0.991820585306115,-0.997875950775248,-0.999997146387718,-0.998175809236459,-0.992419120023356,
+-0.982749774749007,-0.969205895232745,-0.951840878815686,-0.930723187839362,-0.905936079729926,-0.877577278752084,
+-0.845758590726883,-0.810605462232336,-0.772256486024771,-0.730862854630786,-0.68658776426406,-0.639605771417098,
+-0.590102104664575,-0.538271934391528,-0.484319603325524,-0.428457820906457,-0.37090682467023,-0.311893511952568,
+-0.251650545336281,-0.190415435368805,-0.128429604166398,-0.0659374335968388,0.0,
};
-static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
+ mlt_filter filter = (mlt_filter) mlt_frame_pop_service( frame );
+ mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
+ mlt_position pos = mlt_filter_get_position( filter, frame );
+ mlt_position len = mlt_filter_get_length2( filter, frame );
- mlt_filter filter = mlt_frame_pop_service( this );
*format = mlt_image_yuv422;
- int error = mlt_frame_get_image( this, image, format, width, height, 1 );
-
+ int error = mlt_frame_get_image( frame, image, format, width, height, 1 );
+
if ( error == 0 && *image )
{
int h = *height;
int w = *width;
- int x=0;
- int y=0;
-
- double position = mlt_filter_get_progress( filter, this );
- srand(position*10000);
-
- int delta = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "delta" );
- int every = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "every" );
-
- int bdu = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "brightnessdelta_up" );
- int bdd = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "brightnessdelta_down" );
- int bevery = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "brightnessdelta_every" );
-
- int udu = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "unevendevelop_up" );
- int udd = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "unevendevelop_down" );
- int uduration = mlt_properties_get_int( MLT_FILTER_PROPERTIES( filter ), "unevendevelop_duration" );
-
- int diffpic=0;
- if (delta)
- diffpic=rand()%delta*2-delta;
-
- int brightdelta=0;
- if ((bdu+bdd)!=0)
- brightdelta=rand()%(bdu+bdd)-bdd;
- if (rand()%100>every)
- diffpic=0;
- if (rand()%100>bevery)
- brightdelta=0;
- int yend,ydiff;
- int unevendevelop_delta=0;
- if (uduration>0){
- float uval= sinarr[ ( ((int)position) % uduration) * 100 / uduration ] ;
- unevendevelop_delta = uval * ( uval>0 ? udu : udd );
+ int x = 0;
+ int y = 0;
+
+ double position = mlt_filter_get_progress( filter, frame );
+ srand( position * 10000);
+
+ int delta = mlt_properties_anim_get_int( properties, "delta", pos, len );
+ int every = mlt_properties_anim_get_int( properties, "every", pos, len );
+
+ int bdu = mlt_properties_anim_get_int( properties, "brightnessdelta_up", pos, len );
+ int bdd = mlt_properties_anim_get_int( properties, "brightnessdelta_down", pos, len );
+ int bevery = mlt_properties_anim_get_int( properties, "brightnessdelta_every", pos, len );
+
+ int udu = mlt_properties_anim_get_int( properties, "unevendevelop_up", pos, len );
+ int udd = mlt_properties_anim_get_int( properties, "unevendevelop_down", pos, len );
+ int uduration = mlt_properties_anim_get_int( properties, "unevendevelop_duration", pos, len );
+
+ int diffpic = 0;
+ if ( delta )
+ diffpic = rand() % delta * 2 - delta;
+ int brightdelta = 0;
+ if (( bdu + bdd ) != 0 )
+ brightdelta = rand() % (bdu + bdd) - bdd;
+ if ( rand() % 100 > every )
+ diffpic = 0;
+ if ( rand() % 100 > bevery)
+ brightdelta = 0;
+ int yend, ydiff;
+ int unevendevelop_delta = 0;
+ if ( uduration > 0 )
+ {
+ float uval = sinarr[ ( ((int)position) % uduration) * 100 / uduration ];
+ unevendevelop_delta = uval * ( uval > 0 ? udu : udd );
}
-
-
-
- if (diffpic<=0){
- y=h;
- yend=0;
- ydiff=-1;
- }else{
- y=0;
- yend=h;
- ydiff=1;
+ if ( diffpic <= 0 )
+ {
+ y = h;
+ yend = 0;
+ ydiff =- 1;
+ }
+ else
+ {
+ y = 0;
+ yend = h;
+ ydiff = 1;
}
- while(y!=yend){
- //int newy=y+diffpic;
- for (x=0;x<w;x++){
- uint8_t* pic=(*image+y*w*2+x*2);
- int newy=y+diffpic;
- if (newy>0 && newy<h ){
- uint8_t oldval=*(pic+diffpic*w*2);
- /* frame around
- int randx=(x<=frameborder)?x:(x+frameborder>w)?w-x:-1;
- int randy=((newy)<=frameborder)?(newy):((newy)+frameborder>h)?h-(y+diffpic):-1;
- if (randx>=0 ){
- oldval=oldval*pow(((double)randx/(double)frameborder),1.5);
- }
- if (randy>=0 ){
- oldval=oldval*pow(((double)randy/(double)frameborder),1.5);
- }
- if (randx>=0 && randy>=0){
- //oldval=oldval*(randx*randy)/500.0;
- }
- */
- if ( ((int) oldval + brightdelta + unevendevelop_delta ) >255)
- *pic=255;
- else if ( ( (int) oldval + brightdelta + unevendevelop_delta ) <0){
- *pic=0;
- }else
- *pic = oldval + brightdelta + unevendevelop_delta;
- *(pic+1)=*(pic+diffpic*w*2+1);
-
- }else{
+ while( y != yend )
+ {
+ for ( x = 0; x < w; x++ )
+ {
+ uint8_t* pic = ( *image + y * w * 2 + x * 2 );
+ int newy = y + diffpic;
+ if ( newy > 0 && newy < h )
+ {
+ uint8_t oldval= *( pic + diffpic * w * 2 );
+ if ( ((int) oldval + brightdelta + unevendevelop_delta ) > 255 )
+ {
+ *pic=255;
+ }
+ else if ( ( (int) oldval + brightdelta + unevendevelop_delta ) <0 )
+ {
*pic=0;
- //*(pic-1)=127;
}
-
- }
- y+=ydiff;
+ else
+ {
+ *pic = oldval + brightdelta + unevendevelop_delta;
+ }
+ *( pic + 1 ) =* ( pic + diffpic * w * 2 + 1 );
+
+ }
+ else
+ {
+ *pic = 0;
+ }
+ }
+ y += ydiff;
}
}
return error;
}
-static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
{
-
- mlt_frame_push_service( frame, this );
+ mlt_frame_push_service( frame, filter );
mlt_frame_push_get_image( frame, filter_get_image );
return frame;
}
mlt_filter filter_oldfilm_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = mlt_filter_new( );
- if ( this != NULL )
+ mlt_filter filter = mlt_filter_new( );
+ if ( filter != NULL )
{
- this->process = filter_process;
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "delta", "14" );
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "every", "20" );
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "brightnessdelta_up" , "20" );
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "brightnessdelta_down" , "30" );
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "brightnessdelta_every" , "70" );
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "unevendevelop_up" , "60" );
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "unevendevelop_down" , "20" );
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "unevendevelop_duration" , "70" );
+ filter->process = filter_process;
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "delta", "14" );
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "every", "20" );
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "brightnessdelta_up" , "20" );
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "brightnessdelta_down" , "30" );
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "brightnessdelta_every" , "70" );
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "unevendevelop_up" , "60" );
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "unevendevelop_down" , "20" );
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "unevendevelop_duration" , "70" );
}
- return this;
+ return filter;
}
View
51 src/modules/oldfilm/filter_tcolor.c
@@ -27,60 +27,57 @@
#define MIN(a,b) (a<b?a:b)
#define MAX(a,b) (a<b?b:a)
-static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
+static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
+ mlt_filter filter = (mlt_filter) mlt_frame_pop_service( frame );
+ mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
+ mlt_position pos = mlt_filter_get_position( filter, frame );
+ mlt_position len = mlt_filter_get_length2( filter, frame );
- mlt_filter filter = mlt_frame_pop_service( this );
*format = mlt_image_yuv422;
- int error = mlt_frame_get_image( this, image, format, width, height, 1 );
+ int error = mlt_frame_get_image( frame, image, format, width, height, 1 );
if ( error == 0 && *image )
{
+ double over_cr = mlt_properties_anim_get_double( properties, "oversaturate_cr", pos, len )/100.0;
+ double over_cb = mlt_properties_anim_get_double( properties, "oversaturate_cb", pos, len )/100.0;
- double over_cr = mlt_properties_get_double( MLT_FILTER_PROPERTIES( filter ), "oversaturate_cr" )/100.0;
- double over_cb = mlt_properties_get_double( MLT_FILTER_PROPERTIES( filter ), "oversaturate_cb" )/100.0;
-
int video_width = *width;
int video_height = *height;
int x,y;
- for (y=0;y<video_height;y++){
- for (x=0;x<video_width;x+=2){
- uint8_t *pix=(*image+y*video_width*2+x*2+1);
- uint8_t *pix1=(*image+y*video_width*2+x*2+3);
- *pix=MIN(MAX( ((double)*pix-127.0)*over_cb+127.0,0),255);
- *pix1=MIN(MAX( ((double)*pix1-127.0)*over_cr+127.0,0),255);
+ for ( y = 0; y < video_height; y++)
+ {
+ for ( x = 0; x < video_width; x += 2)
+ {
+ uint8_t *pix = (*image + y * video_width * 2 + x * 2 + 1);
+ uint8_t *pix1 = (*image + y * video_width * 2 + x * 2 + 3);
+ *pix = MIN(MAX( ((double) * pix - 127.0) * over_cb + 127.0,0), 255);
+ *pix1 = MIN(MAX( ((double) * pix1 - 127.0) * over_cr + 127.0,0), 255);
}
}
- // short a, short b, short c, short d
- // a= gray val pix 1
- // b: +=blue, -=yellow
- // c: =gray pix 2
- // d: +=red,-=green
}
return error;
}
-static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
+static mlt_frame filter_process( mlt_filter filter, mlt_frame frame )
{
- mlt_frame_push_service( frame, this );
+ mlt_frame_push_service( frame, filter );
mlt_frame_push_get_image( frame, filter_get_image );
return frame;
}
-
mlt_filter filter_tcolor_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
- mlt_filter this = mlt_filter_new( );
- if ( this != NULL )
+ mlt_filter filter = mlt_filter_new( );
+ if ( filter != NULL )
{
- this->process = filter_process;
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "oversaturate_cr", "190" );
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "oversaturate_cb", "190" );
+ filter->process = filter_process;
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "oversaturate_cr", "190" );
+ mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "oversaturate_cb", "190" );
}
- return this;
+ return filter;
}
-
Please sign in to comment.
Something went wrong with that request. Please try again.