transition region
[melted] / src / modules / core / filter_region.c
1 /*
2 * filter_region.c -- region filter
3 * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4 * Author: Charles Yates <charles.yates@pandora.be>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 #include "filter_region.h"
22 #include "transition_region.h"
23
24 #include <framework/mlt.h>
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29
30 /** Filter processing.
31 */
32
33 static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
34 {
35 // Get the properties of the filter
36 mlt_properties properties = mlt_filter_properties( this );
37
38 // Get the region transition
39 mlt_transition transition = mlt_properties_get_data( properties, "_transition", NULL );
40
41 // Create the transition if not available
42 if ( transition == NULL )
43 {
44 // Create the transition
45 transition = mlt_factory_transition( "region", NULL );
46
47 // Pass all properties down
48 mlt_properties_pass( mlt_transition_properties( transition ), properties, "" );
49
50 // Register with the filter
51 mlt_properties_set_data( properties, "_transition", transition, 0, ( mlt_destructor )mlt_transition_close, NULL );
52 }
53
54 // Process the frame
55 return mlt_transition_process( transition, frame, NULL );
56 }
57
58 /** Constructor for the filter.
59 */
60
61 mlt_filter filter_region_init( void *arg )
62 {
63 // Create a new filter
64 mlt_filter this = mlt_filter_new( );
65
66 // Further initialisation
67 if ( this != NULL )
68 {
69 // Get the properties from the filter
70 mlt_properties properties = mlt_filter_properties( this );
71
72 // Assign the filter process method
73 this->process = filter_process;
74
75 // Resource defines the shape of the region
76 mlt_properties_set( properties, "resource", arg == NULL ? "rectangle" : arg );
77 }
78
79 // Return the filter
80 return this;
81 }
82