aboutsummaryrefslogtreecommitdiff
path: root/source/convert_from.cc
diff options
context:
space:
mode:
authorChong Zhang <chz@google.com>2018-08-09 11:04:12 -0700
committerFrank Barchard <fbarchard@chromium.org>2018-08-10 19:16:34 +0000
commitb6b1c273a2d9849f6f03965309b0312c62939f19 (patch)
treef1e04ca98941579af3db1952c8bd50dc1fc8f2ef /source/convert_from.cc
parentc417d5773beb330b4b54fe0f832f3ac9bedfde8b (diff)
downloadlibyuv-b6b1c273a2d9849f6f03965309b0312c62939f19.tar.gz
libyuv: choose matrix for YUV to RGB565 conversion
bug: 109762970 Change-Id: Iccfdc5dded2dc7695f8a7795b2f32b6401efea0d Reviewed-on: https://chromium-review.googlesource.com/1169687 Commit-Queue: Frank Barchard <fbarchard@chromium.org> Reviewed-by: Frank Barchard <fbarchard@chromium.org>
Diffstat (limited to 'source/convert_from.cc')
-rw-r--r--source/convert_from.cc82
1 files changed, 79 insertions, 3 deletions
diff --git a/source/convert_from.cc b/source/convert_from.cc
index cb5b4b51..0a7048c9 100644
--- a/source/convert_from.cc
+++ b/source/convert_from.cc
@@ -930,9 +930,9 @@ int I420ToARGB4444(const uint8_t* src_y,
return 0;
}
-// Convert I420 to RGB565.
+// Convert I420 to RGB565 with specified color matrix.
LIBYUV_API
-int I420ToRGB565(const uint8_t* src_y,
+int I420ToRGB565Matrix(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
@@ -940,6 +940,7 @@ int I420ToRGB565(const uint8_t* src_y,
int src_stride_v,
uint8_t* dst_rgb565,
int dst_stride_rgb565,
+ const struct YuvConstants* yuvconstants,
int width,
int height) {
int y;
@@ -990,7 +991,7 @@ int I420ToRGB565(const uint8_t* src_y,
#endif
for (y = 0; y < height; ++y) {
- I422ToRGB565Row(src_y, src_u, src_v, dst_rgb565, &kYuvI601Constants, width);
+ I422ToRGB565Row(src_y, src_u, src_v, dst_rgb565, yuvconstants, width);
dst_rgb565 += dst_stride_rgb565;
src_y += src_stride_y;
if (y & 1) {
@@ -1001,6 +1002,81 @@ int I420ToRGB565(const uint8_t* src_y,
return 0;
}
+// Convert I420 to RGB565.
+LIBYUV_API
+int I420ToRGB565(const uint8_t* src_y,
+ int src_stride_y,
+ const uint8_t* src_u,
+ int src_stride_u,
+ const uint8_t* src_v,
+ int src_stride_v,
+ uint8_t* dst_rgb565,
+ int dst_stride_rgb565,
+ int width,
+ int height) {
+ return I420ToRGB565Matrix(src_y,
+ src_stride_y,
+ src_u,
+ src_stride_u,
+ src_v,
+ src_stride_v,
+ dst_rgb565,
+ dst_stride_rgb565,
+ &kYuvI601Constants,
+ width,
+ height);
+}
+
+// Convert J420 to RGB565.
+LIBYUV_API
+int J420ToRGB565(const uint8_t* src_y,
+ int src_stride_y,
+ const uint8_t* src_u,
+ int src_stride_u,
+ const uint8_t* src_v,
+ int src_stride_v,
+ uint8_t* dst_rgb565,
+ int dst_stride_rgb565,
+ int width,
+ int height) {
+ return I420ToRGB565Matrix(src_y,
+ src_stride_y,
+ src_u,
+ src_stride_u,
+ src_v,
+ src_stride_v,
+ dst_rgb565,
+ dst_stride_rgb565,
+ &kYuvJPEGConstants,
+ width,
+ height);
+}
+
+// Convert H420 to RGB565.
+LIBYUV_API
+int H420ToRGB565(const uint8_t* src_y,
+ int src_stride_y,
+ const uint8_t* src_u,
+ int src_stride_u,
+ const uint8_t* src_v,
+ int src_stride_v,
+ uint8_t* dst_rgb565,
+ int dst_stride_rgb565,
+ int width,
+ int height) {
+ return I420ToRGB565Matrix(src_y,
+ src_stride_y,
+ src_u,
+ src_stride_u,
+ src_v,
+ src_stride_v,
+ dst_rgb565,
+ dst_stride_rgb565,
+ &kYuvH709Constants,
+ width,
+ height);
+}
+
// Convert I422 to RGB565.
LIBYUV_API
int I422ToRGB565(const uint8_t* src_y,