2 * producer_frei0r.c -- frei0r producer
3 * Copyright (c) 2009 Jean-Baptiste Mardelle <jb@kdenlive.org>
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>
22 #include "frei0r_helper.h"
27 static int producer_get_image( mlt_frame frame
, uint8_t **buffer
, mlt_image_format
*format
, int *width
, int *height
, int writable
)
30 // Obtain properties of frame
31 mlt_properties properties
= MLT_FRAME_PROPERTIES( frame
);
33 // Obtain the producer for this frame
34 mlt_producer producer
= mlt_properties_get_data( properties
, "producer_frei0r", NULL
);
36 // Obtain properties of producer
37 mlt_properties producer_props
= MLT_PRODUCER_PROPERTIES( producer
);
40 int size
= *width
* ( *height
+ 1 ) * 2;
43 *buffer
= mlt_pool_alloc( size
);
46 mlt_properties_set_data( properties
, "image", *buffer
, size
, mlt_pool_release
, NULL
);
47 mlt_properties_set_int( properties
, "width", *width
);
48 mlt_properties_set_int( properties
, "height", *height
);
50 *format
= mlt_image_yuv422
;
51 if ( *buffer
!= NULL
)
53 mlt_position in
= mlt_producer_get_in( producer
);
54 mlt_position out
= mlt_producer_get_out( producer
);
55 mlt_position time
= mlt_frame_get_position( frame
);
56 double position
= ( double )( time
- in
) / ( double )( out
- in
+ 1 );
57 process_frei0r_item( producer_type
, position
, producer_props
, frame
, buffer
, format
, width
, height
, writable
);
63 int producer_get_frame( mlt_producer producer
, mlt_frame_ptr frame
, int index
)
66 *frame
= mlt_frame_init( MLT_PRODUCER_SERVICE( producer
) );
70 // Obtain properties of frame and producer
71 mlt_properties properties
= MLT_FRAME_PROPERTIES( *frame
);
73 // Obtain properties of producer
74 mlt_properties producer_props
= MLT_PRODUCER_PROPERTIES( producer
);
76 // Set the producer on the frame properties
77 mlt_properties_set_data( properties
, "producer_frei0r", producer
, 0, NULL
, NULL
);
79 // Update timecode on the frame we're creating
80 mlt_frame_set_position( *frame
, mlt_producer_position( producer
) );
82 // Set producer-specific frame properties
83 mlt_properties_set_int( properties
, "progressive", 1 );
84 mlt_properties_set_double( properties
, "aspect_ratio", mlt_properties_get_double( producer_props
, "aspect_ratio" ) );
86 // Push the get_image method
87 mlt_frame_push_get_image( *frame
, producer_get_image
);
90 // Calculate the next timecode
91 mlt_producer_prepare_next( producer
);
96 void producer_close( mlt_producer producer
)
98 producer
->close
= NULL
;
99 mlt_producer_close( producer
);