Cleanup license declarations and remove dv1394d references.
[melted] / src / modules / core / producer_colour.c
index 75e7aa9..7eeaac7 100644 (file)
@@ -3,19 +3,19 @@
  * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
  * Author: Dan Dennedy <dan@dennedy.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "producer_colour.h"
@@ -50,6 +50,7 @@ mlt_producer producer_colour_init( char *colour )
                // Set the default properties
                mlt_properties_set( properties, "resource", colour == NULL ? "0x000000ff" : colour );
                mlt_properties_set( properties, "_resource", "" );
+               mlt_properties_set_double( properties, "aspect_ratio", 0 );
                
                return producer;
        }
@@ -135,7 +136,11 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        {
                // Color the image
                uint8_t y, u, v;
-               int i = 0;
+               int i = *height;
+               int j = 0;
+               int uneven = *width % 2;
+               int count = ( *width - uneven ) / 2;
+               uint8_t *p = NULL;
 
                // Allocate the image
                size = *width * *height * 2;
@@ -149,12 +154,23 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 
                RGB2YUV( color.r, color.g, color.b, y, u, v );
 
-               while ( i < size )
+               p = image;
+
+               while ( i -- )
                {
-                       image[ i ++ ] = y;
-                       image[ i ++ ] = u;
-                       image[ i ++ ] = y;
-                       image[ i ++ ] = v;
+                       j = count;
+                       while ( j -- )
+                       {
+                               *p ++ = y;
+                               *p ++ = u;
+                               *p ++ = y;
+                               *p ++ = v;
+                       }
+                       if ( uneven )
+                       {
+                               *p ++ = y;
+                               *p ++ = u;
+                       }
                }
        }
 
@@ -182,6 +198,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                // Now update properties so we free the copy after
                mlt_properties_set_data( properties, "image", copy, size, mlt_pool_release, NULL );
                mlt_properties_set_data( properties, "alpha", alpha, size >> 1, mlt_pool_release, NULL );
+               mlt_properties_set_double( properties, "aspect_ratio", mlt_properties_get_double( producer_props, "aspect_ratio" ) );
        }
 
        // Pass on the image
@@ -212,7 +229,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i
 
                // Set producer-specific frame properties
                mlt_properties_set_int( properties, "progressive", 1 );
-               mlt_properties_set_double( properties, "aspect_ratio", 0 );
+               mlt_properties_set_double( properties, "aspect_ratio", mlt_properties_get_double( producer_props, "aspect_ratio" ) );
 
                // colour is an alias for resource
                if ( mlt_properties_get( producer_props, "colour" ) != NULL )