Cleanup license declarations and remove dv1394d references.
[melted] / src / modules / lumas / luma.c
index 76f927a..0889612 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * luma.c -- image generator for transition_luma
+ * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Author: Charles Yates <charles.yates@pandora.be>
+ *
+ * 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 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
+ * Lesser General Public License for more details.
+ *
+ * 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 <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -20,11 +40,13 @@ typedef struct
        int pflip;
        int pflop;
        int quart;
+       int rotate;
 }
 luma;
 
 void luma_init( luma *this )
 {
+       memset( this, 0, sizeof( luma ) );
        this->type = 0;
        this->w = 720;
        this->h = 576;
@@ -79,6 +101,13 @@ uint16_t *luma_render( luma *this )
                this->h *= 2;
        }
 
+       if ( this->rotate )
+       {
+               int t = this->w;
+               this->w = this->h;
+               this->h = t;
+       }
+
        int max = ( 1 << 16 ) - 1;
        uint16_t *image = malloc( this->w * this->h * sizeof( uint16_t ) );
        uint16_t *end = image + this->w * this->h;
@@ -298,6 +327,26 @@ uint16_t *luma_render( luma *this )
                }
        }
 
+       if ( this->rotate )
+       {
+               uint16_t *image2 = malloc( this->w * this->h * sizeof( uint16_t ) );
+               for ( i = 0; i < this->h; i ++ )
+               {
+                       p = image + i * this->w;
+                       r = image2 + this->h - i - 1;
+                       for ( j = 0; j < this->w; j ++ )
+                       {
+                               *r = *( p ++ );
+                               r += this->h;
+                       }
+               }
+               i = this->w;
+               this->w = this->h;
+               this->h = i;
+               free( image );
+               image = image2;
+       }
+
        return image;
 }
 
@@ -345,6 +394,8 @@ int main( int argc, char **argv )
                        this.pflop = atoi( argv[ ++ arg ] );
                else if ( !strcmp( argv[ arg ], "-quart" ) )
                        this.quart = atoi( argv[ ++ arg ] );
+               else if ( !strcmp( argv[ arg ], "-rotate" ) )
+                       this.rotate = atoi( argv[ ++ arg ] );
                else
                        fprintf( stderr, "ignoring %s\n", argv[ arg ] );
        }