]> git.sesse.net Git - mlt/blob - src/modules/opengl/filter_lift_gamma_gain.cpp
Add the new opengl module (opengl branch).
[mlt] / src / modules / opengl / filter_lift_gamma_gain.cpp
1 /*
2  * filter_lift_gamma_gain.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 <assert.h>
23
24 #include "glsl_manager.h"
25 #include <movit/lift_gamma_gain_effect.h>
26
27 static mlt_frame process( mlt_filter filter, mlt_frame frame )
28 {
29         if ( !mlt_frame_is_test_card( frame ) ) {
30                 Effect* effect = GlslManager::get_effect( filter, frame );
31                 if ( !effect )
32                         effect = GlslManager::add_effect( filter, frame, new LiftGammaGainEffect );
33                 if ( effect ) {
34                         mlt_properties filter_props = MLT_FILTER_PROPERTIES( filter );
35                         RGBTriplet triplet(
36                                 mlt_properties_get_double( filter_props, "lift_r" ),
37                                 mlt_properties_get_double( filter_props, "lift_g" ),
38                                 mlt_properties_get_double( filter_props, "lift_b" )
39                         );
40                         bool ok = effect->set_vec3( "lift", (float*) &triplet );
41                         triplet.r = mlt_properties_get_double( filter_props, "gamma_r" );
42                         triplet.g = mlt_properties_get_double( filter_props, "gamma_g" );
43                         triplet.b = mlt_properties_get_double( filter_props, "gamma_b" );
44                         ok |= effect->set_vec3( "gamma", (float*) &triplet );
45                         triplet.r = mlt_properties_get_double( filter_props, "gain_r" );
46                         triplet.g = mlt_properties_get_double( filter_props, "gain_g" );
47                         triplet.b = mlt_properties_get_double( filter_props, "gain_b" );
48                         ok |= effect->set_vec3( "gain", (float*) &triplet );
49                         assert(ok);
50                 }
51         }
52         return frame;
53 }
54
55 extern "C" {
56
57 mlt_filter filter_lift_gamma_gain_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
58 {
59         mlt_filter filter = NULL;
60         GlslManager* glsl = GlslManager::get_instance();
61
62         if ( glsl && ( filter = mlt_filter_new() ) ) {
63                 mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
64                 mlt_properties_set_double( properties, "lift_r", 0.0 );
65                 mlt_properties_set_double( properties, "lift_g", 0.0 );
66                 mlt_properties_set_double( properties, "lift_b", 0.0 );
67                 mlt_properties_set_double( properties, "gamma_r", 1.0 );
68                 mlt_properties_set_double( properties, "gamma_g", 1.0 );
69                 mlt_properties_set_double( properties, "gamma_b", 1.0 );
70                 mlt_properties_set_double( properties, "gain_r", 1.0 );
71                 mlt_properties_set_double( properties, "gain_g", 1.0 );
72                 mlt_properties_set_double( properties, "gain_b", 1.0 );
73                 filter->process = process;
74         }
75         return filter;
76 }
77
78 }