diff options
author | Frank Barchard <fbarchard@google.com> | 2017-12-28 18:12:27 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2018-01-02 21:09:39 +0000 |
commit | 2ed2402fa0b8ee98ededb5de48153926ef79a42f (patch) | |
tree | 4492125e5dcd944b63cbd9261ba7e307f0c2e4d4 /source/convert_from.cc | |
parent | 140fc0a261e6e76329f68267442177400b23827d (diff) | |
download | libyuv-2ed2402fa0b8ee98ededb5de48153926ef79a42f.tar.gz |
I420ToI010 for 8 to 10 bit YUV conversion.
Convert planar 8 bit formats to planar 16 bit formats.
Includes msan fix for Convert8To16Row_Opt unittest.
I420 is YUV bt.601 8 bits per channel with 420 subsampling.
I010 is YUV bt.601 10 bits per channel with 420 subsampling.
I is color space - bt.601. The function does no color space
conversion so H420ToI010 is aliased to this function as well.
0 = 420 subsampling. The chroma channels are half width / height.
10 = 10 bits per channel, stored in low 10 bits of 16 bit samples.
For SSSE3 version:
out/Release/libyuv_unittest --gtest_filter=*LibYUVConvertTest.I420ToI010_Opt --libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=-1 --libyuv_cpu_info=-1
[ RUN ] LibYUVConvertTest.I420ToI010_Opt
[ OK ] LibYUVConvertTest.I420ToI010_Opt (276 ms)
Bug: libyuv:751
Test: LibYUVConvertTest.I420ToI010_Opt
Change-Id: I072876ee4fd74a2b74f459b628838bc808f9bdd2
Reviewed-on: https://chromium-review.googlesource.com/846421
Reviewed-by: Miguel Casas <mcasas@chromium.org>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Diffstat (limited to 'source/convert_from.cc')
-rw-r--r-- | source/convert_from.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/source/convert_from.cc b/source/convert_from.cc index e57bb4bf..9da60710 100644 --- a/source/convert_from.cc +++ b/source/convert_from.cc @@ -65,6 +65,50 @@ static int I420ToI4xx(const uint8* src_y, return 0; } +// Convert 8 bit YUV to 10 bit. +LIBYUV_API +int I420ToI010(const uint8* src_y, + int src_stride_y, + const uint8* src_u, + int src_stride_u, + const uint8* src_v, + int src_stride_v, + uint16* dst_y, + int dst_stride_y, + uint16* dst_u, + int dst_stride_u, + uint16* dst_v, + int dst_stride_v, + int width, + int height) { + int halfwidth = (width + 1) >> 1; + int halfheight = (height + 1) >> 1; + if (!src_u || !src_v || !dst_u || !dst_v || width <= 0 || height == 0) { + return -1; + } + // Negative height means invert the image. + if (height < 0) { + height = -height; + halfheight = (height + 1) >> 1; + src_y = src_y + (height - 1) * src_stride_y; + src_u = src_u + (halfheight - 1) * src_stride_u; + src_v = src_v + (halfheight - 1) * src_stride_v; + src_stride_y = -src_stride_y; + src_stride_u = -src_stride_u; + src_stride_v = -src_stride_v; + } + + // Convert Y plane. + Convert8To16Plane(src_y, src_stride_y, dst_y, dst_stride_y, 1024, width, + height); + // Convert UV planes. + Convert8To16Plane(src_u, src_stride_u, dst_u, dst_stride_u, 1024, halfwidth, + halfheight); + Convert8To16Plane(src_v, src_stride_v, dst_v, dst_stride_v, 1024, halfwidth, + halfheight); + return 0; +} + // 420 chroma is 1/2 width, 1/2 height // 422 chroma is 1/2 width, 1x height LIBYUV_API |