diff options
-rw-r--r-- | vp8/common/postproc.c | 138 | ||||
-rw-r--r-- | vp8/common/ppflags.h | 18 |
2 files changed, 143 insertions, 13 deletions
diff --git a/vp8/common/postproc.c b/vp8/common/postproc.c index df18c7c75..9c0ab75a7 100644 --- a/vp8/common/postproc.c +++ b/vp8/common/postproc.c @@ -19,8 +19,36 @@ #include <math.h> #include <stdlib.h> #include <stdio.h> + +#define RGB_TO_YUV(t) \ + ( (0.257*(float)(t>>16)) + (0.504*(float)(t>>8&0xff)) + (0.098*(float)(t&0xff)) + 16), \ + (-(0.148*(float)(t>>16)) - (0.291*(float)(t>>8&0xff)) + (0.439*(float)(t&0xff)) + 128), \ + ( (0.439*(float)(t>>16)) - (0.368*(float)(t>>8&0xff)) - (0.071*(float)(t&0xff)) + 128) + // global constants +static const unsigned char MB_PREDICTION_MODE_colors[MB_MODE_COUNT][3] = +{ + { RGB_TO_YUV(0x98FB98) }, // PaleGreen + { RGB_TO_YUV(0x00FF00) }, // Green + { RGB_TO_YUV(0xADFF2F) }, // GreenYellow + { RGB_TO_YUV(0x228B22) }, // ForestGreen + { RGB_TO_YUV(0x006400) }, // DarkGreen + { RGB_TO_YUV(0x98F5FF) }, // Cadet Blue + { RGB_TO_YUV(0x6CA6CD) }, // Sky Blue + { RGB_TO_YUV(0x00008B) }, // Dark blue + { RGB_TO_YUV(0x551A8B) }, // Purple + { RGB_TO_YUV(0xFF0000) } // Red +}; + +static const unsigned char MV_REFERENCE_FRAME_colors[MB_MODE_COUNT][3] = +{ + { RGB_TO_YUV(0x00ff00) }, // Blue + { RGB_TO_YUV(0x0000ff) }, // Green + { RGB_TO_YUV(0xffff00) }, // Yellow + { RGB_TO_YUV(0xff0000) }, // Red +}; + static const short kernel5[] = { 1, 1, 4, 1, 1 @@ -444,11 +472,34 @@ void vp8_plane_add_noise_c(unsigned char *Start, char *noise, } } -#if CONFIG_RUNTIME_CPU_DETECT -#define RTCD_VTABLE(oci) (&(oci)->rtcd.postproc) -#else -#define RTCD_VTABLE(oci) NULL -#endif +void vp8_blend_block_c (unsigned char *y, unsigned char *u, unsigned char *v, + int y1, int u1, int v1, int alpha, int stride) +{ + int i, j; + int y1_const = y1*((1<<16)-alpha); + int u1_const = u1*((1<<16)-alpha); + int v1_const = v1*((1<<16)-alpha); + + for (i = 0; i < 16; i++) + { + for (j = 0; j < 16; j++) + { + y[j] = (y[j]*alpha + y1_const)>>16; + } + y += stride; + } + + for (i = 0; i < 8; i++) + { + for (j = 0; j < 8; j++) + { + u[j] = (u[j]*alpha + u1_const)>>16; + v[j] = (v[j]*alpha + v1_const)>>16; + } + u += stride/2; + v += stride/2; + } +} static void constrain_line (int x0, int *x1, int y0, int *y1, int width, int height) { @@ -489,6 +540,13 @@ static void constrain_line (int x0, int *x1, int y0, int *y1, int width, int hei } } + +#if CONFIG_RUNTIME_CPU_DETECT +#define RTCD_VTABLE(oci) (&(oci)->rtcd.postproc) +#else +#define RTCD_VTABLE(oci) NULL +#endif + int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, int deblock_level, int noise_level, int flags) { char message[512]; @@ -693,6 +751,76 @@ int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, int deblock_l } } + // Color in block modes + else if (flags & VP8D_DEBUG_LEVEL6) + { + int i, j; + YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer; + int width = post->y_width; + int height = post->y_height; + unsigned char *y_ptr = oci->post_proc_buffer.y_buffer; + unsigned char *u_ptr = oci->post_proc_buffer.u_buffer; + unsigned char *v_ptr = oci->post_proc_buffer.v_buffer; + int y_stride = oci->post_proc_buffer.y_stride; + MODE_INFO *mi = oci->mi; + + for (i = 0; i < height; i += 16) + { + for (j = 0; j < width; j += 16) + { + int Y = 0, U = 0, V = 0; + + Y = MB_PREDICTION_MODE_colors[mi->mbmi.mode][0]; + 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); + + mi++; + } + y_ptr += y_stride*16; + u_ptr += y_stride*4; + v_ptr += y_stride*4; + + mi++; + } + } + + // Color in frame reference blocks + else if (flags & VP8D_DEBUG_LEVEL7) + { + int i, j; + YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer; + int width = post->y_width; + int height = post->y_height; + unsigned char *y_ptr = oci->post_proc_buffer.y_buffer; + unsigned char *u_ptr = oci->post_proc_buffer.u_buffer; + unsigned char *v_ptr = oci->post_proc_buffer.v_buffer; + int y_stride = oci->post_proc_buffer.y_stride; + MODE_INFO *mi = oci->mi; + + for (i = 0; i < height; i += 16) + { + for (j = 0; j < width; j +=16) + { + int Y = 0, U = 0, V = 0; + + Y = MV_REFERENCE_FRAME_colors[mi->mbmi.ref_frame][0]; + 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); + + mi++; + } + y_ptr += y_stride*16; + u_ptr += y_stride*4; + v_ptr += y_stride*4; + + mi++; + } + } + *dest = oci->post_proc_buffer; // handle problem with extending borders diff --git a/vp8/common/ppflags.h b/vp8/common/ppflags.h index a1e2330bb..651671a43 100644 --- a/vp8/common/ppflags.h +++ b/vp8/common/ppflags.h @@ -14,14 +14,16 @@ enum { VP8D_NOFILTERING = 0, - VP8D_DEBLOCK = 1, - VP8D_DEMACROBLOCK = 2, - VP8D_ADDNOISE = 4, - VP8D_DEBUG_LEVEL1 = 8, - VP8D_DEBUG_LEVEL2 = 16, - VP8D_DEBUG_LEVEL3 = 32, - VP8D_DEBUG_LEVEL4 = 64, - VP8D_DEBUG_LEVEL5 = 128, + VP8D_DEBLOCK = 1<<0, + VP8D_DEMACROBLOCK = 1<<1, + VP8D_ADDNOISE = 1<<2, + VP8D_DEBUG_LEVEL1 = 1<<3, + VP8D_DEBUG_LEVEL2 = 1<<4, + VP8D_DEBUG_LEVEL3 = 1<<5, + VP8D_DEBUG_LEVEL4 = 1<<6, + VP8D_DEBUG_LEVEL5 = 1<<7, + VP8D_DEBUG_LEVEL6 = 1<<8, + VP8D_DEBUG_LEVEL7 = 1<<9, }; #endif |