From 58eae5dfed3d36aa439b08f0a2e536f0681a5e75 Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Fri, 17 Aug 2018 12:35:12 -0700 Subject: libyuv: choose matrix for YUV to RGB565 conversion (cherry-picked from upstream: https://chromium-review.googlesource.com/1169687) bug: 109762970 Change-Id: Ia88c9cd30679a1888c991c4cbd26b6c8ca35acd8 --- files/include/libyuv/convert_from.h | 24 +++++++++++ files/source/convert_from.cc | 82 +++++++++++++++++++++++++++++++++++-- 2 files changed, 103 insertions(+), 3 deletions(-) diff --git a/files/include/libyuv/convert_from.h b/files/include/libyuv/convert_from.h index a050e445..528d8dda 100644 --- a/files/include/libyuv/convert_from.h +++ b/files/include/libyuv/convert_from.h @@ -200,6 +200,30 @@ int I420ToRGB565(const uint8* src_y, int width, int height); +LIBYUV_API +int J420ToRGB565(const uint8* src_y, + int src_stride_y, + const uint8* src_u, + int src_stride_u, + const uint8* src_v, + int src_stride_v, + uint8* dst_frame, + int dst_stride_frame, + int width, + int height); + +LIBYUV_API +int H420ToRGB565(const uint8* src_y, + int src_stride_y, + const uint8* src_u, + int src_stride_u, + const uint8* src_v, + int src_stride_v, + uint8* dst_frame, + int dst_stride_frame, + int width, + int height); + LIBYUV_API int I422ToRGB565(const uint8* src_y, int src_stride_y, diff --git a/files/source/convert_from.cc b/files/source/convert_from.cc index d623731d..e0ebfb08 100644 --- a/files/source/convert_from.cc +++ b/files/source/convert_from.cc @@ -819,9 +819,9 @@ int I420ToARGB4444(const uint8* src_y, return 0; } -// Convert I420 to RGB565. +// Convert I420 to RGB565 with specified color matrix. LIBYUV_API -int I420ToRGB565(const uint8* src_y, +int I420ToRGB565Matrix(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, @@ -829,6 +829,7 @@ int I420ToRGB565(const uint8* src_y, int src_stride_v, uint8* dst_rgb565, int dst_stride_rgb565, + const struct YuvConstants* yuvconstants, int width, int height) { int y; @@ -879,7 +880,7 @@ int I420ToRGB565(const uint8* 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) { @@ -890,6 +891,81 @@ int I420ToRGB565(const uint8* src_y, return 0; } +// Convert I420 to RGB565. +LIBYUV_API +int I420ToRGB565(const uint8* src_y, + int src_stride_y, + const uint8* src_u, + int src_stride_u, + const uint8* src_v, + int src_stride_v, + uint8* 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* src_y, + int src_stride_y, + const uint8* src_u, + int src_stride_u, + const uint8* src_v, + int src_stride_v, + uint8* 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* src_y, + int src_stride_y, + const uint8* src_u, + int src_stride_u, + const uint8* src_v, + int src_stride_v, + uint8* 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* src_y, -- cgit v1.2.3