]> git.sesse.net Git - mlt/blob - src/modules/opengl/filter_movit_convert.cpp
056a4f38728ac3015af3dedef5de17513342ee28
[mlt] / src / modules / opengl / filter_movit_convert.cpp
1 /*
2  * filter_movit_convert.cpp
3  * Copyright (C) 2013 Dan Dennedy <dan@dennedy.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #include <framework/mlt.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include <assert.h>
24 #include <string>
25
26 #include "filter_glsl_manager.h"
27 #include <movit/effect_chain.h>
28 #include <movit/util.h>
29 #include "mlt_movit_input.h"
30 #include <mlt++/MltProducer.h>
31 #include "mlt_flip_effect.h"
32
33 static void yuv422_to_yuv422p( uint8_t *yuv422, uint8_t *yuv422p, int width, int height )
34 {
35         uint8_t *Y = yuv422p;
36         uint8_t *U = Y + width * height;
37         uint8_t *V = U + width * height / 2;
38         int n = width * height / 2 + 1;
39         while ( --n ) {
40                 *Y++ = *yuv422++;
41                 *U++ = *yuv422++;
42                 *Y++ = *yuv422++;
43                 *V++ = *yuv422++;
44         }
45 }
46
47 static int convert_on_cpu( mlt_frame frame, uint8_t **image, mlt_image_format *format, mlt_image_format output_format )
48 {
49         int error = 0;
50         mlt_filter cpu_csc = (mlt_filter) mlt_properties_get_data( MLT_FRAME_PROPERTIES( frame ), "cpu_csc", NULL );
51         if ( cpu_csc ) {
52                 int (* save_fp )( mlt_frame self, uint8_t **image, mlt_image_format *input, mlt_image_format output )
53                         = frame->convert_image;
54                 frame->convert_image = NULL;
55                 mlt_filter_process( cpu_csc, frame );
56                 error = frame->convert_image( frame, image, format, output_format );
57                 frame->convert_image = save_fp;
58         } else {
59                 error = 1;
60         }
61         return error;
62 }
63
64 static void delete_chain( EffectChain* chain )
65 {
66         delete chain;
67 }
68
69 static void get_format_from_properties( mlt_properties properties, ImageFormat* image_format, YCbCrFormat* ycbcr_format )
70 {
71         switch ( mlt_properties_get_int( properties, "colorspace" ) ) {
72         case 601:
73                 ycbcr_format->luma_coefficients = YCBCR_REC_601;
74                 break;
75         case 709:
76         default:
77                 ycbcr_format->luma_coefficients = YCBCR_REC_709;
78                 break;
79         }
80
81         switch ( mlt_properties_get_int( properties, "color_primaries" ) ) {
82         case 601625:
83                 image_format->color_space = COLORSPACE_REC_601_625;
84                 break;
85         case 601525:
86                 image_format->color_space = COLORSPACE_REC_601_525;
87                 break;
88         case 709:
89         default:
90                 image_format->color_space = COLORSPACE_REC_709;
91                 break;
92         }
93
94         image_format->gamma_curve = GAMMA_REC_709;
95
96         if ( mlt_properties_get_int( properties, "force_full_luma" ) ) {
97                 ycbcr_format->full_range = true;
98         } else {
99                 ycbcr_format->full_range = ( mlt_properties_get_int( properties, "full_luma" ) == 1 );
100         }
101
102         // TODO: make new frame properties set by producers
103         ycbcr_format->cb_x_position = ycbcr_format->cr_x_position = 0.0f;
104         ycbcr_format->cb_y_position = ycbcr_format->cr_y_position = 0.5f;
105 }
106
107 static void build_fingerprint( mlt_service service, mlt_frame frame, std::string *fingerprint )
108 {
109         if ( service == (mlt_service) -1 ) {
110                 fingerprint->append( "input" );
111                 return;
112         }
113
114         Effect* effect = GlslManager::get_effect( service, frame );
115         assert( effect );
116         mlt_service input_a = GlslManager::get_effect_input( service, frame );
117         fingerprint->push_back( '(' );
118         build_fingerprint( input_a, frame, fingerprint );
119         fingerprint->push_back( ')' );
120
121         mlt_frame frame_b;
122         mlt_service input_b;
123         GlslManager::get_effect_secondary_input( service, frame, &input_b, &frame_b );
124         if ( input_b ) {
125                 fingerprint->push_back( '(' );
126                 build_fingerprint( input_b, frame_b, fingerprint );
127                 fingerprint->push_back( ')' );
128         }
129
130         fingerprint->push_back( '(' );
131         fingerprint->append( mlt_properties_get( MLT_SERVICE_PROPERTIES( service ), "_unique_id" ) );
132         bool disable = mlt_properties_get_int( MLT_SERVICE_PROPERTIES( service ), "movit.disable" );
133         if ( disable ) {
134                 fingerprint->push_back( 'd' );
135                 bool ok = effect->set_int( "disable", 1 );
136                 assert(ok);
137         }
138         fingerprint->push_back( ')' );
139 }
140
141 static Effect* build_movit_chain( mlt_service service, mlt_frame frame, GlslChain *chain )
142 {
143         if ( service == (mlt_service) -1 ) {
144                 mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
145                 MltInput* input = GlslManager::get_input( producer, frame );
146                 GlslManager::set_input( producer, frame, NULL );
147                 chain->effect_chain->add_input( input );
148                 chain->effects.insert(std::make_pair( MLT_SERVICE( producer ), input ) );
149                 return input;
150         }
151
152         Effect* effect = GlslManager::get_effect( service, frame );
153         assert( effect );
154         GlslManager::set_effect( service, frame, NULL );
155
156         mlt_service input_a = GlslManager::get_effect_input( service, frame );
157         mlt_service input_b;
158         mlt_frame frame_b;
159         GlslManager::get_effect_secondary_input( service, frame, &input_b, &frame_b );
160         Effect *effect_a = build_movit_chain( input_a, frame, chain );
161
162         if ( input_b ) {
163                 Effect *effect_b = build_movit_chain( input_b, frame_b, chain );
164                 chain->effect_chain->add_effect( effect, effect_a, effect_b );
165         } else {
166                 chain->effect_chain->add_effect( effect, effect_a );
167         }
168                 
169         chain->effects.insert(std::make_pair( service, effect ) );
170         return effect;
171 }
172
173 static void dispose_movit_effects( mlt_service service, mlt_frame frame )
174 {
175         if ( service == (mlt_service) -1 ) {
176                 mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
177                 delete GlslManager::get_input( producer, frame );
178                 GlslManager::set_input( producer, frame, NULL );
179                 return;
180         }
181
182         delete GlslManager::get_effect( service, frame );
183         GlslManager::set_effect( service, frame, NULL );
184
185         mlt_service input_a = GlslManager::get_effect_input( service, frame );
186         mlt_service input_b;
187         mlt_frame frame_b;
188         GlslManager::get_effect_secondary_input( service, frame, &input_b, &frame_b );
189         dispose_movit_effects( input_a, frame );
190
191         if ( input_b ) {
192                 dispose_movit_effects( input_b, frame_b );
193         }
194 }
195
196 static void finalize_movit_chain( mlt_service leaf_service, mlt_frame frame )
197 {
198         GlslChain* chain = GlslManager::get_chain( leaf_service );
199
200         std::string new_fingerprint;
201         build_fingerprint( leaf_service, frame, &new_fingerprint );
202
203         // Build the chain if needed.
204         if ( !chain || new_fingerprint != chain->fingerprint ) {
205                 mlt_log_debug( leaf_service, "=== CREATING NEW CHAIN (old chain=%p, leaf=%p, fingerprint=%s) ===\n", chain, leaf_service, new_fingerprint.c_str() );
206                 mlt_profile profile = mlt_service_profile( leaf_service );
207                 chain = new GlslChain;
208                 chain->effect_chain = new EffectChain( profile->display_aspect_num, profile->display_aspect_den );
209                 chain->fingerprint = new_fingerprint;
210
211                 build_movit_chain( leaf_service, frame, chain );
212                 chain->effect_chain->add_effect( new Mlt::VerticalFlip );
213
214                 ImageFormat output_format;
215                 output_format.color_space = COLORSPACE_sRGB;
216                 output_format.gamma_curve = GAMMA_sRGB;
217                 chain->effect_chain->add_output(output_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED);
218                 chain->effect_chain->set_dither_bits(8);
219                 chain->effect_chain->finalize();
220
221                 GlslManager::set_chain( leaf_service, chain );
222         } else {
223                 // Delete all the created Effect instances to avoid memory leaks.
224                 dispose_movit_effects( leaf_service, frame );
225         }
226 }
227
228 static void set_movit_parameters( GlslChain *chain, mlt_service service, mlt_frame frame )
229 {
230         if ( service == (mlt_service) -1 ) {
231                 mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
232                 MltInput* input = (MltInput *) chain->effects[ MLT_PRODUCER_SERVICE( producer ) ];
233                 input->set_pixel_data( GlslManager::get_input_pixel_pointer( producer, frame ) );
234                 return;
235         }
236
237         Effect* effect = chain->effects[ service ];
238         mlt_service input_a = GlslManager::get_effect_input( service, frame );
239         set_movit_parameters( chain, input_a, frame );
240
241         mlt_service input_b;
242         mlt_frame frame_b;
243         GlslManager::get_effect_secondary_input( service, frame, &input_b, &frame_b );
244         if ( input_b ) {
245                 set_movit_parameters( chain, input_b, frame_b );
246         }
247                 
248         mlt_properties properties = MLT_SERVICE_PROPERTIES( service );
249         int count = mlt_properties_count( properties );
250         for (int i = 0; i < count; ++i) {
251                 const char *name = mlt_properties_get_name( properties, i );
252                 if (strncmp(name, "movit.parms.float.", strlen("movit.parms.float.")) == 0) {
253                         bool ok = effect->set_float(name + strlen("movit.parms.float."),
254                                 mlt_properties_get_double( properties, name ));
255                         assert(ok);
256                 }
257                 if (strncmp(name, "movit.parms.int.", strlen("movit.parms.int.")) == 0) {
258                         bool ok = effect->set_int(name + strlen("movit.parms.int."),
259                                 mlt_properties_get_int( properties, name ));
260                         assert(ok);
261                 }
262                 if (strncmp(name, "movit.parms.vec3.", strlen("movit.parms.vec3.")) == 0 &&
263                     strcmp(name + strlen(name) - 3, "[0]") == 0) {
264                         float val[3];
265                         char *name_copy = strdup(name);
266                         char *index_char = name_copy + strlen(name_copy) - 2;
267                         val[0] = mlt_properties_get_double( properties, name_copy );
268                         *index_char = '1';
269                         val[1] = mlt_properties_get_double( properties, name_copy );
270                         *index_char = '2';
271                         val[2] = mlt_properties_get_double( properties, name_copy );
272                         index_char[-1] = '\0';
273                         bool ok = effect->set_vec3(name_copy + strlen("movit.parms.vec3."), val);
274                         assert(ok);
275                         free(name_copy);
276                 }
277                 if (strncmp(name, "movit.parms.vec4.", strlen("movit.parms.vec4.")) == 0 &&
278                     strcmp(name + strlen(name) - 3, "[0]") == 0) {
279                         float val[4];
280                         char *name_copy = strdup(name);
281                         char *index_char = name_copy + strlen(name_copy) - 2;
282                         val[0] = mlt_properties_get_double( properties, name_copy );
283                         *index_char = '1';
284                         val[1] = mlt_properties_get_double( properties, name_copy );
285                         *index_char = '2';
286                         val[2] = mlt_properties_get_double( properties, name_copy );
287                         *index_char = '3';
288                         val[3] = mlt_properties_get_double( properties, name_copy );
289                         index_char[-1] = '\0';
290                         bool ok = effect->set_vec4(name_copy + strlen("movit.parms.vec4."), val);
291                         assert(ok);
292                         free(name_copy);
293                 }
294         }
295 }
296
297 static void dispose_pixel_pointers( mlt_service service, mlt_frame frame )
298 {
299         if ( service == (mlt_service) -1 ) {
300                 mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
301                 mlt_pool_release( GlslManager::get_input_pixel_pointer( producer, frame ) );
302                 return;
303         }
304
305         mlt_service input_a = GlslManager::get_effect_input( service, frame );
306         dispose_pixel_pointers( input_a, frame );
307
308         mlt_service input_b;
309         mlt_frame frame_b;
310         GlslManager::get_effect_secondary_input( service, frame, &input_b, &frame_b );
311         if ( input_b ) {
312                 dispose_pixel_pointers( input_b, frame_b );
313         }
314 }
315
316 static int movit_render( EffectChain *chain, mlt_frame frame, mlt_image_format *format, mlt_image_format output_format, int width, int height, uint8_t **image )
317 {
318         GlslManager* glsl = GlslManager::get_instance();
319         int error;
320         if ( output_format == mlt_image_glsl_texture ) {
321                 error = glsl->render_frame_texture( chain, frame, width, height, image );
322         }
323         else {
324                 error = glsl->render_frame_rgba( chain, frame, width, height, image );
325                 if ( !error && output_format != mlt_image_rgb24a ) {
326                         *format = mlt_image_rgb24a;
327                         error = convert_on_cpu( frame, image, format, output_format );
328                 }
329         }
330         return error;
331 }
332
333 // Create an MltInput for an image with the given format and dimensions.
334 static MltInput* create_input( mlt_properties properties, mlt_image_format format, int aspect_width, int aspect_height, int width, int height )
335 {
336         MltInput* input = new MltInput( aspect_width, aspect_height );
337         if ( format == mlt_image_rgb24a || format == mlt_image_opengl ) {
338                 // TODO: Get the color space if available.
339                 input->useFlatInput( FORMAT_RGBA_POSTMULTIPLIED_ALPHA, width, height );
340         }
341         else if ( format == mlt_image_rgb24 ) {
342                 // TODO: Get the color space if available.
343                 input->useFlatInput( FORMAT_RGB, width, height );
344         }
345         else if ( format == mlt_image_yuv420p ) {
346                 ImageFormat image_format;
347                 YCbCrFormat ycbcr_format;
348                 get_format_from_properties( properties, &image_format, &ycbcr_format );
349                 ycbcr_format.chroma_subsampling_x = ycbcr_format.chroma_subsampling_y = 2;
350                 input->useYCbCrInput( image_format, ycbcr_format, width, height );
351         }
352         else if ( format == mlt_image_yuv422 ) {
353                 ImageFormat image_format;
354                 YCbCrFormat ycbcr_format;
355                 get_format_from_properties( properties, &image_format, &ycbcr_format );
356                 ycbcr_format.chroma_subsampling_x = 2;
357                 ycbcr_format.chroma_subsampling_y = 1;
358                 input->useYCbCrInput( image_format, ycbcr_format, width, height );
359         }
360         return input;
361 }
362
363 // Make a copy of the given image (allocated using mlt_pool_alloc) suitable
364 // to pass as pixel pointer to an MltInput (created using create_input
365 // with the same parameters), and return that pointer.
366 static uint8_t* make_input_copy( mlt_image_format format, uint8_t *image, int width, int height )
367 {
368         int img_size = mlt_image_format_size( format, width, height, NULL );
369         uint8_t* img_copy = (uint8_t*) mlt_pool_alloc( img_size );
370         if ( format == mlt_image_yuv422 ) {
371                 yuv422_to_yuv422p( image, img_copy, width, height );
372         } else {
373                 memcpy( img_copy, image, img_size );
374         }
375         return img_copy;
376 }
377
378 static int convert_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, mlt_image_format output_format )
379 {
380         // Nothing to do!
381         if ( *format == output_format )
382                 return 0;
383
384         mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
385
386         mlt_log_debug( NULL, "filter_movit_convert: %s -> %s (%d)\n",
387                 mlt_image_format_name( *format ), mlt_image_format_name( output_format ),
388                 mlt_frame_get_position( frame ) );
389
390         // Use CPU if glsl not initialized or not supported.
391         GlslManager* glsl = GlslManager::get_instance();
392         if ( !glsl || !glsl->get_int("glsl_supported" ) )
393                 return convert_on_cpu( frame, image, format, output_format );
394
395         // Do non-GL image conversions on a CPU-based image converter.
396         if ( *format != mlt_image_glsl && output_format != mlt_image_glsl && output_format != mlt_image_glsl_texture )
397                 return convert_on_cpu( frame, image, format, output_format );
398
399         int error = 0;
400         int width = mlt_properties_get_int( properties, "width" );
401         int height = mlt_properties_get_int( properties, "height" );
402         GlslManager::get_instance()->lock_service( frame );
403         
404         // If we're at the beginning of a series of Movit effects, store the input
405         // sent into the chain.
406         if ( output_format == mlt_image_glsl ) {
407                 mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
408                 mlt_profile profile = mlt_service_profile( MLT_PRODUCER_SERVICE( producer ) );
409                 MltInput *input = create_input( properties, *format, profile->width, profile->height, width, height );
410                 GlslManager::set_input( producer, frame, input );
411                 uint8_t *img_copy = make_input_copy( *format, *image, width, height );
412                 GlslManager::set_input_pixel_pointer( producer, frame, img_copy );
413
414                 *image = (uint8_t *) -1;
415                 mlt_frame_set_image( frame, *image, 0, NULL );
416         }
417
418         // If we're at the _end_ of a series of Movit effects, render the chain.
419         if ( *format == mlt_image_glsl ) {
420                 mlt_service leaf_service = (mlt_service) *image;
421
422                 // Construct the chain unless we already have a good one.
423                 finalize_movit_chain( leaf_service, frame );
424
425                 // Set per-frame parameters now that we know which Effect instances to set them on.
426                 GlslChain *chain = GlslManager::get_chain( leaf_service );
427                 set_movit_parameters( chain, leaf_service, frame );
428
429                 error = movit_render( chain->effect_chain, frame, format, output_format, width, height, image );
430
431                 dispose_pixel_pointers( leaf_service, frame );
432         }
433
434         // If we've been asked to render some frame directly to a texture (without any
435         // effects in-between), we create a new mini-chain to do so.
436         if ( *format != mlt_image_glsl && output_format == mlt_image_glsl_texture ) {
437                 // We might already have a texture from a previous conversion from mlt_image_glsl.
438                 glsl_texture texture = (glsl_texture) mlt_properties_get_data( properties, "movit.convert.texture", NULL );
439                 // XXX: requires a special property set on the frame by the app for now
440                 // because we do not have reliable way to clear the texture property
441                 // when a downstream filter has changed image.
442                 if ( texture && mlt_properties_get_int( properties, "movit.convert.use_texture") ) {
443                         *image = (uint8_t*) &texture->texture;
444                         mlt_frame_set_image( frame, *image, 0, NULL );
445                 } else {
446                         // Use a separate chain to convert image in RAM to OpenGL texture.
447                         // Use cached chain if available and compatible.
448                         Mlt::Producer producer( mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) ) );
449                         EffectChain *chain = (EffectChain*) producer.get_data( "movit.convert.chain" );
450                         MltInput *input = (MltInput*) producer.get_data( "movit.convert.input" );
451                         int w = producer.get_int( "movit.convert.width" );
452                         int h = producer.get_int( "movit.convert.height" );
453                         mlt_image_format f = (mlt_image_format) producer.get_int( "movit.convert.format" );
454                         if ( !chain || !input || width != w || height != h || *format != f ) {
455                                 chain = new EffectChain( width, height );
456                                 input = create_input( properties, *format, width, height, width, height );
457                                 chain->add_input( input );
458                                 chain->add_effect( new Mlt::VerticalFlip() );
459                                 ImageFormat movit_output_format;
460                                 movit_output_format.color_space = COLORSPACE_sRGB;
461                                 movit_output_format.gamma_curve = GAMMA_sRGB;
462                                 chain->add_output(movit_output_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED);
463                                 chain->set_dither_bits(8);
464                                 chain->finalize();
465                                 producer.set( "movit.convert.chain", chain, 0, (mlt_destructor) delete_chain );
466                                 producer.set( "movit.convert.input", input, 0, NULL );
467                                 producer.set( "movit.convert.width", width );
468                                 producer.set( "movit.convert.height", height );
469                                 producer.set( "movit.convert.format", *format );
470                         }
471
472                         if ( *format == mlt_image_yuv422 ) {
473                                 // We need to convert to planar, which make_input_copy() will do for us.
474                                 uint8_t *planar = make_input_copy( *format, *image, width, height );
475                                 input->set_pixel_data( planar );
476                                 error = movit_render( chain, frame, format, output_format, width, height, image );
477                                 mlt_pool_release( planar );
478                         } else {
479                                 input->set_pixel_data( *image );
480                                 error = movit_render( chain, frame, format, output_format, width, height, image );
481                         }
482                 }
483         }
484
485         GlslManager::get_instance()->unlock_service( frame );
486
487         mlt_properties_set_int( properties, "format", output_format );
488         *format = output_format;
489
490         return error;
491 }
492
493 static mlt_frame process( mlt_filter filter, mlt_frame frame )
494 {
495         // Set a default colorspace on the frame if not yet set by the producer.
496         // The producer may still change it during get_image.
497         // This way we do not have to modify each producer to set a valid colorspace.
498         mlt_properties properties = MLT_FRAME_PROPERTIES(frame);
499         if ( mlt_properties_get_int( properties, "colorspace" ) <= 0 )
500                 mlt_properties_set_int( properties, "colorspace", mlt_service_profile( MLT_FILTER_SERVICE(filter) )->colorspace );
501
502         frame->convert_image = convert_image;
503
504         mlt_filter cpu_csc = (mlt_filter) mlt_properties_get_data( MLT_FILTER_PROPERTIES( filter ), "cpu_csc", NULL );
505         mlt_properties_inc_ref( MLT_FILTER_PROPERTIES(cpu_csc) );
506         mlt_properties_set_data( properties, "cpu_csc", cpu_csc, 0,
507                 (mlt_destructor) mlt_filter_close, NULL );
508
509         return frame;
510 }
511
512 static mlt_filter create_filter( mlt_profile profile, const char *effect )
513 {
514         mlt_filter filter;
515         char *id = strdup( effect );
516         char *arg = strchr( id, ':' );
517         if ( arg != NULL )
518                 *arg ++ = '\0';
519
520         // The swscale and avcolor_space filters require resolution as arg to test compatibility
521         if ( !strcmp( effect, "avcolor_space" ) )
522                 filter = mlt_factory_filter( profile, id, &profile->width );
523         else
524                 filter = mlt_factory_filter( profile, id, arg );
525         if ( filter )
526                 mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "_loader", 1 );
527         free( id );
528         return filter;
529 }
530
531 extern "C" {
532
533 mlt_filter filter_movit_convert_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
534 {
535         mlt_filter filter = NULL;
536         GlslManager* glsl = GlslManager::get_instance();
537
538         if ( glsl && ( filter = mlt_filter_new() ) )
539         {
540 #ifdef WIN32
541                 // XXX avcolor_space is crashing on Windows in this context!
542                 mlt_filter cpu_csc = NULL;
543 #else
544                 mlt_filter cpu_csc = create_filter( profile, "avcolor_space" );
545 #endif
546                 if ( !cpu_csc )
547                         cpu_csc = create_filter( profile, "imageconvert" );
548                 if ( cpu_csc )
549                         mlt_properties_set_data( MLT_FILTER_PROPERTIES( filter ), "cpu_csc", cpu_csc, 0,
550                                 (mlt_destructor) mlt_filter_close, NULL );
551                 filter->process = process;
552         }
553         return filter;
554 }
555
556 }