]> git.sesse.net Git - vlc/blobdiff - src/video_output/video_yuv.c
. nouveaux plugins - ne fonctionnent pas encore tous
[vlc] / src / video_output / video_yuv.c
index 5f752f2ea6bb78b0cb8f5a0bb163ef990ac99fac..2c3bc260427da5d22119db66316e960844707708 100644 (file)
@@ -1,65 +1,53 @@
-/*******************************************************************************
+/*****************************************************************************
  * video_yuv.c: YUV transformation functions
- * (c)1999 VideoLAN
- *******************************************************************************
  * Provides functions to perform the YUV conversion. The functions provided here
  * are a complete and portable C implementation, and may be replaced in certain
  * case by optimized functions.
- *******************************************************************************/
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * 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 program 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.
+ *
+ * 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.
+ *****************************************************************************/
 
-/*******************************************************************************
+/*****************************************************************************
  * Preamble
- *******************************************************************************/
-#include <math.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
+ *****************************************************************************/
+#include "defs.h"
+
+#include <math.h>                                            /* exp(), pow() */
+#include <errno.h>                                                 /* ENOMEM */
+#include <stdlib.h>                                                /* free() */
+#include <string.h>                                            /* strerror() */
 
-#include "common.h"
 #include "config.h"
+#include "common.h"
+#include "threads.h"
 #include "mtime.h"
-#include "vlc_thread.h"
+#include "plugins.h"
 #include "video.h"
 #include "video_output.h"
 #include "video_yuv.h"
+
 #include "intf_msg.h"
 
-/*******************************************************************************
+/*****************************************************************************
  * Constants
- *******************************************************************************/
-
-/* Color masks for different color depths - 8bpp masks can be choosen, since 
- * colormaps instead of hardware-defined colors are used. */
-//?? remove
-#define RED_8BPP_MASK           0xe0
-#define GREEN_8BPP_MASK         0x1c
-#define BLUE_8BPP_MASK          0x03
-
-#define RED_15BPP_MASK          0xf800
-#define GREEN_15BPP_MASK        0x03e0
-#define BLUE_15BPP_MASK         0x001f
-
-#define RED_16BPP_MASK          0xf800
-#define GREEN_16BPP_MASK        0x07e0
-#define BLUE_16BPP_MASK         0x001f
-
-#define RED_24BPP_MASK          0xff0000
-#define GREEN_24BPP_MASK        0x00ff00
-#define BLUE_24BPP_MASK         0x0000ff
-
-/* RGB/YUV inversion matrix (ISO/IEC 13818-2 section 6.3.6, table 6.9) */
-//?? no more used ?
-const int MATRIX_COEFFICIENTS_TABLE[8][4] =
-{
-  {117504, 138453, 13954, 34903},       /* no sequence_display_extension */
-  {117504, 138453, 13954, 34903},       /* ITU-R Rec. 709 (1990) */
-  {104597, 132201, 25675, 53279},       /* unspecified */
-  {104597, 132201, 25675, 53279},       /* reserved */
-  {104448, 132798, 24759, 53109},       /* FCC */
-  {104597, 132201, 25675, 53279},       /* ITU-R Rec. 624-4 System B, G */
-  {104597, 132201, 25675, 53279},       /* SMPTE 170M */
-  {117579, 136230, 16907, 35559}        /* SMPTE 240M (1987) */
-};
+ *****************************************************************************/
 
 /* Margins and offsets in conversion tables - Margins are used in case a RGB
  * RGB conversion would give a value outside the 0-255 range. Offsets have been
@@ -78,19 +66,21 @@ const int MATRIX_COEFFICIENTS_TABLE[8][4] =
 
 #define PALETTE_TABLE_SIZE 2176          /* YUV -> 8bpp palette lookup table */
 
-//??
+/* macros used for YUV pixel conversions */
 #define SHIFT 20
 #define U_GREEN_COEF    ((int)(-0.391 * (1<<SHIFT) / 1.164))
 #define U_BLUE_COEF     ((int)(2.018 * (1<<SHIFT) / 1.164))
 #define V_RED_COEF      ((int)(1.596 * (1<<SHIFT) / 1.164))
 #define V_GREEN_COEF    ((int)(-0.813 * (1<<SHIFT) / 1.164))
 
+//#define NODITHER
+
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
 static void     SetGammaTable     ( int *pi_table, double f_gamma );
 static void     SetYUV            ( vout_thread_t *p_vout );
