Merge "postproc: Tweaks to line drawing and blending."

This commit is contained in:
Fritz Koenig 2010-10-27 13:20:56 -07:00 коммит произвёл Code Review
Родитель f26fe7d93b a097e18964
Коммит 2b4913eb0d
3 изменённых файлов: 55 добавлений и 21 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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++;
}

Просмотреть файл

@ -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