2 * transition_movit_overlay.cpp
3 * Copyright (C) 2013 Dan Dennedy <dan@dennedy.org>
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.
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.
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.
21 #include <framework/mlt.h>
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>
31 static int get_image( mlt_frame a_frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
35 // Get the b frame from the stack
36 mlt_frame b_frame = (mlt_frame) mlt_frame_pop_frame( a_frame );
38 // Get the transition object
39 mlt_transition transition = (mlt_transition) mlt_frame_pop_service( a_frame );
40 mlt_service service = MLT_TRANSITION_SERVICE( transition );
41 mlt_service_lock( service );
43 uint8_t *a_image, *b_image;
45 // Get the two images.
46 *format = mlt_image_glsl;
47 error = mlt_frame_get_image( a_frame, &a_image, format, width, height, writable );
48 error = mlt_frame_get_image( b_frame, &b_image, format, width, height, writable );
50 GlslManager::set_effect_input( service, a_frame, (mlt_service) a_image );
51 GlslManager::set_effect_secondary_input( service, a_frame, (mlt_service) b_image, b_frame );
52 GlslManager::set_effect( service, a_frame, new OverlayEffect );
53 *image = (uint8_t *) service;
55 mlt_service_unlock( service );
59 static mlt_frame process( mlt_transition transition, mlt_frame a_frame, mlt_frame b_frame )
61 mlt_frame_push_service( a_frame, transition );
62 mlt_frame_push_frame( a_frame, b_frame );
63 mlt_frame_push_get_image( a_frame, get_image );
69 mlt_transition transition_movit_overlay_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
71 mlt_transition transition = NULL;
72 GlslManager* glsl = GlslManager::get_instance();
73 if ( glsl && ( transition = mlt_transition_new() ) ) {
74 transition->process = process;
76 // Inform apps and framework that this is a video only transition
77 mlt_properties_set_int( MLT_TRANSITION_PROPERTIES( transition ), "_transition_type", 1 );