-static void     SetOffset         ( int i_width, int i_height, int i_pic_width, int i_pic_height, 
+static void     SetOffset         ( int i_width, int i_height, int i_pic_width, int i_pic_height,
                                     boolean_t *pb_h_scaling, int *pi_v_scaling, int *p_offset );
 
 static void     ConvertY4Gray8    ( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
@@ -187,7 +177,7 @@ static void     ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data
         (((*p_y++ + dither13[i_real_y]) >> 4) << 7)                           \
       + ((*p_u++ + dither23[i_real_y]) >> 5) * 9                              \
       + ((*p_v++ + dither23[i_real_y]) >> 5) ];                               \
+
 #define CONVERT_4YUV_PIXELS_SCALE( CHROMA )                                   \
     *p_pic++ = p_lookup[                                                      \
         (((*p_y + dither10[i_real_y]) >> 4) << 7)                             \
@@ -274,7 +264,7 @@ static void     ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data
     {                                                                         \
         /* Horizontal scaling, but we can't use a buffer due to dither */     \
         p_offset = p_offset_start;                                            \
-       b_jump_uv = 0;                                                        \
+        b_jump_uv = 0;                                                        \
         for( i_x = i_pic_width / 16; i_x--; )                                 \
         {                                                                     \
             CONVERT_4YUV_PIXELS_SCALE( CHROMA )                               \
@@ -291,7 +281,7 @@ static void     ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data
             CONVERT_4YUV_PIXELS( CHROMA )                                     \
             CONVERT_4YUV_PIXELS( CHROMA )                                     \
             CONVERT_4YUV_PIXELS( CHROMA )                                     \
-       }                                                                     \
+        }                                                                     \
     }                                                                         \
     /* Increment of picture pointer to end of line is still needed */         \
     p_pic += i_pic_line_width;                                                \
@@ -437,29 +427,29 @@ static void     ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data
 int vout_InitYUV( vout_thread_t *p_vout )
 {
     size_t      tables_size;                        /* tables size, in bytes */
-    
+
     /* Computes tables size - 3 Bpp use 32 bits pixel entries in tables */
     switch( p_vout->i_bytes_per_pixel )
     {
     case 1:
         tables_size = sizeof( u8 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : PALETTE_TABLE_SIZE);
-        break;        
+        break;
     case 2:
         tables_size = sizeof( u16 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
-        break;        
-    case 3:        
+        break;
+    case 3:
     case 4:
-    default:         
-        tables_size = sizeof( u32 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);        
-        break;        
+    default:
+        tables_size = sizeof( u32 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
+        break;
     }
-    
+
     /* Allocate memory */
     p_vout->yuv.p_base = malloc( tables_size );
     if( p_vout->yuv.p_base == NULL )
     {
         intf_ErrMsg("error: %s\n", strerror(ENOMEM));
-        return( 1 );                
+        return( 1 );
     }
 
     /* Allocate memory for conversion buffer and offset array */
@@ -468,20 +458,20 @@ int vout_InitYUV( vout_thread_t *p_vout )
     {
         intf_ErrMsg("error: %s\n", strerror(ENOMEM));
         free( p_vout->yuv.p_base );
-        return( 1 );                
+        return( 1 );
     }
-    p_vout->yuv.p_offset = malloc( p_vout->i_width * sizeof( int ) );    
+    p_vout->yuv.p_offset = malloc( p_vout->i_width * sizeof( int ) );
     if( p_vout->yuv.p_offset == NULL )
     {
         intf_ErrMsg("error: %s\n", strerror(ENOMEM));
         free( p_vout->yuv.p_base );
-        free( p_vout->yuv.p_buffer );        
-        return( 1 );                
+        free( p_vout->yuv.p_buffer );
+        return( 1 );
     }
 
     /* Initialize tables */
     SetYUV( p_vout );
-    return( 0 );    
+    return( 0 );
 }
 
 /*****************************************************************************
@@ -492,8 +482,8 @@ int vout_InitYUV( vout_thread_t *p_vout )
  *****************************************************************************/
 int vout_ResetYUV( vout_thread_t *p_vout )
 {
-    vout_EndYUV( p_vout );    
-    return( vout_InitYUV( p_vout ) );    
+    vout_EndYUV( p_vout );
+    return( vout_InitYUV( p_vout ) );
 }
 
 /*****************************************************************************
@@ -505,7 +495,7 @@ void vout_EndYUV( vout_thread_t *p_vout )
 {
     free( p_vout->yuv.p_base );
     free( p_vout->yuv.p_buffer );
-    free( p_vout->yuv.p_offset );    
+    free( p_vout->yuv.p_offset );
 }
 
 /* following functions are local */
@@ -537,12 +527,12 @@ static void SetYUV( vout_thread_t *p_vout )
     int         pi_gamma[256];                                /* gamma table */
     int         i_index;                                  /* index in tables */
 
-    /* Build gamma table */    
+    /* Build gamma table */
     SetGammaTable( pi_gamma, p_vout->f_gamma );
-    
+
     /*
      * Set pointers and build YUV tables
-     */        
+     */
     if( p_vout->b_grayscale )
     {
         /* Grayscale: build gray table */
@@ -557,8 +547,8 @@ static void SetYUV( vout_thread_t *p_vout )
                 {
                     p_vout->yuv.yuv.p_gray8[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
                     p_vout->yuv.yuv.p_gray8[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
-                }            
-                for( i_index = 0; i_index < 256; i_index++) 
+                }
+                for( i_index = 0; i_index < 256; i_index++)
                 {
                     p_vout->yuv.yuv.p_gray8[ i_index ] = pi_gamma[ i_index ];
                     bright[ i_index ] = i_index << 8;
@@ -571,7 +561,7 @@ static void SetYUV( vout_thread_t *p_vout )
                 p_vout->i_gray_pixel = 0x44;
                 p_vout->i_blue_pixel = 0x3b;
 
-                break;        
+                break;
             }
         case 2:
             p_vout->yuv.yuv.p_gray16 =  (u16 *)p_vout->yuv.p_base + GRAY_MARGIN;
@@ -579,25 +569,25 @@ static void SetYUV( vout_thread_t *p_vout )
             {
                 p_vout->yuv.yuv.p_gray16[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
                 p_vout->yuv.yuv.p_gray16[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
-            }            
-            for( i_index = 0; i_index < 256; i_index++) 
+            }
+            for( i_index = 0; i_index < 256; i_index++)
             {
                 p_vout->yuv.yuv.p_gray16[ i_index ] = RGB2PIXEL( p_vout, pi_gamma[i_index], pi_gamma[i_index], pi_gamma[i_index] );
             }
-            break;        
+            break;
         case 3:
-        case 4:        
+        case 4:
             p_vout->yuv.yuv.p_gray32 =  (u32 *)p_vout->yuv.p_base + GRAY_MARGIN;
             for( i_index = 0; i_index < GRAY_MARGIN; i_index++ )
             {
                 p_vout->yuv.yuv.p_gray32[ -i_index ] =      RGB2PIXEL( p_vout, pi_gamma[0], pi_gamma[0], pi_gamma[0] );
                 p_vout->yuv.yuv.p_gray32[ 256 + i_index ] = RGB2PIXEL( p_vout, pi_gamma[255], pi_gamma[255], pi_gamma[255] );
-            }            
-            for( i_index = 0; i_index < 256; i_index++) 
+            }
+            for( i_index = 0; i_index < 256; i_index++)
             {
                 p_vout->yuv.yuv.p_gray32[ i_index ] = RGB2PIXEL( p_vout, pi_gamma[i_index], pi_gamma[i_index], pi_gamma[i_index] );
             }
-            break;        
+            break;
          }
     }
     else
@@ -609,20 +599,17 @@ static void SetYUV( vout_thread_t *p_vout )
             {
                 #define RGB_MIN 0
                 #define RGB_MAX 255
-                #define SATURATE( x )    \
-                x = x + ( x >> 3 ) - 16; \
-                if( x < 0 ) x = 0;       \
-                if( x > 255 ) x = 255;
-    
+                #define CLIP( x ) ( ((x < 0) ? 0 : (x > 255) ? 255 : x) << 8 )
+
                 int y,u,v;
                 int r,g,b;
                 int uvr, uvg, uvb;
                 int i = 0, j = 0;
                 u16 red[256], green[256], blue[256], transp[256];
                 unsigned char lookup[PALETTE_TABLE_SIZE];
-    
+
                 p_vout->yuv.yuv.p_rgb8 = (u8 *)p_vout->yuv.p_base;
-    
+
                 /* this loop calculates the intersection of an YUV box
                  * and the RGB cube. */
                 for ( y = 0; y <= 256; y += 16 )
@@ -636,23 +623,19 @@ static void SetYUV( vout_thread_t *p_vout )
                         r = y + uvr;
                         g = y + uvg;
                         b = y + uvb;
-    
+
                         if( r >= RGB_MIN && g >= RGB_MIN && b >= RGB_MIN
                                 && r <= RGB_MAX && g <= RGB_MAX && b <= RGB_MAX )
                         {
                             /* this one should never happen unless someone fscked up my code */
-                            if(j == 256) { intf_DbgMsg( "sorry, no colors left\n" ); exit( 1 ); }
-    
-                            /* saturate the colors */
-                            SATURATE( r );
-                            SATURATE( g );
-                            SATURATE( b );
-    
-                            red[j] = r << 8;
-                            green[j] = g << 8;
-                            blue[j] = b << 8;
+                            if(j == 256) { intf_ErrMsg( "vout error: no colors left to build palette\n" ); break; }
+
+                            /* clip the colors */
+                            red[j] = CLIP( r );
+                            green[j] = CLIP( g );
+                            blue[j] = CLIP( b );
                             transp[j] = 0;
-    
+
                             /* allocate color */
                             lookup[i] = 1;
                             p_vout->yuv.yuv.p_rgb8[i++] = j;
@@ -687,13 +670,13 @@ static void SetYUV( vout_thread_t *p_vout )
                     {
                         int u2, v2;
                         int dist, mindist = 100000000;
-    
+
                         if( lookup[i] || y==0)
                         {
                             i++;
                             continue;
                         }
-                                                                                                                   
+
                         /* heavy. yeah. */
                         for( u2 = 0; u2 <= 256; u2 += 32 )
                         for( v2 = 0; v2 <= 256; v2 += 32 )
@@ -721,7 +704,7 @@ static void SetYUV( vout_thread_t *p_vout )
                     i += 128-81;
                 }
 
-                break;        
+                break;
             }
         case 2:
             p_vout->yuv.yuv.p_rgb16 = (u16 *)p_vout->yuv.p_base;
@@ -744,9 +727,9 @@ static void SetYUV( vout_thread_t *p_vout )
             {
                 p_vout->yuv.yuv.p_rgb16[RED_OFFSET + i_index] =   RGB2PIXEL( p_vout, pi_gamma[ i_index ], 0, 0 );
                 p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[ i_index ], 0 );
-                p_vout->yuv.yuv.p_rgb16[BLUE_OFFSET + i_index] =  RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] ); 
-            }            
-            break;        
+                p_vout->yuv.yuv.p_rgb16[BLUE_OFFSET + i_index] =  RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] );
+            }
+            break;
         case 3:
         case 4:
             p_vout->yuv.yuv.p_rgb32 = (u32 *)p_vout->yuv.p_base;
