summaryrefslogtreecommitdiff
path: root/vp8
diff options
context:
space:
mode:
authorFritz Koenig <frkoenig@google.com>2010-10-25 15:40:22 -0700
committerCode Review <code-review@webmproject.org>2010-10-25 15:40:22 -0700
commit1d70aaf08be0d2097c4c1ea1a8f0ab99947e11ea (patch)
tree009645ae058b489376e75eebe947e3937c9deca6 /vp8
parenta3b002fc900565b33784b3b757b01f3bb45d5894 (diff)
parentd1a4cce8092f0a71d4be34b1c2ea74d06dbac9d0 (diff)
downloadlibvpx-1d70aaf08be0d2097c4c1ea1a8f0ab99947e11ea.tar
libvpx-1d70aaf08be0d2097c4c1ea1a8f0ab99947e11ea.tar.gz
libvpx-1d70aaf08be0d2097c4c1ea1a8f0ab99947e11ea.tar.bz2
libvpx-1d70aaf08be0d2097c4c1ea1a8f0ab99947e11ea.zip
Merge "Debug option for drawing motion vectors."
Diffstat (limited to 'vp8')
-rw-r--r--vp8/common/postproc.c70
-rw-r--r--vp8/common/ppflags.h1
-rw-r--r--vp8/common/textblit.c79
3 files changed, 148 insertions, 2 deletions
diff --git a/vp8/common/postproc.c b/vp8/common/postproc.c
index 0c8cf13bf..df18c7c75 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 b1f925c44..a1e2330bb 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 da40f9352..b7922d385 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 <stdlib.h>
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;
+ }
+ }
+ }
+}