]> git.sesse.net Git - mlt/blob - src/modules/opengl/transition_movit_overlay.cpp
Adjust for Movit moving into namespace movit.
[mlt] / src / modules / opengl / transition_movit_overlay.cpp
1 /*
2  * transition_movit_overlay.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
21 #include <framework/mlt.h>
22 #include <string.h>
23 #include <assert.h>
24
25 #include "filter_glsl_manager.h"
26 #include <movit/init.h>
27 #include <movit/effect_chain.h>
28 #include <movit/util.h>
29 #include <movit/overlay_effect.h>
30
31 using namespace movit;
32
33 static int get_image( mlt_frame a_frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
34 {
35         int error;
36
37         // Get the b frame from the stack
38         mlt_frame b_frame = (mlt_frame) mlt_frame_pop_frame( a_frame );
39
40         // Get the transition object
41         mlt_transition transition = (mlt_transition) mlt_frame_pop_service( a_frame );
42         mlt_service service = MLT_TRANSITION_SERVICE( transition );
43         mlt_service_lock( service );
44
45         uint8_t *a_image, *b_image;
46
47         // Get the two images.
48         *format = mlt_image_glsl;
49         error = mlt_frame_get_image( a_frame, &a_image, format, width, height, writable );
50         error = mlt_frame_get_image( b_frame, &b_image, format, width, height, writable );
51
52         GlslManager::set_effect_input( service, a_frame, (mlt_service) a_image );
53         GlslManager::set_effect_secondary_input( service, a_frame, (mlt_service) b_image, b_frame );
54         GlslManager::set_effect( service, a_frame, new OverlayEffect );
55         *image = (uint8_t *) service;
56
57         mlt_service_unlock( service );
58         return error;
59 }
60
61 static mlt_frame process( mlt_transition transition, mlt_frame a_frame, mlt_frame b_frame )
62 {
63         mlt_frame_push_service( a_frame, transition );
64         mlt_frame_push_frame( a_frame, b_frame );
65         mlt_frame_push_get_image( a_frame, get_image );
66
67         return a_frame;
68 }
69
70 extern "C"
71 mlt_transition transition_movit_overlay_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
72 {
73         mlt_transition transition = NULL;
74         GlslManager* glsl = GlslManager::get_instance();
75         if ( glsl && ( transition = mlt_transition_new() ) ) {
76                 transition->process = process;
77                 
78                 // Inform apps and framework that this is a video only transition
79                 mlt_properties_set_int( MLT_TRANSITION_PROPERTIES( transition ), "_transition_type", 1 );
80         }
81         return transition;
82 }