]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/blend.c
Removed stupid debug message.
[vlc] / modules / video_filter / blend.c
index f3cf1dc970dc3eae3082a743926bcc149989c7ca..60874b219df52a4f9abb4fc912dea04b8dea407c 100644 (file)
@@ -77,14 +77,14 @@ static void Blend( filter_t *, picture_t *, picture_t *, picture_t *,
                    int, int, int );
 
 /* YUVA */
-static void BlendI420( filter_t *, picture_t *, picture_t *, picture_t *,
-                       int, int, int, int, int );
-static void BlendR16( filter_t *, picture_t *, picture_t *, picture_t *,
-                      int, int, int, int, int );
-static void BlendR24( filter_t *, picture_t *, picture_t *, picture_t *,
-                      int, int, int, int, int );
-static void BlendYUVPacked( filter_t *, picture_t *, picture_t *, picture_t *,
-                            int, int, int, int, int );
+static void BlendYUVAI420( filter_t *, picture_t *, picture_t *, picture_t *,
+                           int, int, int, int, int );
+static void BlendYUVARV16( filter_t *, picture_t *, picture_t *, picture_t *,
+                           int, int, int, int, int );
+static void BlendYUVARV24( filter_t *, picture_t *, picture_t *, picture_t *,
+                           int, int, int, int, int );
+static void BlendYUVAYUVPacked( filter_t *, picture_t *, picture_t *, picture_t *,
+                                int, int, int, int, int );
 
 /* I420, YV12 */
 static void BlendI420I420( filter_t *, picture_t *, picture_t *, picture_t *,
@@ -117,8 +117,6 @@ static void BlendRGBAR16( filter_t *, picture_t *, picture_t *, picture_t *,
 static void BlendRGBAR24( filter_t *, picture_t *, picture_t *, picture_t *,
                           int, int, int, int, int );
 
-static void video_format_FixRgb( video_format_t *p_fmt );
-
 /*****************************************************************************
  * OpenFilter: probe the filter and return score
  *****************************************************************************/
@@ -196,7 +194,7 @@ static const struct
     BlendFunction pf_blend;
 } p_blend_cfg[] = {
 
-    BLEND_CFG( FCC_YUVA, BlendI420, BlendYUVPacked, BlendR16, BlendR24 ),
+    BLEND_CFG( FCC_YUVA, BlendYUVAI420, BlendYUVAYUVPacked, BlendYUVARV16, BlendYUVARV24 ),
 
     BLEND_CFG( FCC_YUVP, BlendPalI420, BlendPalYUVPacked, BlendPalRV, BlendPalRV ),
 
@@ -390,32 +388,6 @@ static void vlc_blend_rgb16( uint16_t *p_dst, const uint16_t *p_src,
              ( vlc_blend( B >> p_fmt->i_rbshift, b, i_alpha ) << p_fmt->i_lbshift );
 }
 
-/*****************************************************************************
- * BinaryLog: computes the base 2 log of a binary value
- *****************************************************************************
- * This functions is used by MaskToShift, to get a bit index from a binary
- * value.
- *****************************************************************************/
-static int BinaryLog( uint32_t i )
-{
-    int i_log = 0;
-
-    if( i == 0 ) return -31337;
-
-    if( i & 0xffff0000 ) i_log += 16;
-    if( i & 0xff00ff00 ) i_log += 8;
-    if( i & 0xf0f0f0f0 ) i_log += 4;
-    if( i & 0xcccccccc ) i_log += 2;
-    if( i & 0xaaaaaaaa ) i_log += 1;
-
-    return i_log;
-}
-
-/**
- * It transforms a color mask into right and left shifts
- * FIXME copied from video_output.c
- */
-#if 1
 static void vlc_rgb_index( int *pi_rindex, int *pi_gindex, int *pi_bindex,
                            const video_format_t *p_fmt )
 {
@@ -434,96 +406,14 @@ static void vlc_rgb_index( int *pi_rindex, int *pi_gindex, int *pi_bindex,
     *pi_bindex = p_fmt->i_lbshift / 8;
 #endif
 }
-#endif
-
-
-/*
- * FIXME copied from video_output.c
- */
-static void MaskToShift( int *pi_left, int *pi_right, uint32_t i_mask )
-{
-    uint32_t i_low, i_high;            /* lower hand higher bits of the mask */
-
-    if( !i_mask )
-    {
-        *pi_left = *pi_right = 0;
-        return;
-    }
-
-    /* Get bits */
-    i_low = i_high = i_mask;
-
-    i_low &= - (int32_t)i_low;          /* lower bit of the mask */
-    i_high += i_low;                    /* higher bit of the mask */
-
-    /* Transform bits into an index. Also deal with i_high overflow, which
-     * is faster than changing the BinaryLog code to handle 64 bit integers. */
-    i_low =  BinaryLog (i_low);
-    i_high = i_high ? BinaryLog (i_high) : 32;
-
-    /* Update pointers and return */
-    *pi_left =   i_low;
-    *pi_right = (8 - i_high + i_low);
-}
-
-/* FIXME should be moved to src/ */
-static void video_format_FixRgb( video_format_t *p_fmt )
-{
-    if( p_fmt->i_chroma != FCC_RV15 &&
-        p_fmt->i_chroma != FCC_RV16 &&
-        p_fmt->i_chroma != FCC_RV24 &&
-        p_fmt->i_chroma != FCC_RV32 )
-        return;
-
-    /* FIXME find right default mask */
-    if( !p_fmt->i_rmask || !p_fmt->i_gmask || !p_fmt->i_bmask )
-    {
-        switch( p_fmt->i_chroma )
-        {
-        case FCC_RV15:
-            p_fmt->i_rmask = 0x7c00;
-            p_fmt->i_gmask = 0x03e0;
-            p_fmt->i_bmask = 0x001f;
-            break;
-
-        case FCC_RV16:
-            p_fmt->i_rmask = 0xf800;
-            p_fmt->i_gmask = 0x07e0;
-            p_fmt->i_bmask = 0x001f;
-            break;
-
-        case FCC_RV24:
-            p_fmt->i_rmask = 0xff0000;
-            p_fmt->i_gmask = 0x00ff00;
-            p_fmt->i_bmask = 0x0000ff;
-            break;
-        case FCC_RV32:
-            p_fmt->i_rmask = 0x00ff0000;
-            p_fmt->i_gmask = 0x0000ff00;
-            p_fmt->i_bmask = 0x000000ff;
-            break;
-
-        default:
-            assert(0);
-            break;
-        }
-    }
-
-    MaskToShift( &p_fmt->i_lrshift, &p_fmt->i_rrshift,
-                 p_fmt->i_rmask );
-    MaskToShift( &p_fmt->i_lgshift, &p_fmt->i_rgshift,
-                 p_fmt->i_gmask );
-    MaskToShift( &p_fmt->i_lbshift, &p_fmt->i_rbshift,
-                 p_fmt->i_bmask );
-}
 
 /***********************************************************************
  * YUVA
  ***********************************************************************/
-static void BlendI420( filter_t *p_filter, picture_t *p_dst,
-                       picture_t *p_dst_orig, picture_t *p_src,
-                       int i_x_offset, int i_y_offset,
-                       int i_width, int i_height, int i_alpha )
+static void BlendYUVAI420( filter_t *p_filter, picture_t *p_dst,
+                           picture_t *p_dst_orig, picture_t *p_src,
+                           int i_x_offset, int i_y_offset,
+                           int i_width, int i_height, int i_alpha )
 {
     int i_src1_pitch, i_src2_pitch, i_dst_pitch;
     uint8_t *p_src1_y, *p_src2_y, *p_dst_y;
@@ -589,10 +479,10 @@ static void BlendI420( filter_t *p_filter, picture_t *p_dst,
     }
 }
 
-static void BlendR16( filter_t *p_filter, picture_t *p_dst_pic,
-                      picture_t *p_dst_orig, picture_t *p_src,
-                      int i_x_offset, int i_y_offset,
-                      int i_width, int i_height, int i_alpha )
+static void BlendYUVARV16( filter_t *p_filter, picture_t *p_dst_pic,
+                           picture_t *p_dst_orig, picture_t *p_src,
+                           int i_x_offset, int i_y_offset,
+                           int i_width, int i_height, int i_alpha )
 {
     int i_src1_pitch, i_src2_pitch, i_dst_pitch;
     uint8_t *p_dst, *p_src1, *p_src2_y;
@@ -648,10 +538,10 @@ static void BlendR16( filter_t *p_filter, picture_t *p_dst_pic,
     }
 }
 
-static void BlendR24( filter_t *p_filter, picture_t *p_dst_pic,
-                      picture_t *p_dst_orig, picture_t *p_src,
-                      int i_x_offset, int i_y_offset,
-                      int i_width, int i_height, int i_alpha )
+static void BlendYUVARV24( filter_t *p_filter, picture_t *p_dst_pic,
+                           picture_t *p_dst_orig, picture_t *p_src,
+                           int i_x_offset, int i_y_offset,
+                           int i_width, int i_height, int i_alpha )
 {
     int i_src1_pitch, i_src2_pitch, i_dst_pitch;
     uint8_t *p_dst, *p_src1, *p_src2_y;
@@ -781,10 +671,10 @@ static void BlendR24( filter_t *p_filter, picture_t *p_dst_pic,
     }
 }
 
-static void BlendYUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
-                            picture_t *p_dst_orig, picture_t *p_src,
-                            int i_x_offset, int i_y_offset,
-                            int i_width, int i_height, int i_alpha )
+static void BlendYUVAYUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
+                                picture_t *p_dst_orig, picture_t *p_src,
+                                int i_x_offset, int i_y_offset,
+                                int i_width, int i_height, int i_alpha )
 {
     int i_src1_pitch, i_src2_pitch, i_dst_pitch;
     uint8_t *p_dst, *p_src1, *p_src2_y;
@@ -850,7 +740,7 @@ static void BlendYUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
                     i_u = p_src2_u[i_x];
                     i_v = p_src2_v[i_x];
                 }
+
                 vlc_blend_packed( &p_dst[i_x * 2], &p_src1[i_x * 2],
                                   i_l_offset, i_u_offset, i_v_offset,
                                   p_src2_y[i_x], i_u, i_v, i_trans, true );
@@ -1241,7 +1131,6 @@ static void BlendPalI420( filter_t *p_filter, picture_t *p_dst,
     p_src2 = p_src->p->p_pixels + p_filter->fmt_in.video.i_x_offset +
              i_src2_pitch * p_filter->fmt_in.video.i_y_offset;
 
-    const uint8_t *p_trans = p_src2;
 #define p_pal p_filter->fmt_in.video.p_palette->palette
 
     /* Draw until we reach the bottom of the subtitle */
@@ -1253,6 +1142,7 @@ static void BlendPalI420( filter_t *p_filter, picture_t *p_dst,
          p_dst_v += b_even_scanline ? i_dst_pitch/2 : 0,
          p_src1_v += b_even_scanline ? i_src1_pitch/2 : 0 )
     {
+        const uint8_t *p_trans = p_src2;
         b_even_scanline = !b_even_scanline;
 
         /* Draw until we reach the end of the line */
@@ -1305,13 +1195,13 @@ static void BlendPalYUVPacked( filter_t *p_filter, picture_t *p_dst_pic,
 
     i_width &= ~1; /* Needs to be a multiple of 2 */
 
-    const uint8_t *p_trans = p_src2;
 #define p_pal p_filter->fmt_in.video.p_palette->palette
 
     /* Draw until we reach the bottom of the subtitle */
     for( i_y = 0; i_y < i_height; i_y++,
          p_dst += i_dst_pitch, p_src1 += i_src1_pitch, p_src2 += i_src2_pitch )
     {
+        const uint8_t *p_trans = p_src2;
         /* Draw until we reach the end of the line */
         for( i_x = 0; i_x < i_width; i_x++, b_even = !b_even )
         {
@@ -1375,7 +1265,6 @@ static void BlendPalRV( filter_t *p_filter, picture_t *p_dst_pic,
     p_src2 = p_src->p->p_pixels + p_filter->fmt_in.video.i_x_offset +
              i_src2_pitch * p_filter->fmt_in.video.i_y_offset;
 
-    const uint8_t *p_trans = p_src2;
 #define p_pal p_filter->fmt_in.video.p_palette->palette
 #define rgbpal rgbpalette.palette
 
@@ -1393,6 +1282,7 @@ static void BlendPalRV( filter_t *p_filter, picture_t *p_dst_pic,
     for( i_y = 0; i_y < i_height; i_y++,
          p_dst += i_dst_pitch, p_src1 += i_src1_pitch, p_src2 += i_src2_pitch )
     {
+        const uint8_t *p_trans = p_src2;
         /* Draw until we reach the end of the line */
         for( i_x = 0; i_x < i_width; i_x++ )
         {