From a097e189641fcbbecc92661e2c87019845dc7b00 Mon Sep 17 00:00:00 2001 From: Fritz Koenig Date: Wed, 27 Oct 2010 12:50:16 -0700 Subject: [PATCH] postproc: Tweaks to line drawing and blending. 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: Id3ef0fdeeab2949a6664b2c63e2a3e1a89503f6c --- vp8/common/generic/systemdependent.c | 1 + vp8/common/postproc.c | 65 +++++++++++++++++++--------- vp8/common/postproc.h | 10 +++++ 3 files changed, 55 insertions(+), 21 deletions(-) diff --git a/vp8/common/generic/systemdependent.c b/vp8/common/generic/systemdependent.c index 0c9b77e76..c624242a5 100644 --- a/vp8/common/generic/systemdependent.c +++ b/vp8/common/generic/systemdependent.c @@ -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 diff --git a/vp8/common/postproc.c b/vp8/common/postproc.c index 21e08638d..42e37da30 100644 --- a/vp8/common/postproc.c +++ b/vp8/common/postproc.c @@ -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++; } diff --git a/vp8/common/postproc.h b/vp8/common/postproc.h index 80337fc68..4a4493802 100644 --- a/vp8/common/postproc.h +++ b/vp8/common/postproc.h @@ -24,6 +24,10 @@ 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 -- 2.40.0