From: Fritz Koenig Date: Fri, 22 Oct 2010 22:41:06 +0000 (-0700) Subject: Debug option for drawing motion vectors. X-Git-Tag: 1.0_branch~840^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d1a4cce8092f0a71d4be34b1c2ea74d06dbac9d0;p=profile%2Fivi%2Flibvpx.git Debug option for drawing motion vectors. Postproc level that uses Bresenham's line algorithm to draw motion vectors onto the postproc buffer. Change-Id: I34c7daa324f2bdfee71e84fcb1c50b90fa06f6fb --- diff --git a/vp8/common/postproc.c b/vp8/common/postproc.c index 0c8cf13..df18c7c 100644 --- a/vp8/common/postproc.c +++ b/vp8/common/postproc.c @@ -76,7 +76,7 @@ const short vp8_rv[] = extern void vp8_blit_text(const char *msg, unsigned char *address, const int pitch); - +extern void vp8_blit_line(int x0, int x1, int y0, int y1, unsigned char *image, const int pitch); /*********************************************************************************************************** */ void vp8_post_proc_down_and_across_c @@ -450,6 +450,45 @@ void vp8_plane_add_noise_c(unsigned char *Start, char *noise, #define RTCD_VTABLE(oci) NULL #endif +static void constrain_line (int x0, int *x1, int y0, int *y1, int width, int height) +{ + int dx = *x1 - x0; + int dy = *y1 - y0; + + if (*x1 > width) + { + *x1 = width; + if (dy) + *y1 = ((width-x0)*dy)/dx + y0; + dx = *x1 - x0; + dy = *y1 - y0; + } + if (*x1 < 0) + { + *x1 = 0; + if (dy) + *y1 = ((0-x0)*dy)/dx + y0; + dx = *x1 - x0; + dy = *y1 - y0; + } + if (*y1 > height) + { + *y1 = height; + if (dx) + *x1 = ((height-y0)*dx)/dy + x0; + dx = *x1 - x0; + dy = *y1 - y0; + } + if (*y1 < 0) + { + *y1 = 0; + if (dx) + *x1 = ((0-y0)*dx)/dy + x0; + dx = *x1 - x0; + dy = *y1 - y0; + } +} + int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, int deblock_level, int noise_level, int flags) { char message[512]; @@ -622,8 +661,37 @@ int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, int deblock_l #endif } + else if (flags & VP8D_DEBUG_LEVEL5) + { + YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer; + int width = post->y_width; + int height = post->y_height; + int mb_cols = width >> 4; + unsigned char *y_buffer = oci->post_proc_buffer.y_buffer; + int y_stride = oci->post_proc_buffer.y_stride; + MODE_INFO *mi = oci->mi; + int x0, y0; + + for (y0 = 8; y0 < (height + 8); y0 += 16) + { + for (x0 = 8; x0 < (width + 8); x0 += 16) + { + int x1, y1; + if (mi->mbmi.mode >= NEARESTMV) + { + MV *mv = &mi->mbmi.mv.as_mv; + 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); + } + mi++; + } + mi++; + } + } *dest = oci->post_proc_buffer; diff --git a/vp8/common/ppflags.h b/vp8/common/ppflags.h index b1f925c..a1e2330 100644 --- a/vp8/common/ppflags.h +++ b/vp8/common/ppflags.h @@ -21,6 +21,7 @@ enum VP8D_DEBUG_LEVEL2 = 16, VP8D_DEBUG_LEVEL3 = 32, VP8D_DEBUG_LEVEL4 = 64, + VP8D_DEBUG_LEVEL5 = 128, }; #endif diff --git a/vp8/common/textblit.c b/vp8/common/textblit.c index da40f93..b7922d3 100644 --- a/vp8/common/textblit.c +++ b/vp8/common/textblit.c @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ - +#include void vp8_blit_text(const char *msg, unsigned char *address, const int pitch) @@ -51,3 +51,80 @@ void vp8_blit_text(const char *msg, unsigned char *address, const int pitch) colpos++; } } + +static void plot (const int x, const int y, unsigned char *image, const int pitch) +{ + image [x+y*pitch] ^= 255; +} + +// Bresenham line algorithm +void vp8_blit_line(int x0, int x1, int y0, int y1, unsigned char *image, const int pitch) +{ + int steep = abs(y1 - y0) > abs(x1 - x0); + int deltax, deltay; + int error, ystep, y, x; + + if (steep) + { + int t; + t = x0; + x0 = y0; + y0 = t; + + t = x1; + x1 = y1; + y1 = t; + } + + if (x0 > x1) + { + int t; + t = x0; + x0 = x1; + x1 = t; + + t = y0; + y0 = y1; + y1 = t; + } + + deltax = x1 - x0; + deltay = abs(y1 - y0); + error = deltax / 2; + + y = y0; + + if (y0 < y1) + ystep = 1; + else + ystep = -1; + + if (steep) + { + for (x = x0; x <= x1; x++) + { + plot(y,x, image, pitch); + + error = error - deltay; + if (error < 0) + { + y = y + ystep; + error = error + deltax; + } + } + } + else + { + for (x = x0; x <= x1; x++) + { + plot(x,y, image, pitch); + + error = error - deltay; + if (error < 0) + { + y = y + ystep; + error = error + deltax; + } + } + } +}