@@ -769,11 +752,11 @@ static void SetYUV( vout_thread_t *p_vout )
             {
                 p_vout->yuv.yuv.p_rgb32[RED_OFFSET + i_index] =   RGB2PIXEL( p_vout, pi_gamma[ i_index ], 0, 0 );
                 p_vout->yuv.yuv.p_rgb32[GREEN_OFFSET + i_index] = RGB2PIXEL( p_vout, 0, pi_gamma[ i_index ], 0 );
-                p_vout->yuv.yuv.p_rgb32[BLUE_OFFSET + i_index] =  RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] ); 
-            }            
-            break;        
+                p_vout->yuv.yuv.p_rgb32[BLUE_OFFSET + i_index] =  RGB2PIXEL( p_vout, 0, 0, pi_gamma[ i_index ] );
+            }
+            break;
         }
-    }    
+    }
 
     /*
      * Set functions pointers
@@ -784,26 +767,26 @@ static void SetYUV( vout_thread_t *p_vout )
         switch( p_vout->i_bytes_per_pixel )
         {
         case 1:
-            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray8;        
-            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray8;        
-            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray8;        
-            break;        
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray8;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray8;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray8;
+            break;
         case 2:
-            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray16;        
-            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray16;        
-            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray16;        
-            break;        
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray16;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray16;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray16;
+            break;
         case 3:
-            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray24;        
-            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray24;        
-            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray24;        
-            break;        
-        case 4:        
-            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray32;        
-            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray32;        
-            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray32;        
-            break;        
-        }        
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray24;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray24;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray24;
+            break;
+        case 4:
+            p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray32;
+            p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray32;
+            p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray32;
+            break;
+        }
     }
     else
     {
@@ -814,24 +797,24 @@ static void SetYUV( vout_thread_t *p_vout )
             p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertYUV420RGB8;
             p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertYUV422RGB8;
             p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertYUV444RGB8;
-            break;        
+            break;
         case 2:
-            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB16;        
-            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB16;        
-            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB16;        
-            break;        
+            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB16;
+            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB16;
+            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB16;
+            break;
         case 3:
-            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB24;        
-            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB24;        
-            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB24;        
-            break;        
-        case 4:        
-            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB32;        
-            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB32;        
-            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB32;        
-            break;        
+            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB24;
+            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB24;
+            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB24;
+            break;
+        case 4:
+            p_vout->yuv.p_Convert420 =   (vout_yuv_convert_t *) ConvertYUV420RGB32;
+            p_vout->yuv.p_Convert422 =   (vout_yuv_convert_t *) ConvertYUV422RGB32;
+            p_vout->yuv.p_Convert444 =   (vout_yuv_convert_t *) ConvertYUV444RGB32;
+            break;
         }
-    }        
+    }
 }
 
 /*****************************************************************************
@@ -840,29 +823,29 @@ static void SetYUV( vout_thread_t *p_vout )
  * This function will build an offset array used in later conversion functions.
  * It will also set horizontal and vertical scaling indicators.
  *****************************************************************************/
