Merge pie-platform-release to aosp-master - DO NOT MERGE

Change-Id: I74559e5cfdc3dc3d45ca1a1a8a434ebac95a7bd4
diff --git a/files/include/libyuv/convert_from.h b/files/include/libyuv/convert_from.h
index a050e44..528d8dd 100644
--- a/files/include/libyuv/convert_from.h
+++ b/files/include/libyuv/convert_from.h
@@ -201,6 +201,30 @@
                  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,
                  const uint8* src_u,
diff --git a/files/source/convert_from.cc b/files/source/convert_from.cc
index d623731..e0ebfb0 100644
--- a/files/source/convert_from.cc
+++ b/files/source/convert_from.cc
@@ -819,9 +819,9 @@
   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 src_stride_v,
                  uint8* dst_rgb565,
                  int dst_stride_rgb565,
+                 const struct YuvConstants* yuvconstants,
                  int width,
                  int height) {
   int y;
@@ -879,7 +880,7 @@
 #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 @@
   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,