2 * transition_frei0r.c -- frei0r transition
3 * Copyright (c) 2008 Marco Gittler <g.marco@freenet.de>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <framework/mlt.h>
21 #include "frei0r_helper.h"
24 static int transition_get_image( mlt_frame a_frame
, uint8_t **image
, mlt_image_format
*format
, int *width
, int *height
, int writable
){
26 if (*format
!=mlt_image_yuv422
){
30 mlt_frame b_frame
= mlt_frame_pop_frame( a_frame
);
31 mlt_transition transition
= mlt_frame_pop_service( a_frame
);
32 mlt_properties properties
= MLT_TRANSITION_PROPERTIES( transition
);
33 mlt_properties a_props
= MLT_FRAME_PROPERTIES( a_frame
);
34 mlt_properties b_props
= MLT_FRAME_PROPERTIES( b_frame
);
36 int invert
= mlt_properties_get_int( properties
, "invert" );
38 if ( mlt_properties_get( a_props
, "rescale.interp" ) == NULL
|| !strcmp( mlt_properties_get( a_props
, "rescale.interp" ), "none" ) )
39 mlt_properties_set( a_props
, "rescale.interp", "nearest" );
41 // set consumer_aspect_ratio for a and b frame
42 if ( mlt_properties_get_double( a_props
, "aspect_ratio" ) == 0.0 )
43 mlt_properties_set_double( a_props
, "aspect_ratio", mlt_properties_get_double( a_props
, "consumer_aspect_ratio" ) );
44 if ( mlt_properties_get_double( b_props
, "aspect_ratio" ) == 0.0 )
45 mlt_properties_set_double( b_props
, "aspect_ratio", mlt_properties_get_double( a_props
, "consumer_aspect_ratio" ) );
46 mlt_properties_set_double( b_props
, "consumer_aspect_ratio", mlt_properties_get_double( a_props
, "consumer_aspect_ratio" ) );
48 if ( mlt_properties_get( b_props
, "rescale.interp" ) == NULL
|| !strcmp( mlt_properties_get( b_props
, "rescale.interp" ), "none" ) )
49 mlt_properties_set( b_props
, "rescale.interp", "nearest" );
51 uint8_t *images
[]={NULL
,NULL
,NULL
};
53 mlt_frame_get_image( a_frame
, &images
[0], format
, width
, height
, 1 );
54 mlt_frame_get_image( b_frame
, &images
[1], format
, width
, height
, 1 );
56 mlt_position in
= mlt_transition_get_in( transition
);
57 mlt_position out
= mlt_transition_get_out( transition
);
59 // Get the position of the frame
60 char *name
= mlt_properties_get( MLT_TRANSITION_PROPERTIES( transition
), "_unique_id" );
61 mlt_position position
= mlt_properties_get_position( MLT_FRAME_PROPERTIES( a_frame
), name
);
63 float pos
=( float )( position
- in
) / ( float )( out
- in
+ 1 );
65 process_frei0r_item( transition_type
, pos
, properties
, !invert ? a_frame
: b_frame
, images
, format
, width
,height
, writable
);
67 *width
= mlt_properties_get_int( !invert ? a_props
: b_props
, "width" );
68 *height
= mlt_properties_get_int( !invert ? a_props
: b_props
, "height" );
69 *image
= mlt_properties_get_data( !invert ? a_props
: b_props
, "image", NULL
);
73 mlt_frame
transition_process( mlt_transition transition
, mlt_frame a_frame
, mlt_frame b_frame
)
75 char *name
= mlt_properties_get( MLT_TRANSITION_PROPERTIES( transition
), "_unique_id" );
76 mlt_properties_set_position( MLT_FRAME_PROPERTIES( a_frame
), name
, mlt_frame_get_position( a_frame
) );
77 mlt_frame_push_service( a_frame
, transition
);
78 mlt_frame_push_frame( a_frame
, b_frame
);
79 mlt_frame_push_get_image( a_frame
, transition_get_image
);
83 void transition_close( mlt_transition
this ){
84 destruct ( MLT_TRANSITION_PROPERTIES ( this ) );