]> git.sesse.net Git - mlt/blobdiff - src/modules/core/filter_mirror.c
Fix abruptness when using a luma with softness in composite.
[mlt] / src / modules / core / filter_mirror.c
index a9678914f33858b8c6717e120f91422abbe87562..813aeef87b54b72593ae734b40f28fe449418b21 100644 (file)
@@ -3,23 +3,22 @@
  * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
  * Author: Charles Yates <charles.yates@pandora.be>
  *
- * 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 "filter_mirror.h"
-
+#include <framework/mlt_filter.h>
 #include <framework/mlt_frame.h>
 
 #include <stdio.h>
@@ -44,13 +43,14 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        int reverse = mlt_properties_get_int( properties, "reverse" );
 
        // Get the image
+       *format = mlt_image_yuv422;
        int error = mlt_frame_get_image( frame, image, format, width, height, 1 );
 
        // Get the alpha
        uint8_t *alpha = mlt_frame_get_alpha_mask( frame );
 
        // If we have an image of the right colour space
-       if ( error == 0 && *format == mlt_image_yuv422 )
+       if ( error == 0 )
        {
                // We'll KISS here
                int hh = *height / 2;
@@ -62,6 +62,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                        uint8_t *a = NULL;
                        uint8_t *b = NULL;
                        int i;
+                       int uneven_w = ( *width % 2 ) * 2;
                        for ( i = 0; i < *height; i ++ )
                        {
                                p = ( uint8_t * )*image + i * *width * 2;
@@ -73,9 +74,9 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                                        while ( p < q )
                                        {
                                                *p ++ = *( q - 2 );
-                                               *p ++ = *( q - 3 );
+                                               *p ++ = *( q - 3 - uneven_w );
                                                *p ++ = *( q - 4 );
-                                               *p ++ = *( q - 1 );
+                                               *p ++ = *( q - 1 - uneven_w );
                                                q -= 4;
                                                *a ++ = *b --;
                                                *a ++ = *b --;
@@ -86,9 +87,9 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                                        while ( p < q )
                                        {
                                                *( q - 2 ) = *p ++;
-                                               *( q - 3 ) = *p ++;
+                                               *( q - 3 - uneven_w ) = *p ++;
                                                *( q - 4 ) = *p ++;
-                                               *( q - 1 ) = *p ++;
+                                               *( q - 1 - uneven_w ) = *p ++;
                                                q -= 4;
                                                *b -- = *a ++;
                                                *b -- = *a ++;
@@ -139,6 +140,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                        uint8_t *b = NULL;
                        int i;
                        int j;
+                       int uneven_w = ( *width % 2 ) * 2;
                        for ( i = 0; i < *height; i ++ )
                        {
                                p = ( uint8_t * )*image + i * *width * 2;
@@ -151,9 +153,9 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                                        while ( j -- )
                                        {
                                                *p ++ = *( q - 2 );
-                                               *p ++ = *( q - 3 );
+                                               *p ++ = *( q - 3 - uneven_w );
                                                *p ++ = *( q - 4 );
-                                               *p ++ = *( q - 1 );
+                                               *p ++ = *( q - 1 - uneven_w );
                                                q -= 4;
                                                *a ++ = *b --;
                                                *a ++ = *b --;
@@ -164,9 +166,9 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                                        while ( j -- )
                                        {
                                                *( q - 2 ) = *p ++;
-                                               *( q - 3 ) = *p ++;
+                                               *( q - 3 - uneven_w ) = *p ++;
                                                *( q - 4 ) = *p ++;
-                                               *( q - 1 ) = *p ++;
+                                               *( q - 1 - uneven_w ) = *p ++;
                                                q -= 4;
                                                *b -- = *a ++;
                                                *b -- = *a ++;
@@ -183,6 +185,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                        int j;
                        uint8_t *a = NULL;
                        uint8_t *b = NULL;
+                       int uneven_w = ( *width % 2 ) * 2;
                        for ( i = 0; i < *height; i ++ )
                        {
                                p = ( uint8_t * )*image + ( i + 1 ) * *width * 2;
@@ -195,9 +198,9 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                                        while ( j -- )
                                        {
                                                *q ++ = *( p - 2 );
-                                               *q ++ = *( p - 3 );
+                                               *q ++ = *( p - 3 - uneven_w );
                                                *q ++ = *( p - 4 );
-                                               *q ++ = *( p - 1 );
+                                               *q ++ = *( p - 1 - uneven_w );
                                                p -= 4;
                                                *b ++ = *a --;
                                                *b ++ = *a --;
@@ -208,9 +211,9 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                                        while ( j -- )
                                        {
                                                *( p - 2 ) = *q ++;
-                                               *( p - 3 ) = *q ++;
+                                               *( p - 3 - uneven_w ) = *q ++;
                                                *( p - 4 ) = *q ++;
-                                               *( p - 1 ) = *q ++;
+                                               *( p - 1 - uneven_w ) = *q ++;
                                                p -= 4;
                                                *a -- = *b ++;
                                                *a -- = *b ++;
@@ -227,6 +230,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                        uint8_t *a = NULL;
                        uint8_t *b = NULL;
                        uint8_t c;
+                       int uneven_w = ( *width % 2 ) * 2;
                        for ( i = 0; i < *height; i ++ )
                        {
                                p = ( uint8_t * )*image + i * *width * 2;
@@ -236,13 +240,13 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                                while ( p < q )
                                {
                                        t[ 0 ] = p[ 0 ];
-                                       t[ 1 ] = p[ 1 ];
+                                       t[ 1 ] = p[ 1 + uneven_w ];
                                        t[ 2 ] = p[ 2 ];
-                                       t[ 3 ] = p[ 3 ];
+                                       t[ 3 ] = p[ 3 + uneven_w ];
                                        *p ++ = *( q - 2 );
-                                       *p ++ = *( q - 3 );
+                                       *p ++ = *( q - 3 - uneven_w );
                                        *p ++ = *( q - 4 );
-                                       *p ++ = *( q - 1 );
+                                       *p ++ = *( q - 1 - uneven_w );
                                        *( -- q ) = t[ 3 ];
                                        *( -- q ) = t[ 0 ];
                                        *( -- q ) = t[ 1 ];
@@ -308,7 +312,7 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 /** Constructor for the filter.
 */
 
-mlt_filter filter_mirror_init( void *arg )
+mlt_filter filter_mirror_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
 {
        // Construct a new filter
        mlt_filter this = mlt_filter_new( );