-static void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height, 
+static void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
                        boolean_t *pb_h_scaling, int *pi_v_scaling, int *p_offset )
-{    
+{
     int i_x;                                    /* x position in destination */
     int i_scale_count;                                     /* modulo counter */
 
     /*
      * Prepare horizontal offset array
-     */      
+     */
     if( i_pic_width - i_width > 0 )
     {
         /* Prepare scaling array for horizontal extension */
-        *pb_h_scaling =  1;   
+        *pb_h_scaling =  1;
         i_scale_count =         i_pic_width;
         for( i_x = i_width; i_x--; )
         {
             while( (i_scale_count -= i_width) > 0 )
             {
-                *p_offset++ = 0;                
+                *p_offset++ = 0;
             }
-            *p_offset++ = 1;            
-            i_scale_count += i_pic_width;            
-        }        
+            *p_offset++ = 1;
+            i_scale_count += i_pic_width;
+        }
     }
     else if( i_pic_width - i_width < 0 )
     {
@@ -871,19 +854,19 @@ static void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_hei
         i_scale_count =         i_pic_width;
         for( i_x = i_pic_width; i_x--; )
         {
-            *p_offset = 1;            
+            *p_offset = 1;
             while( (i_scale_count -= i_pic_width) >= 0 )
-            {                
-                *p_offset += 1;                
+            {
+                *p_offset += 1;
             }
             p_offset++;
             i_scale_count += i_width;
-        }        
+        }
     }
     else
     {
-        /* No horizontal scaling: YUV conversion is done directly to picture */          
-        *pb_h_scaling = 0;        
+        /* No horizontal scaling: YUV conversion is done directly to picture */
+        *pb_h_scaling = 0;
     }
 
     /*
@@ -891,15 +874,15 @@ static void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_hei
      */
     if( i_pic_height - i_height > 0 )
     {
-        *pi_v_scaling = 1;        
+        *pi_v_scaling = 1;
     }
     else if( i_pic_height - i_height < 0 )
     {
-        *pi_v_scaling = -1;        
+        *pi_v_scaling = -1;
     }
     else
     {
-        *pi_v_scaling = 0;        
+        *pi_v_scaling = 0;
     }
 }
 
@@ -922,15 +905,15 @@ static void ConvertY4Gray8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y,
     u8 *        p_buffer;                       /* conversion buffer pointer */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
-    i_pic_line_width -= i_pic_width;                                            
-    p_gray =            p_vout->yuv.yuv.p_gray8;    
-    p_buffer_start =    p_vout->yuv.p_buffer;                                   
-    p_offset_start =    p_vout->yuv.p_offset;                                   
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    i_pic_line_width -= i_pic_width;
+    p_gray =            p_vout->yuv.yuv.p_gray8;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -956,11 +939,11 @@ static void ConvertY4Gray8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y,
             *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
             *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
             *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-        }             
+        }
 
         /* Do horizontal and vertical scaling */
         SCALE_WIDTH;
-        SCALE_HEIGHT(400, 1);        
+        SCALE_HEIGHT(400, 1);
     }
 }
 
@@ -982,15 +965,15 @@ static void ConvertY4Gray16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y
     u16 *       p_buffer;                       /* conversion buffer pointer */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
-    i_pic_line_width -= i_pic_width;                                            
-    p_gray =            p_vout->yuv.yuv.p_gray16;    
-    p_buffer_start =    p_vout->yuv.p_buffer;                                   
-    p_offset_start =    p_vout->yuv.p_offset;                                   
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    i_pic_line_width -= i_pic_width;
+    p_gray =            p_vout->yuv.yuv.p_gray16;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -1002,7 +985,7 @@ static void ConvertY4Gray16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y
         /* Mark beginnning of line for possible later line copy, and initialize
          * buffer */
         p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;        
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
 
         /* Do YUV conversion to buffer - YUV picture is always formed of 16
          * pixels wide blocks */
@@ -1016,11 +999,11 @@ static void ConvertY4Gray16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y
             *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
             *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
             *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-        }             
+        }
 
         /* Do horizontal and vertical scaling */
         SCALE_WIDTH;
-        SCALE_HEIGHT(400, 2);        
+        SCALE_HEIGHT(400, 2);
     }
 }
 
@@ -1031,7 +1014,7 @@ static void ConvertY4Gray24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_
                              int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
                              int i_matrix_coefficients )
 {
-    //??
+    /* XXX?? */
 }
 
 /*****************************************************************************
@@ -1052,15 +1035,15 @@ static void ConvertY4Gray32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y
     u32 *       p_buffer;                       /* conversion buffer pointer */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
-    i_pic_line_width -= i_pic_width;                                            
-    p_gray =            p_vout->yuv.yuv.p_gray32;    
-    p_buffer_start =    p_vout->yuv.p_buffer;                                   
-    p_offset_start =    p_vout->yuv.p_offset;                                   
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    i_pic_line_width -= i_pic_width;
+    p_gray =            p_vout->yuv.yuv.p_gray32;
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -1072,7 +1055,7 @@ static void ConvertY4Gray32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y
         /* Mark beginnning of line for possible later line copy, and initialize
          * buffer */
         p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;        
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
 
         /* Do YUV conversion to buffer - YUV picture is always formed of 16
          * pixels wide blocks */
@@ -1086,11 +1069,11 @@ static void ConvertY4Gray32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y
             *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
             *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
             *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
-        }             
+        }
 
         /* Do horizontal and vertical scaling */
         SCALE_WIDTH;
