aboutsummaryrefslogtreecommitdiff
path: root/source/convert.cc
diff options
context:
space:
mode:
authorSergio Garcia Murillo <sergio.garcia.murillo@gmail.com>2022-12-21 08:34:00 +0100
committerlibyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-01-03 20:27:28 +0000
commitf583b1b4b82ef71eba776c3591c82227db615c75 (patch)
tree0e54e887255e06585ea42996ad14c6e6a563a002 /source/convert.cc
parent3abd6f36b6e4f5a2e0ce236580a8bc1da3c7cf7e (diff)
downloadlibyuv-f583b1b4b82ef71eba776c3591c82227db615c75.tar.gz
Add I410Copy and I410ToI420 methods
The I410To420 implementation does a two step approach for scaling down and 10-to-8 bit conversion using the Y plane as temporal storage. Bug: libyuv:950 Change-Id: I3d35fad4b99e17253230456233fbd947e013c0ec Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4110783 Commit-Queue: Frank Barchard <fbarchard@chromium.org> Reviewed-by: Frank Barchard <fbarchard@chromium.org>
Diffstat (limited to 'source/convert.cc')
-rw-r--r--source/convert.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/source/convert.cc b/source/convert.cc
index b62e513a..8b2373ec 100644
--- a/source/convert.cc
+++ b/source/convert.cc
@@ -292,6 +292,61 @@ int I210ToI422(const uint16_t* src_y,
}
LIBYUV_API
+int I410ToI420(const uint16_t* src_y,
+ int src_stride_y,
+ const uint16_t* src_u,
+ int src_stride_u,
+ const uint16_t* src_v,
+ int src_stride_v,
+ uint8_t* dst_y,
+ int dst_stride_y,
+ uint8_t* dst_u,
+ int dst_stride_u,
+ uint8_t* dst_v,
+ int dst_stride_v,
+ int width,
+ int height) {
+ const int depth = 10;
+ const int scale = 1 << (24 - depth);
+
+ if (width <= 0 || height == 0) {
+ return -1;
+ }
+ // Negative height means invert the image.
+ if (height < 0) {
+ height = -height;
+ src_y = src_y + (height - 1) * src_stride_y;
+ src_u = src_u + (height - 1) * src_stride_u;
+ src_v = src_v + (height - 1) * src_stride_v;
+ src_stride_y = -src_stride_y;
+ src_stride_u = -src_stride_u;
+ src_stride_v = -src_stride_v;
+ }
+
+ {
+ const int uv_width = SUBSAMPLE(width, 1, 1);
+ const int uv_stride = uv_width;
+ const int uv_height = SUBSAMPLE(height, 1, 1);
+
+ // Scale uv planes using Y plane as temp buffer and then convert to 8 bits.
+ ScalePlane_12(src_u, src_stride_u, width, height, (uint16_t*)dst_y,
+ uv_stride, uv_width, uv_height, kFilterBilinear);
+ Convert16To8Plane((uint16_t*)dst_y, uv_stride, dst_u, dst_stride_u, scale,
+ uv_width, uv_height);
+
+ ScalePlane_12(src_v, src_stride_v, width, height, (uint16_t*)dst_y,
+ uv_stride, uv_width, uv_height, kFilterBilinear);
+ Convert16To8Plane((uint16_t*)dst_y, uv_stride, dst_v, dst_stride_v, scale,
+ uv_width, uv_height);
+
+ // Convert Y plane last.
+ Convert16To8Plane(src_y, src_stride_y, dst_y, dst_stride_y, scale, width,
+ height);
+ }
+ return 0;
+}
+
+LIBYUV_API
int I410ToI444(const uint16_t* src_y,
int src_stride_y,
const uint16_t* src_u,