diff options
author | Frank Barchard <fbarchard@chromium.org> | 2022-06-07 09:06:38 +0000 |
---|---|---|
committer | libyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-06-07 09:16:05 +0000 |
commit | d011314f14738e0751dcb269c1d989c4dcbaad7b (patch) | |
tree | ba4ac530c7714d19e51bd8490da51c9ad2f9bb87 /source/planar_functions.cc | |
parent | 60254a1d846a93a4d7559009004cdd91bcc04d82 (diff) | |
download | libyuv-d011314f14738e0751dcb269c1d989c4dcbaad7b.tar.gz |
Revert "I210ToI420, InterpolatePlane_16, and ScalePlane Vertical-only asan fix"
This reverts commit 60254a1d846a93a4d7559009004cdd91bcc04d82.
Reason for revert: breaks PaintCanvasVideoRendererTest.HighBitDepth
Original change's description:
> I210ToI420, InterpolatePlane_16, and ScalePlane Vertical-only asan fix
>
> - Add I210ToI420 to convert 10 bit 4:2:2 YUV to 4:2:0 8 bit
> - Add NEON InterpolateRow_16 for fast 10 bit scaling
> - When scaling up, set step to interpolate toward height - 1 to avoid buffer overread
> - When scaling down, center the 2 rows used for source to achieve filtering.
> - CopyPlane check for 0 size and return
>
> Bug: libyuv:931, b/228605787, b/233233302, b/233634772, b/234558395, b/234340482
> Change-Id: I63e8580710a57812b683c2fe40583ac5a179c4f1
> Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/3687552
> Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
> Reviewed-by: richard winterton <rrwinterton@gmail.com>
Bug: libyuv:931, b/228605787, b/233233302, b/233634772, b/234558395, b/234340482
Change-Id: Icc05bb340db0e7fe864061fb501d0a861c764116
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/3692886
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
Commit-Queue: Mirko Bonadei <mbonadei@chromium.org>
Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
Diffstat (limited to 'source/planar_functions.cc')
-rw-r--r-- | source/planar_functions.cc | 159 |
1 files changed, 33 insertions, 126 deletions
diff --git a/source/planar_functions.cc b/source/planar_functions.cc index b5344862..141db6ef 100644 --- a/source/planar_functions.cc +++ b/source/planar_functions.cc @@ -35,7 +35,7 @@ void CopyPlane(const uint8_t* src_y, int height) { int y; void (*CopyRow)(const uint8_t* src, uint8_t* dst, int width) = CopyRow_C; - if (width <= 0 || height == 0) { + if (width == 0 || height == 0) { return; } // Negative height means invert the image. @@ -84,6 +84,8 @@ void CopyPlane(const uint8_t* src_y, } } +// TODO(fbarchard): Consider support for negative height. +// TODO(fbarchard): Consider stride measured in bytes. LIBYUV_API void CopyPlane_16(const uint16_t* src_y, int src_stride_y, @@ -91,8 +93,36 @@ void CopyPlane_16(const uint16_t* src_y, int dst_stride_y, int width, int height) { - CopyPlane((const uint8_t*)src_y, src_stride_y * 2, (uint8_t*)dst_y, - dst_stride_y * 2, width * 2, height); + int y; + void (*CopyRow)(const uint16_t* src, uint16_t* dst, int width) = CopyRow_16_C; + // Coalesce rows. + if (src_stride_y == width && dst_stride_y == width) { + width *= height; + height = 1; + src_stride_y = dst_stride_y = 0; + } +#if defined(HAS_COPYROW_16_SSE2) + if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 32)) { + CopyRow = CopyRow_16_SSE2; + } +#endif +#if defined(HAS_COPYROW_16_ERMS) + if (TestCpuFlag(kCpuHasERMS)) { + CopyRow = CopyRow_16_ERMS; + } +#endif +#if defined(HAS_COPYROW_16_NEON) + if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 32)) { + CopyRow = CopyRow_16_NEON; + } +#endif + + // Copy plane + for (y = 0; y < height; ++y) { + CopyRow(src_y, dst_y, width); + src_y += src_stride_y; + dst_y += dst_stride_y; + } } // Convert a plane of 16 bit data to 8 bit @@ -108,9 +138,6 @@ void Convert16To8Plane(const uint16_t* src_y, void (*Convert16To8Row)(const uint16_t* src_y, uint8_t* dst_y, int scale, int width) = Convert16To8Row_C; - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -169,9 +196,6 @@ void Convert8To16Plane(const uint8_t* src_y, void (*Convert8To16Row)(const uint8_t* src_y, uint16_t* dst_y, int scale, int width) = Convert8To16Row_C; - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -446,9 +470,6 @@ void SplitUVPlane(const uint8_t* src_uv, int y; void (*SplitUVRow)(const uint8_t* src_uv, uint8_t* dst_u, uint8_t* dst_v, int width) = SplitUVRow_C; - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -526,9 +547,6 @@ void MergeUVPlane(const uint8_t* src_u, int y; void (*MergeUVRow)(const uint8_t* src_u, const uint8_t* src_v, uint8_t* dst_uv, int width) = MergeUVRow_C; - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -608,9 +626,6 @@ void SplitUVPlane_16(const uint16_t* src_uv, void (*SplitUVRow_16)(const uint16_t* src_uv, uint16_t* dst_u, uint16_t* dst_v, int depth, int width) = SplitUVRow_16_C; - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -668,9 +683,6 @@ void MergeUVPlane_16(const uint16_t* src_u, MergeUVRow_16_C; assert(depth >= 8); assert(depth <= 16); - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -723,9 +735,6 @@ void ConvertToMSBPlane_16(const uint16_t* src_y, int scale = 1 << (16 - depth); void (*MultiplyRow_16)(const uint16_t* src_y, uint16_t* dst_y, int scale, int width) = MultiplyRow_16_C; - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -776,9 +785,6 @@ void ConvertToLSBPlane_16(const uint16_t* src_y, int scale = 1 << depth; void (*DivideRow)(const uint16_t* src_y, uint16_t* dst_y, int scale, int width) = DivideRow_16_C; - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -827,9 +833,6 @@ void SwapUVPlane(const uint8_t* src_uv, int y; void (*SwapUVRow)(const uint8_t* src_uv, uint8_t* dst_vu, int width) = SwapUVRow_C; - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -933,9 +936,6 @@ void DetilePlane(const uint8_t* src_y, assert(tile_height > 0); assert(src_stride_y > 0); - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -991,9 +991,6 @@ void DetileSplitUVPlane(const uint8_t* src_uv, assert(tile_height > 0); assert(src_stride_uv > 0); - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -1049,9 +1046,6 @@ void SplitRGBPlane(const uint8_t* src_rgb, int y; void (*SplitRGBRow)(const uint8_t* src_rgb, uint8_t* dst_r, uint8_t* dst_g, uint8_t* dst_b, int width) = SplitRGBRow_C; - if (width <= 0 || height == 0) { - return; - } // Negative height means invert the image. if (height < 0) { height = -height; @@ -1111,9 +1105,6 @@ void MergeRGBPlane(const uint8_t* src_r, void (*MergeRGBRow)(const uint8_t* src_r, const uint8_t* src_g, const uint8_t* src_b, uint8_t* dst_rgb, int width) = MergeRGBRow_C; - if (width <= 0 || height == 0) { - return; - } // Coalesce rows. // Negative height means invert the image. if (height < 0) { @@ -3068,10 +3059,6 @@ void SetPlane(uint8_t* dst_y, uint32_t value) { int y; void (*SetRow)(uint8_t * dst, uint8_t value, int width) = SetRow_C; - - if (width <= 0 || height == 0) { - return; - } if (height < 0) { height = -height; dst_y = dst_y + (height - 1) * dst_stride_y; @@ -4018,86 +4005,6 @@ int InterpolatePlane(const uint8_t* src0, return 0; } -// Interpolate 2 planes by specified amount (0 to 255). -LIBYUV_API -int InterpolatePlane_16(const uint16_t* src0, - int src_stride0, - const uint16_t* src1, - int src_stride1, - uint16_t* dst, - int dst_stride, - int width, - int height, - int interpolation) { - int y; - void (*InterpolateRow_16)(uint16_t * dst_ptr, const uint16_t* src_ptr, - ptrdiff_t src_stride, int dst_width, - int source_y_fraction) = InterpolateRow_16_C; - if (!src0 || !src1 || !dst || width <= 0 || height == 0) { - return -1; - } - // Negative height means invert the image. - if (height < 0) { - height = -height; - dst = dst + (height - 1) * dst_stride; - dst_stride = -dst_stride; - } - // Coalesce rows. - if (src_stride0 == width && src_stride1 == width && dst_stride == width) { - width *= height; - height = 1; - src_stride0 = src_stride1 = dst_stride = 0; - } -#if defined(HAS_INTERPOLATEROW_16_SSSE3) - if (TestCpuFlag(kCpuHasSSSE3)) { - InterpolateRow_16 = InterpolateRow_16_Any_SSSE3; - if (IS_ALIGNED(width, 16)) { - InterpolateRow_16 = InterpolateRow_16_SSSE3; - } - } -#endif -#if defined(HAS_INTERPOLATEROW_16_AVX2) - if (TestCpuFlag(kCpuHasAVX2)) { - InterpolateRow_16 = InterpolateRow_16_Any_AVX2; - if (IS_ALIGNED(width, 32)) { - InterpolateRow_16 = InterpolateRow_16_AVX2; - } - } -#endif -#if defined(HAS_INTERPOLATEROW_16_NEON) - if (TestCpuFlag(kCpuHasNEON)) { - InterpolateRow_16 = InterpolateRow_16_Any_NEON; - if (IS_ALIGNED(width, 8)) { - InterpolateRow_16 = InterpolateRow_16_NEON; - } - } -#endif -#if defined(HAS_INTERPOLATEROW_16_MSA) - if (TestCpuFlag(kCpuHasMSA)) { - InterpolateRow_16 = InterpolateRow_16_Any_MSA; - if (IS_ALIGNED(width, 32)) { - InterpolateRow_16 = InterpolateRow_16_MSA; - } - } -#endif -#if defined(HAS_INTERPOLATEROW_16_LSX) - if (TestCpuFlag(kCpuHasLSX)) { - InterpolateRow_16 = InterpolateRow_16_Any_LSX; - if (IS_ALIGNED(width, 32)) { - InterpolateRow_16 = InterpolateRow_16_LSX; - } - } -#endif - - for (y = 0; y < height; ++y) { - InterpolateRow_16(dst, src0, src1 - src0, width, interpolation); - src0 += src_stride0; - src1 += src_stride1; - dst += dst_stride; - } - return 0; -} - // Interpolate 2 ARGB images by specified amount (0 to 255). LIBYUV_API int ARGBInterpolate(const uint8_t* src_argb0, |