-        SCALE_HEIGHT(400, 4);        
+        SCALE_HEIGHT(400, 4);
     }
 }
 
@@ -1111,31 +1094,48 @@ static void ConvertYUV420RGB8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_
     int         i_chroma_width;                              /* chroma width */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    int dither10[4] = { 0x0, 0x8, 0x2, 0xa };
-    int dither11[4] = { 0xc, 0x4, 0xe, 0x6 };
-    int dither12[4] = { 0x3, 0xb, 0x1, 0x9 };
-    int dither13[4] = { 0xf, 0x7, 0xd, 0x5 };
-    int dither20[4] = { 0x00, 0x10, 0x04, 0x14 };
-    int dither21[4] = { 0x18, 0x08, 0x1c, 0x0c };
-    int dither22[4] = { 0x06, 0x16, 0x02, 0x12 };
-    int dither23[4] = { 0x1e, 0x0e, 0x1a, 0x0a };
-
-    /* other matrices that can be interesting, either for debugging or for effects */
-    //int dither[4][4] = { { 0, 8, 2, 10 }, { 12, 4, 14, 16 }, { 3, 11, 1, 9}, {15, 7, 13, 5} };
-    //int dither[4][4] = { { 7, 8, 0, 15 }, { 0, 15, 8, 7 }, { 7, 0, 15, 8 }, { 15, 7, 8, 0 } };
-    //int dither[4][4] = { { 0, 15, 0, 15 }, { 15, 0, 15, 0 }, { 0, 15, 0, 15 }, { 15, 0, 15, 0 } };
-    //int dither[4][4] = { { 15, 15, 0, 0 }, { 15, 15, 0, 0 }, { 0, 0, 15, 15 }, { 0, 0, 15, 15 } };
-    //int dither[4][4] = { { 8, 8, 8, 8 }, { 8, 8, 8, 8 }, { 8, 8, 8, 8 }, { 8, 8, 8, 8 } };
-    //int dither[4][4] = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, { 12, 13, 14, 15 } };
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+#ifdef NODITHER
+    int dither10[4] = {  0x7,  0x8,  0x7,  0x8 };
+    int dither11[4] = {  0x8,  0x7,  0x8,  0x7 };
+    int dither12[4] = {  0x7,  0x8,  0x7,  0x8 };
+    int dither13[4] = {  0x8,  0x7,  0x8,  0x7 };
+
+    int dither20[4] = {  0xf, 0x10,  0xf, 0x10 };
+    int dither21[4] = { 0x10,  0xf, 0x10,  0xf };
+    int dither22[4] = {  0xf, 0x10,  0xf, 0x10 };
+    int dither23[4] = { 0x10,  0xf, 0x10,  0xf };
+#else
+    int dither10[4] = {  0x0,  0x8,  0x2,  0xa };
+    int dither11[4] = {  0xc,  0x4,  0xe,  0x6 };
+    int dither12[4] = {  0x3,  0xb,  0x1,  0x9 };
+    int dither13[4] = {  0xf,  0x7,  0xd,  0x5 };
+
+    int dither20[4] = {  0x0, 0x10,  0x4, 0x14 };
+    int dither21[4] = { 0x18,  0x8, 0x1c,  0xc };
+    int dither22[4] = {  0x6, 0x16,  0x2, 0x12 };
+    int dither23[4] = { 0x1e,  0xe, 0x1a,  0xa };
+#endif
+
+    /* some other matrices that can be interesting, either for debugging
+     *  or for effects :
+     *  
+     * { { 0, 8, 2, 10 }, { 12, 4, 14, 16 }, { 3, 11, 1, 9}, {15, 7, 13, 5} }
+     * { { 7, 8, 0, 15 }, { 0, 15, 8, 7 }, { 7, 0, 15, 8 }, { 15, 7, 8, 0 } }
+     * { { 0, 15, 0, 15 }, { 15, 0, 15, 0 }, { 0, 15, 0, 15 }, { 15, 0, 15, 0 } }
+     * { { 15, 15, 0, 0 }, { 15, 15, 0, 0 }, { 0, 0, 15, 15 }, { 0, 0, 15, 15 } }
+     * { { 8, 8, 8, 8 }, { 8, 8, 8, 8 }, { 8, 8, 8, 8 }, { 8, 8, 8, 8 } }
+     * { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, { 12, 13, 14, 15 } }
+     */
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
     i_pic_line_width -= i_pic_width;
     i_chroma_width =    i_width / 2;
     p_offset_start =    p_vout->yuv.p_offset;
     p_lookup =          p_vout->yuv.p_base;
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -1172,16 +1172,16 @@ static void ConvertYUV422RGB8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_
     u8 *        p_buffer;                       /* conversion buffer pointer */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
     i_pic_line_width -= i_pic_width;
     i_chroma_width =    i_width / 2;
     p_yuv =             p_vout->yuv.yuv.p_rgb8;
-    p_buffer_start =    p_vout->yuv.p_buffer;        
-    p_offset_start =    p_vout->yuv.p_offset;                    
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -1193,7 +1193,7 @@ static void ConvertYUV422RGB8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_
         /* Mark beginnning of line for possible later line copy, and initialize
          * buffer */
         p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;        
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
 
         /* Do YUV conversion to buffer - YUV picture is always formed of 16
          * pixels wide blocks */
@@ -1207,11 +1207,11 @@ static void ConvertYUV422RGB8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_
             CONVERT_YUV_PIXEL(1);  CONVERT_Y_PIXEL(1);
             CONVERT_YUV_PIXEL(1);  CONVERT_Y_PIXEL(1);
             CONVERT_YUV_PIXEL(1);  CONVERT_Y_PIXEL(1);
-        }             
+        }
 
         /* Do horizontal and vertical scaling */
         SCALE_WIDTH;
-        SCALE_HEIGHT(422, 1);        
+        SCALE_HEIGHT(422, 1);
     }
 }
 
@@ -1236,15 +1236,15 @@ static void ConvertYUV444RGB8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_
     u8 *        p_buffer;                       /* conversion buffer pointer */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
     i_pic_line_width -= i_pic_width;
     p_yuv =             p_vout->yuv.yuv.p_rgb8;
