diff options
author | Tomi Valkeinen <tomi.valkeinen@iki.fi> | 2015-10-08 19:12:24 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@iki.fi> | 2015-10-08 19:12:24 +0300 |
commit | e689ae60dafcc5db6a7266906f38410f0d6f3e24 (patch) | |
tree | 85f7107d058753c8dffc9ecc44f2a9de5839db09 /libkmstest | |
parent | 4a6bfde6cd19e9a7b98491761cfbfc491660cd89 (diff) |
Add support for YVYU and VYUY
Diffstat (limited to 'libkmstest')
-rw-r--r-- | libkmstest/testpat.cpp | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/libkmstest/testpat.cpp b/libkmstest/testpat.cpp index f621b91..5c67660 100644 --- a/libkmstest/testpat.cpp +++ b/libkmstest/testpat.cpp @@ -40,6 +40,9 @@ static void draw_pixel(DumbFramebuffer& buf, unsigned x, unsigned y, RGB color) break; } case PixelFormat::UYVY: + case PixelFormat::YUYV: + case PixelFormat::YVYU: + case PixelFormat::VYUY: { if ((x & 1) == 0) { c1 = color; @@ -51,28 +54,38 @@ static void draw_pixel(DumbFramebuffer& buf, unsigned x, unsigned y, RGB color) YUV yuv1 = c1.yuv(); YUV yuv2 = color.yuv(); - p[0] = (yuv1.u + yuv2.u) / 2; - p[1] = yuv1.y; - p[2] = (yuv1.v + yuv2.v) / 2; - p[3] = yuv2.y; - break; - } - case PixelFormat::YUYV: - { - if ((x & 1) == 0) { - c1 = color; - return; + 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; + 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; + 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; + 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; + break; + default: + break; } - uint8_t *p = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x * 2); - - YUV yuv1 = c1.yuv(); - YUV yuv2 = color.yuv(); - - p[0] = yuv1.y; - p[1] = (yuv1.u + yuv2.u) / 2; - p[2] = yuv2.y; - p[3] = (yuv1.v + yuv2.v) / 2; break; } default: |