summaryrefslogtreecommitdiff
path: root/libkmstest
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@iki.fi>2015-10-08 22:17:00 +0300
committerTomi Valkeinen <tomi.valkeinen@iki.fi>2015-10-08 22:17:00 +0300
commite48cd1b64b3980a7e3c78c406e8bfd309ade2f51 (patch)
tree636d5d0320ab6270cde33cdf75f07beb6fa5b60d /libkmstest
parente689ae60dafcc5db6a7266906f38410f0d6f3e24 (diff)
testpat: cleanup and fix drawing yuv pixels
Diffstat (limited to 'libkmstest')
-rw-r--r--libkmstest/testpat.cpp46
1 files changed, 28 insertions, 18 deletions
diff --git a/libkmstest/testpat.cpp b/libkmstest/testpat.cpp
index 5c67660..f65a1f8 100644
--- a/libkmstest/testpat.cpp
+++ b/libkmstest/testpat.cpp
@@ -18,8 +18,6 @@ namespace kms
{
static void draw_pixel(DumbFramebuffer& buf, unsigned x, unsigned y, RGB color)
{
- static RGB c1;
-
switch (buf.format()) {
case PixelFormat::XRGB8888:
{
@@ -44,43 +42,55 @@ static void draw_pixel(DumbFramebuffer& buf, unsigned x, unsigned y, RGB color)
case PixelFormat::YVYU:
case PixelFormat::VYUY:
{
+ // HACK. we store the even pixels to c1, and only draw when at the odd pixel.
+
+ static RGB c1;
+
if ((x & 1) == 0) {
c1 = color;
return;
}
+ // adjust X back to the even pixel
+ x--;
+
uint8_t *p = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
YUV yuv1 = c1.yuv();
YUV yuv2 = color.yuv();
+ uint8_t y0 = yuv1.y;
+ uint8_t y1 = yuv2.y;
+ uint8_t u = (yuv1.u + yuv2.u) / 2;
+ uint8_t v = (yuv1.v + yuv2.v) / 2;
+
switch (buf.format()) {
case PixelFormat::UYVY:
- p[0] = (yuv1.u + yuv2.u) / 2;
- p[1] = yuv1.y;
- p[2] = (yuv1.v + yuv2.v) / 2;
- p[3] = yuv2.y;
+ p[0] = u;
+ p[1] = y0;
+ p[2] = v;
+ p[3] = y1;
break;
case PixelFormat::YUYV:
- p[0] = yuv1.y;
- p[1] = (yuv1.u + yuv2.u) / 2;
- p[2] = yuv2.y;
- p[3] = (yuv1.v + yuv2.v) / 2;
+ p[0] = y0;
+ p[1] = u;
+ p[2] = y1;
+ p[3] = v;
break;
case PixelFormat::YVYU:
- p[0] = yuv1.y;
- p[1] = (yuv1.v + yuv2.v) / 2;
- p[2] = yuv2.y;
- p[3] = (yuv1.u + yuv2.u) / 2;
+ p[0] = y0;
+ p[1] = v;
+ p[2] = y1;
+ p[3] = u;
break;
case PixelFormat::VYUY:
- p[0] = (yuv1.v + yuv2.v) / 2;
- p[1] = yuv1.y;
- p[2] = (yuv1.u + yuv2.u) / 2;
- p[3] = yuv2.y;
+ p[0] = v;
+ p[1] = y0;
+ p[2] = u;
+ p[3] = y1;
break;
default:
break;