-    p_buffer_start =    p_vout->yuv.p_buffer;        
-    p_offset_start =    p_vout->yuv.p_offset;                    
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -1256,7 +1256,7 @@ static void ConvertYUV444RGB8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_
         /* Mark beginnning of line for possible later line copy, and initialize
          * buffer */
         p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;        
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
 
         /* Do YUV conversion to buffer - YUV picture is always formed of 16
          * pixels wide blocks */
@@ -1270,11 +1270,11 @@ static void ConvertYUV444RGB8( p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_
             CONVERT_YUV_PIXEL(1);  CONVERT_YUV_PIXEL(1);
             CONVERT_YUV_PIXEL(1);  CONVERT_YUV_PIXEL(1);
             CONVERT_YUV_PIXEL(1);  CONVERT_YUV_PIXEL(1);
-        }             
+        }
 
         /* Do horizontal and vertical scaling */
         SCALE_WIDTH;
-        SCALE_HEIGHT(444, 1);        
+        SCALE_HEIGHT(444, 1);
     }
 }
 
@@ -1285,17 +1285,18 @@ static void ConvertYUV420RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *
                                 int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
                                 int i_matrix_coefficients )
 {
-/* MMX version */
-  //  int                 i_chroma_width, i_chroma_skip;      /* width and eol for chroma */
-/*
+#if 0
+    /* MMX version */
+    int                 i_chroma_width, i_chroma_skip;      /* width and eol for chroma */
+
     i_chroma_width =    i_width / 2;
     i_chroma_skip =     i_skip / 2;
-    ConvertYUV420RGB16MMX( p_y, p_u, p_v, i_width, i_height, 
-                           (i_width + i_skip) * sizeof( yuv_data_t ), 
+    ConvertYUV420RGB16MMX( p_y, p_u, p_v, i_width, i_height,
+                           (i_width + i_skip) * sizeof( yuv_data_t ),
                            (i_chroma_width + i_chroma_skip) * sizeof( yuv_data_t),
                            i_scale, (u8 *)p_pic, 0, 0, (i_width + i_pic_eol) * sizeof( u16 ),
-                           p_vout->i_screen_depth == 15 );    
-*/
+                           p_vout->i_screen_depth == 15 );
+#endif
     boolean_t   b_horizontal_scaling;             /* horizontal scaling type */
     int         i_vertical_scaling;                 /* vertical scaling type */
     int         i_x, i_y;                 /* horizontal and vertical indexes */
@@ -1310,16 +1311,16 @@ static void ConvertYUV420RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *
     u16 *       p_buffer;                       /* conversion buffer pointer */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
     i_pic_line_width -= i_pic_width;
     i_chroma_width =    i_width / 2;
     p_yuv =             p_vout->yuv.yuv.p_rgb16;
-    p_buffer_start =    p_vout->yuv.p_buffer;        
-    p_offset_start =    p_vout->yuv.p_offset;                    
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -1331,7 +1332,7 @@ static void ConvertYUV420RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *
         /* Mark beginnning of line for possible later line copy, and initialize
          * buffer */
         p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;        
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
 
         /* Do YUV conversion to buffer - YUV picture is always formed of 16
          * pixels wide blocks */
@@ -1345,11 +1346,11 @@ static void ConvertYUV420RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *
             CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
             CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
             CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-        }             
+        }
 
         /* Do horizontal and vertical scaling */
         SCALE_WIDTH;
-        SCALE_HEIGHT(420, 2);        
+        SCALE_HEIGHT(420, 2);
     }
 }
 
@@ -1374,16 +1375,16 @@ static void ConvertYUV422RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *
     u16 *       p_buffer;                       /* conversion buffer pointer */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
     i_pic_line_width -= i_pic_width;
     i_chroma_width =    i_width / 2;
     p_yuv =             p_vout->yuv.yuv.p_rgb16;
-    p_buffer_start =    p_vout->yuv.p_buffer;        
-    p_offset_start =    p_vout->yuv.p_offset;                    
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -1395,7 +1396,7 @@ static void ConvertYUV422RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *
         /* Mark beginnning of line for possible later line copy, and initialize
          * buffer */
         p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;        
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
 
         /* Do YUV conversion to buffer - YUV picture is always formed of 16
          * pixels wide blocks */
@@ -1409,11 +1410,11 @@ static void ConvertYUV422RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *
             CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
             CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
             CONVERT_YUV_PIXEL(2);  CONVERT_Y_PIXEL(2);
-        }             
+        }
 
         /* Do horizontal and vertical scaling */
         SCALE_WIDTH;
-        SCALE_HEIGHT(422, 2);        
+        SCALE_HEIGHT(422, 2);
     }
 }
 
@@ -1438,15 +1439,15 @@ static void ConvertYUV444RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *
     u16 *       p_buffer;                       /* conversion buffer pointer */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
     i_pic_line_width -= i_pic_width;
     p_yuv =             p_vout->yuv.yuv.p_rgb16;
-    p_buffer_start =    p_vout->yuv.p_buffer;        
-    p_offset_start =    p_vout->yuv.p_offset;                    
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -1458,7 +1459,7 @@ static void ConvertYUV444RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *
         /* Mark beginnning of line for possible later line copy, and initialize
          * buffer */
         p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;        
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
 
         /* Do YUV conversion to buffer - YUV picture is always formed of 16
          * pixels wide blocks */
@@ -1472,11 +1473,11 @@ static void ConvertYUV444RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *
             CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
             CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
             CONVERT_YUV_PIXEL(2);  CONVERT_YUV_PIXEL(2);
-        }             
+        }
 
         /* Do horizontal and vertical scaling */
         SCALE_WIDTH;
-        SCALE_HEIGHT(444, 2);        
+        SCALE_HEIGHT(444, 2);
     }
 }
 
