* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "config.h"
#include "mlt_frame.h"
#include "mlt_producer.h"
#include "mlt_factory.h"
+#include "mlt_profile.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/** Constructor for a frame.
*/
-mlt_frame mlt_frame_init( )
+mlt_frame mlt_frame_init( mlt_service service )
{
// Allocate a frame
mlt_frame this = calloc( sizeof( struct mlt_frame_s ), 1 );
if ( this != NULL )
{
- // Get the normalisation
- char *normalisation = mlt_environment( "MLT_NORMALISATION" );
+ mlt_profile profile = mlt_service_profile( service );
// Initialise the properties
mlt_properties properties = &this->parent;
// Set default properties on the frame
mlt_properties_set_position( properties, "_position", 0.0 );
mlt_properties_set_data( properties, "image", NULL, 0, NULL, NULL );
-
- if ( normalisation == NULL || strcmp( normalisation, "NTSC" ) )
- {
- mlt_properties_set_int( properties, "width", 720 );
- mlt_properties_set_int( properties, "height", 576 );
- mlt_properties_set_int( properties, "normalised_width", 720 );
- mlt_properties_set_int( properties, "normalised_height", 576 );
- mlt_properties_set_double( properties, "aspect_ratio", 59.0/54.0 );
- }
- else
- {
- mlt_properties_set_int( properties, "width", 720 );
- mlt_properties_set_int( properties, "height", 480 );
- mlt_properties_set_int( properties, "normalised_width", 720 );
- mlt_properties_set_int( properties, "normalised_height", 480 );
- mlt_properties_set_double( properties, "aspect_ratio", 10.0/11.0 );
- }
-
+ mlt_properties_set_int( properties, "width", profile? profile->width : 720 );
+ mlt_properties_set_int( properties, "height", profile? profile->height : 576 );
+ mlt_properties_set_int( properties, "normalised_width", profile? profile->width : 720 );
+ mlt_properties_set_int( properties, "normalised_height", profile? profile->height : 576 );
+ mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( NULL ) );
mlt_properties_set_data( properties, "audio", NULL, 0, NULL, NULL );
mlt_properties_set_data( properties, "alpha", NULL, 0, NULL, NULL );
mlt_audio_format format = mlt_audio_pcm;
int frequency = 32000; // lower frequency available?
int channels = 2;
- double fps = mlt_properties_get_double( properties, "fps" );
+ double fps = mlt_profile_fps( NULL );
int samples = mlt_sample_calculator( fps, frequency, mlt_frame_get_position( this ) );
// Get the pcm data
register uint8_t *d = yuv;
register int i, j;
+ if ( alpha )
for ( i = 0; i < height; i++ )
{
register uint8_t *s = rgba + ( stride * i );
*d++ = u0;
}
}
+ else
+ for ( i = 0; i < height; i++ )
+ {
+ register uint8_t *s = rgba + ( stride * i );
+ for ( j = 0; j < ( width / 2 ); j++ )
+ {
+ r = *s++;
+ g = *s++;
+ b = *s++;
+ s++;
+ RGB2YUV (r, g, b, y0, u0 , v0);
+ r = *s++;
+ g = *s++;
+ b = *s++;
+ s++;
+ RGB2YUV (r, g, b, y1, u1 , v1);
+ *d++ = y0;
+ *d++ = (u0+u1) >> 1;
+ *d++ = y1;
+ *d++ = (v0+v1) >> 1;
+ }
+ if ( width % 2 )
+ {
+ r = *s++;
+ g = *s++;
+ b = *s++;
+ s++;
+ RGB2YUV (r, g, b, y0, u0 , v0);
+ *d++ = y0;
+ *d++ = u0;
+ }
+ }
+
return ret;
}
register uint8_t *d = yuv;
register int i, j;
+ if ( alpha )
for ( i = 0; i < height; i++ )
{
register uint8_t *s = rgba + ( stride * i );
*d++ = u0;
}
}
+ else
+ for ( i = 0; i < height; i++ )
+ {
+ register uint8_t *s = rgba + ( stride * i );
+ for ( j = 0; j < ( width / 2 ); j++ )
+ {
+ b = *s++;
+ g = *s++;
+ r = *s++;
+ s++;
+ RGB2YUV (r, g, b, y0, u0 , v0);
+ b = *s++;
+ g = *s++;
+ r = *s++;
+ s++;
+ RGB2YUV (r, g, b, y1, u1 , v1);
+ *d++ = y0;
+ *d++ = (u0+u1) >> 1;
+ *d++ = y1;
+ *d++ = (v0+v1) >> 1;
+ }
+ if ( width % 2 )
+ {
+ b = *s++;
+ g = *s++;
+ r = *s++;
+ s++;
+ RGB2YUV (r, g, b, y0, u0 , v0);
+ *d++ = y0;
+ *d++ = u0;
+ }
+ }
return ret;
}
register uint8_t *d = yuv;
register int i, j;
+ if ( alpha )
for ( i = 0; i < height; i++ )
{
register uint8_t *s = rgba + ( stride * i );
*d++ = u0;
}
}
+ else
+ for ( i = 0; i < height; i++ )
+ {
+ register uint8_t *s = rgba + ( stride * i );
+ for ( j = 0; j < ( width / 2 ); j++ )
+ {
+ s++;
+ r = *s++;
+ g = *s++;
+ b = *s++;
+ RGB2YUV (r, g, b, y0, u0 , v0);
+ s++;
+ r = *s++;
+ g = *s++;
+ b = *s++;
+ RGB2YUV (r, g, b, y1, u1 , v1);
+ *d++ = y0;
+ *d++ = (u0+u1) >> 1;
+ *d++ = y1;
+ *d++ = (v0+v1) >> 1;
+ }
+ if ( width % 2 )
+ {
+ s++;
+ r = *s++;
+ g = *s++;
+ b = *s++;
+ RGB2YUV (r, g, b, y0, u0 , v0);
+ *d++ = y0;
+ *d++ = u0;
+ }
+ }
return ret;
}