ref: d1a4cce8092f0a71d4be34b1c2ea74d06dbac9d0
parent: 3b9e72b210eb4c8b86b1fecf5e89c49bfd4800da
author: Fritz Koenig <frkoenig@google.com>
date: Fri Oct 22 11:41:06 EDT 2010
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
--- a/vp8/common/postproc.c
+++ b/vp8/common/postproc.c
@@ -76,7 +76,7 @@
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 @@
#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 @@
#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;
--- a/vp8/common/ppflags.h
+++ b/vp8/common/ppflags.h
@@ -21,6 +21,7 @@
VP8D_DEBUG_LEVEL2 = 16,
VP8D_DEBUG_LEVEL3 = 32,
VP8D_DEBUG_LEVEL4 = 64,
+ VP8D_DEBUG_LEVEL5 = 128,
};
#endif
--- a/vp8/common/textblit.c
+++ b/vp8/common/textblit.c
@@ -8,9 +8,9 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include <stdlib.h>
-
void vp8_blit_text(const char *msg, unsigned char *address, const int pitch)
{
int letter_bitmap;
@@ -49,5 +49,82 @@
output_pos += 7;
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;
+ }
+ }
}
}