]> granicus.if.org Git - libvpx/commitdiff
postproc: Tweaks to line drawing and blending.
authorFritz Koenig <frkoenig@google.com>
Wed, 27 Oct 2010 19:50:16 +0000 (12:50 -0700)
committerJohn Koleszar <jkoleszar@google.com>
Thu, 28 Oct 2010 12:25:45 +0000 (08:25 -0400)
Turned down the blending level to make colored blocks obscure
the video less.
Not blending the entire block to give distinction to macro
block edges.
Added configuration so that macro block blending function can
be optimized.
Change to constrain line as to when dx and dy are computed.
Now draw two lines to form an arrow.

Change-Id: I986784e6abff65ea3e0d1437dfca7d06d44ede71

vp8/common/generic/systemdependent.c
vp8/common/postproc.c
vp8/common/postproc.h

index 0c9b77e76275916a5a2849fc2986f9ee848f3a82..c624242a547a07a7536b67b3260175726501da04 100644 (file)
@@ -69,6 +69,7 @@ void vp8_machine_specific_config(VP8_COMMON *ctx)
     rtcd->postproc.across      = vp8_mbpost_proc_across_ip_c;
     rtcd->postproc.downacross  = vp8_post_proc_down_and_across_c;
     rtcd->postproc.addnoise    = vp8_plane_add_noise_c;
+    rtcd->postproc.blend_mb    = vp8_blend_mb_c;
 #endif
 
 #endif
index 21e08638d81d96cd9380dfa1f00279c64af921d6..42e37da307a1455adc643c7dfc33dfafae5c9a5d 100644 (file)
@@ -472,7 +472,10 @@ void vp8_plane_add_noise_c(unsigned char *Start, char *noise,
     }
 }
 
-void vp8_blend_block_c (unsigned char *y, unsigned char *u, unsigned char *v,
+// Blend the macro block with a solid colored square.  Leave the
+// edges unblended to give distinction to macro blocks in areas
+// filled with the same color block.
+void vp8_blend_mb_c (unsigned char *y, unsigned char *u, unsigned char *v,
                         int y1, int u1, int v1, int alpha, int stride)
 {
     int i, j;
@@ -480,63 +483,73 @@ void vp8_blend_block_c (unsigned char *y, unsigned char *u, unsigned char *v,
     int u1_const = u1*((1<<16)-alpha);
     int v1_const = v1*((1<<16)-alpha);
 
-    for (i = 0; i < 16; i++)
+    y += stride + 2;
+    for (i = 0; i < 14; i++)
     {
-        for (j = 0; j < 16; j++)
+        for (j = 0; j < 14; j++)
         {
             y[j] = (y[j]*alpha + y1_const)>>16;
         }
         y += stride;
     }
 
-    for (i = 0; i < 8; i++)
+    stride >>= 1;
+
+    u += stride + 1;
+    v += stride + 1;
+
+    for (i = 0; i < 6; i++)
     {
-        for (j = 0; j < 8; j++)
+        for (j = 0; j < 6; j++)
         {
             u[j] = (u[j]*alpha + u1_const)>>16;
             v[j] = (v[j]*alpha + v1_const)>>16;
         }
-        u += stride/2;
-        v += stride/2;
+        u += stride;
+        v += stride;
     }
 }
 
 static void constrain_line (int x0, int *x1, int y0, int *y1, int width, int height)
 {
-    int dx = *x1 - x0;
-    int dy = *y1 - y0;
+    int dx;
+    int dy;
 
     if (*x1 > width)
     {
+        dx = *x1 - x0;
+        dy = *y1 - y0;
+
         *x1 = width;
         if (dy)
             *y1 = ((width-x0)*dy)/dx + y0;
-        dx = *x1 - x0;
-        dy = *y1 - y0;
     }
     if (*x1 < 0)
     {
+        dx = *x1 - x0;
+        dy = *y1 - y0;
+
         *x1 = 0;
         if (dy)
             *y1 = ((0-x0)*dy)/dx + y0;
-        dx = *x1 - x0;
-        dy = *y1 - y0;
     }
     if (*y1 > height)
     {
+        dx = *x1 - x0;
+        dy = *y1 - y0;
+
         *y1 = height;
         if (dx)
             *x1 = ((height-y0)*dx)/dy + x0;
-        dx = *x1 - x0;
-        dy = *y1 - y0;
     }
     if (*y1 < 0)
     {
+        dx = *x1 - x0;
+        dy = *y1 - y0;
+
         *y1 = 0;
         if (dx)
             *x1 = ((0-y0)*dx)/dy + x0;
-        dx = *x1 - x0;
-        dy = *y1 - y0;
     }
 }
 
@@ -747,8 +760,16 @@ int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, int deblock_l
                     x1 = x0 + (mv->col >> 3);
                     y1 = y0 + (mv->row >> 3);
 
-                    constrain_line (x0, &x1, y0, &y1, width, height);
-                    vp8_blit_line (x0, x1, y0, y1, y_buffer, y_stride);
+                    if (x1 != x0 && y1 != y0)
+                    {
+                        constrain_line (x0, &x1, y0-1, &y1, width, height);
+                        vp8_blit_line  (x0,  x1, y0-1,  y1, y_buffer, y_stride);
+
+                        constrain_line (x0, &x1, y0+1, &y1, width, height);
+                        vp8_blit_line  (x0,  x1, y0+1,  y1, y_buffer, y_stride);
+                    }
+                    else
+                        vp8_blit_line  (x0,  x1, y0,  y1, y_buffer, y_stride);
                 }
                 mi++;
             }