@@ -1487,7 +1488,7 @@ static void ConvertYUV420RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t
                                 int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
                                 int i_matrix_coefficients )
 {
-    //???
+    /* XXX?? */
 }
 
 /*****************************************************************************
@@ -1497,7 +1498,7 @@ static void ConvertYUV422RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t
                                 int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
                                 int i_matrix_coefficients )
 {
-    //???
+    /* XXX?? */
 }
 
 /*****************************************************************************
@@ -1506,8 +1507,8 @@ static void ConvertYUV422RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t
 static void ConvertYUV444RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
                                 int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
                                 int i_matrix_coefficients )
-{    
-    //???
+{
+    /* XXX?? */
 }
 
 /*****************************************************************************
@@ -1531,16 +1532,16 @@ static void ConvertYUV420RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *
     u32 *       p_buffer;                       /* conversion buffer pointer */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
     i_pic_line_width -= i_pic_width;
     i_chroma_width =    i_width / 2;
     p_yuv =             p_vout->yuv.yuv.p_rgb32;
-    p_buffer_start =    p_vout->yuv.p_buffer;        
-    p_offset_start =    p_vout->yuv.p_offset;                    
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -1552,7 +1553,7 @@ static void ConvertYUV420RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *
         /* Mark beginnning of line for possible later line copy, and initialize
          * buffer */
         p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;        
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
 
         /* Do YUV conversion to buffer - YUV picture is always formed of 16
          * pixels wide blocks */
@@ -1566,11 +1567,11 @@ static void ConvertYUV420RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *
             CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
             CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
             CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-        }             
+        }
 
         /* Do horizontal and vertical scaling */
         SCALE_WIDTH;
-        SCALE_HEIGHT(420, 4);        
+        SCALE_HEIGHT(420, 4);
     }
 }
 
@@ -1595,16 +1596,16 @@ static void ConvertYUV422RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *
     u32 *       p_buffer;                       /* conversion buffer pointer */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
     i_pic_line_width -= i_pic_width;
     i_chroma_width =    i_width / 2;
     p_yuv =             p_vout->yuv.yuv.p_rgb32;
-    p_buffer_start =    p_vout->yuv.p_buffer;        
-    p_offset_start =    p_vout->yuv.p_offset;                    
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -1616,7 +1617,7 @@ static void ConvertYUV422RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *
         /* Mark beginnning of line for possible later line copy, and initialize
          * buffer */
         p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;        
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
 
         /* Do YUV conversion to buffer - YUV picture is always formed of 16
          * pixels wide blocks */
@@ -1630,11 +1631,11 @@ static void ConvertYUV422RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *
             CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
             CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
             CONVERT_YUV_PIXEL(4);  CONVERT_Y_PIXEL(4);
-        }             
+        }
 
         /* Do horizontal and vertical scaling */
         SCALE_WIDTH;
-        SCALE_HEIGHT(422, 4);        
+        SCALE_HEIGHT(422, 4);
     }
 }
 
@@ -1659,15 +1660,15 @@ static void ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *
     u32 *       p_buffer;                       /* conversion buffer pointer */
     int *       p_offset_start;                        /* offset array start */
     int *       p_offset;                            /* offset array pointer */
-    
-    /* 
-     * Initialize some values  - i_pic_line_width will store the line skip 
+
+    /*
+     * Initialize some values  - i_pic_line_width will store the line skip
      */
     i_pic_line_width -= i_pic_width;
     p_yuv =             p_vout->yuv.yuv.p_rgb32;
-    p_buffer_start =    p_vout->yuv.p_buffer;        
-    p_offset_start =    p_vout->yuv.p_offset;                    
-    SetOffset( i_width, i_height, i_pic_width, i_pic_height, 
+    p_buffer_start =    p_vout->yuv.p_buffer;
+    p_offset_start =    p_vout->yuv.p_offset;
+    SetOffset( i_width, i_height, i_pic_width, i_pic_height,
                &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
 
     /*
@@ -1679,7 +1680,7 @@ static void ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *
         /* Mark beginnning of line for possible later line copy, and initialize
          * buffer */
         p_pic_start =   p_pic;
-        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;        
+        p_buffer =      b_horizontal_scaling ? p_buffer_start : p_pic;
 
         /* Do YUV conversion to buffer - YUV picture is always formed of 16
          * pixels wide blocks */
@@ -1693,15 +1694,15 @@ static void ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *
             CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
             CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
             CONVERT_YUV_PIXEL(4);  CONVERT_YUV_PIXEL(4);
-        }             
+        }
 
         /* Do horizontal and vertical scaling */
         SCALE_WIDTH;
-        SCALE_HEIGHT(444, 4);        
+        SCALE_HEIGHT(444, 4);
     }
 }
 
-//-------------------- walken code follows ------------------------------------
+/*-------------------- walken code follows ----------------------------------*/
 
 /*
  * YUV to RGB routines.
@@ -1727,10 +1728,10 @@ static void ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *
  */
 
 #if 0