@@ -779,7 +800,8 @@ int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, int deblock_l
                 U = MB_PREDICTION_MODE_colors[mi->mbmi.mode][1];
                 V = MB_PREDICTION_MODE_colors[mi->mbmi.mode][2];
 
-                vp8_blend_block_c (&y_ptr[j], &u_ptr[j>>1], &v_ptr[j>>1], Y, U, V, 0xb000, y_stride);
+                POSTPROC_INVOKE(RTCD_VTABLE(oci), blend_mb)
+                    (&y_ptr[j], &u_ptr[j>>1], &v_ptr[j>>1], Y, U, V, 0xc000, y_stride);
 
                 mi++;
             }
@@ -814,7 +836,8 @@ int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, int deblock_l
                 U = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][1];
                 V = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][2];
 
-                vp8_blend_block_c (&y_ptr[j], &u_ptr[j>>1], &v_ptr[j>>1], Y, U, V, 0xb000, y_stride);
+                POSTPROC_INVOKE(RTCD_VTABLE(oci), blend_mb)
+                    (&y_ptr[j], &u_ptr[j>>1], &v_ptr[j>>1], Y, U, V, 0xc000, y_stride);
 
                 mi++;
             }
index 80337fc689df51c3c573b51c53f0b0f09c4cfbf7..4a4493802e3f22d7b35e1409157b9526e71c0f5e 100644 (file)
               char whiteclamp[16], char bothclamp[16],\
               unsigned int w, unsigned int h, int pitch)
 
+#define prototype_postproc_blend_mb(sym)\
+    void sym (unsigned char *y, unsigned char *u, unsigned char *v,\
+              int y1, int u1, int v1, int alpha, int stride)
+
 #if ARCH_X86 || ARCH_X86_64
 #include "x86/postproc_x86.h"
 #endif
@@ -48,16 +52,22 @@ extern prototype_postproc(vp8_postproc_downacross);
 #endif
 extern prototype_postproc_addnoise(vp8_postproc_addnoise);
 
+#ifndef vp8_postproc_blend_mb
+#define vp8_postproc_blend_mb vp8_blend_mb_c
+#endif
+extern prototype_postproc_blend_mb(vp8_postproc_blend_mb);
 
 typedef prototype_postproc((*vp8_postproc_fn_t));
 typedef prototype_postproc_inplace((*vp8_postproc_inplace_fn_t));
 typedef prototype_postproc_addnoise((*vp8_postproc_addnoise_fn_t));
+typedef prototype_postproc_blend_mb((*vp8_postproc_blend_mb_fn_t));
 typedef struct
 {
     vp8_postproc_inplace_fn_t   down;
     vp8_postproc_inplace_fn_t   across;
     vp8_postproc_fn_t           downacross;
     vp8_postproc_addnoise_fn_t  addnoise;
+    vp8_postproc_blend_mb_fn_t  blend_mb;
 } vp8_postproc_rtcd_vtable_t;
 
 #if CONFIG_RUNTIME_CPU_DETECT