-//??
+/* XXX?? */
 static void yuvToRgb24 (unsigned char * Y,
-                       unsigned char * U, unsigned char * V,
-                       char * dest, int table[1935], int width)
+                        unsigned char * U, unsigned char * V,
+                        char * dest, int table[1935], int width)
 {
     int i;
     int u;
@@ -1743,145 +1744,145 @@ static void yuvToRgb24 (unsigned char * Y,
 
     i = width >> 3;
     while (i--) {
-       u = *(U++);
-       v = *(V++);
-       uvRed = (V_RED_COEF*v) >> SHIFT;
-       uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-       uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-       tableY = table + *(Y++);
-       tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                       uvGreen] |
-                tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-       *(dest++) = tmp24;
-       *(dest++) = tmp24 >> 8;
-       *(dest++) = tmp24 >> 16;
-
-       tableY = table + *(Y++);
-       tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                       uvGreen] |
-                tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-       *(dest++) = tmp24;
-       *(dest++) = tmp24 >> 8;
-       *(dest++) = tmp24 >> 16;
-
-       u = *(U++);
-       v = *(V++);
-       uvRed = (V_RED_COEF*v) >> SHIFT;
-       uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-       uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-       tableY = table + *(Y++);
-       tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                       uvGreen] |
-                tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-       *(dest++) = tmp24;
-       *(dest++) = tmp24 >> 8;
-       *(dest++) = tmp24 >> 16;
-
-       tableY = table + *(Y++);
-       tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                       uvGreen] |
-                tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-       *(dest++) = tmp24;
-       *(dest++) = tmp24 >> 8;
-       *(dest++) = tmp24 >> 16;
-
-       u = *(U++);
-       v = *(V++);
-       uvRed = (V_RED_COEF*v) >> SHIFT;
-       uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-       uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-       tableY = table + *(Y++);
-       tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                       uvGreen] |
-                tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-       *(dest++) = tmp24;
-       *(dest++) = tmp24 >> 8;
-       *(dest++) = tmp24 >> 16;
-
-       tableY = table + *(Y++);
-       tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                       uvGreen] |
-                tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-       *(dest++) = tmp24;
-       *(dest++) = tmp24 >> 8;
-       *(dest++) = tmp24 >> 16;
-
-       u = *(U++);
-       v = *(V++);
-       uvRed = (V_RED_COEF*v) >> SHIFT;
-       uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-       uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-       tableY = table + *(Y++);
-       tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                       uvGreen] |
-                tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-       *(dest++) = tmp24;
-       *(dest++) = tmp24 >> 8;
-       *(dest++) = tmp24 >> 16;
-
-       tableY = table + *(Y++);
-       tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                       uvGreen] |
-                tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-       *(dest++) = tmp24;
-       *(dest++) = tmp24 >> 8;
-       *(dest++) = tmp24 >> 16;
+        u = *(U++);
+        v = *(V++);
+        uvRed = (V_RED_COEF*v) >> SHIFT;
+        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
+        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
+
+        tableY = table + *(Y++);
+        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
+                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
+                        uvGreen] |
+                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
+        *(dest++) = tmp24;
+        *(dest++) = tmp24 >> 8;
+        *(dest++) = tmp24 >> 16;
+
+        tableY = table + *(Y++);
+        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
+                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
+                        uvGreen] |
+                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
+        *(dest++) = tmp24;
+        *(dest++) = tmp24 >> 8;
+        *(dest++) = tmp24 >> 16;
+
+        u = *(U++);
+        v = *(V++);
+        uvRed = (V_RED_COEF*v) >> SHIFT;
+        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
+        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
+
+        tableY = table + *(Y++);
+        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
+                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
+                        uvGreen] |
+                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
+        *(dest++) = tmp24;
+        *(dest++) = tmp24 >> 8;
+        *(dest++) = tmp24 >> 16;
+
+        tableY = table + *(Y++);
+        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
+                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
+                        uvGreen] |
+                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
+        *(dest++) = tmp24;
+        *(dest++) = tmp24 >> 8;
+        *(dest++) = tmp24 >> 16;
+
+        u = *(U++);
+        v = *(V++);
+        uvRed = (V_RED_COEF*v) >> SHIFT;
+        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
+        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
+
+        tableY = table + *(Y++);
+        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
+                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
+                        uvGreen] |
+                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
+        *(dest++) = tmp24;
+        *(dest++) = tmp24 >> 8;
+        *(dest++) = tmp24 >> 16;
+
+        tableY = table + *(Y++);
+        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
+                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
+                        uvGreen] |
+                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
+        *(dest++) = tmp24;
+        *(dest++) = tmp24 >> 8;
+        *(dest++) = tmp24 >> 16;
+
+        u = *(U++);
+        v = *(V++);
+        uvRed = (V_RED_COEF*v) >> SHIFT;
+        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
+        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
+
+        tableY = table + *(Y++);
+        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
+                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
+                        uvGreen] |
+                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
+        *(dest++) = tmp24;
+        *(dest++) = tmp24 >> 8;
+        *(dest++) = tmp24 >> 16;
+
+        tableY = table + *(Y++);
+        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
+                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
+                        uvGreen] |
+                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
+        *(dest++) = tmp24;
+        *(dest++) = tmp24 >> 8;
+        *(dest++) = tmp24 >> 16;
     }
 
     i = (width & 7) >> 1;
     while (i--) {
-       u = *(U++);
-       v = *(V++);
-       uvRed = (V_RED_COEF*v) >> SHIFT;
-       uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-       uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-       tableY = table + *(Y++);
-       tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                       uvGreen] |
-                tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-       *(dest++) = tmp24;
-       *(dest++) = tmp24 >> 8;
-       *(dest++) = tmp24 >> 16;
-
-       tableY = table + *(Y++);
-       tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                       uvGreen] |
-                tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-       *(dest++) = tmp24;
-       *(dest++) = tmp24 >> 8;
-       *(dest++) = tmp24 >> 16;
+        u = *(U++);
+        v = *(V++);
+        uvRed = (V_RED_COEF*v) >> SHIFT;
+        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
+        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
+
+        tableY = table + *(Y++);
+        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
+                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
+                        uvGreen] |
+                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
+        *(dest++) = tmp24;
+        *(dest++) = tmp24 >> 8;
+        *(dest++) = tmp24 >> 16;
+
+        tableY = table + *(Y++);
+        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
+                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
+                        uvGreen] |
+                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
+        *(dest++) = tmp24;
+        *(dest++) = tmp24 >> 8;
+        *(dest++) = tmp24 >> 16;
     }
 
     if (width & 1) {
-       u = *(U++);
-       v = *(V++);
-       uvRed = (V_RED_COEF*v) >> SHIFT;
-       uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
-       uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
-       tableY = table + *(Y++);
-       tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
-                tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
-                       uvGreen] |
-                tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
-       *(dest++) = tmp24;
-       *(dest++) = tmp24 >> 8;
-       *(dest++) = tmp24 >> 16;
+        u = *(U++);
+        v = *(V++);
+        uvRed = (V_RED_COEF*v) >> SHIFT;
+        uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
+        uvBlue = (U_BLUE_COEF*u) >> SHIFT;
+
+        tableY = table + *(Y++);
+        tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
+                 tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
+                        uvGreen] |
+                 tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
+        *(dest++) = tmp24;
+        *(dest++) = tmp24 >> 8;
+        *(dest++) = tmp24 >> 16;
     }
 }
 #endif