aboutsummaryrefslogtreecommitdiff
path: root/source/scale_common.cc
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@chromium.org>2022-06-07 09:06:38 +0000
committerlibyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-06-07 09:16:05 +0000
commitd011314f14738e0751dcb269c1d989c4dcbaad7b (patch)
treeba4ac530c7714d19e51bd8490da51c9ad2f9bb87 /source/scale_common.cc
parent60254a1d846a93a4d7559009004cdd91bcc04d82 (diff)
downloadlibyuv-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/scale_common.cc')
-rw-r--r--source/scale_common.cc69
1 files changed, 13 insertions, 56 deletions
diff --git a/source/scale_common.cc b/source/scale_common.cc
index e0c821c2..d54ab942 100644
--- a/source/scale_common.cc
+++ b/source/scale_common.cc
@@ -1533,7 +1533,6 @@ void ScalePlaneVertical(int src_height,
y += dy;
}
}
-
void ScalePlaneVertical_16(int src_height,
int dst_width,
int dst_height,
@@ -1544,7 +1543,7 @@ void ScalePlaneVertical_16(int src_height,
int x,
int y,
int dy,
- int wpp, /* words per pixel. normally 1 */
+ int wpp,
enum FilterMode filtering) {
// TODO(fbarchard): Allow higher wpp.
int dst_width_words = dst_width * wpp;
@@ -1560,32 +1559,32 @@ void ScalePlaneVertical_16(int src_height,
src_argb += (x >> 16) * wpp;
#if defined(HAS_INTERPOLATEROW_16_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
- InterpolateRow = InterpolateRow_16_Any_SSE2;
- if (IS_ALIGNED(dst_width_words, 16)) {
+ InterpolateRow = InterpolateRow_Any_16_SSE2;
+ if (IS_ALIGNED(dst_width_bytes, 16)) {
InterpolateRow = InterpolateRow_16_SSE2;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_16_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
- InterpolateRow = InterpolateRow_16_Any_SSSE3;
- if (IS_ALIGNED(dst_width_words, 16)) {
+ InterpolateRow = InterpolateRow_Any_16_SSSE3;
+ if (IS_ALIGNED(dst_width_bytes, 16)) {
InterpolateRow = InterpolateRow_16_SSSE3;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_16_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
- InterpolateRow = InterpolateRow_16_Any_AVX2;
- if (IS_ALIGNED(dst_width_words, 32)) {
+ InterpolateRow = InterpolateRow_Any_16_AVX2;
+ if (IS_ALIGNED(dst_width_bytes, 32)) {
InterpolateRow = InterpolateRow_16_AVX2;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_16_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
- InterpolateRow = InterpolateRow_16_Any_NEON;
- if (IS_ALIGNED(dst_width_words, 8)) {
+ InterpolateRow = InterpolateRow_Any_16_NEON;
+ if (IS_ALIGNED(dst_width_bytes, 16)) {
InterpolateRow = InterpolateRow_16_NEON;
}
}
@@ -1605,48 +1604,6 @@ void ScalePlaneVertical_16(int src_height,
}
}
-void ScalePlaneVertical_16To8(int src_height,
- int dst_width,
- int dst_height,
- int src_stride,
- int dst_stride,
- const uint16_t* src_argb,
- uint8_t* dst_argb,
- int x,
- int y,
- int dy,
- int wpp, /* words per pixel. normally 1 */
- int scale,
- enum FilterMode filtering) {
- // TODO(fbarchard): Allow higher wpp.
- int dst_width_words = dst_width * wpp;
- // TODO(https://crbug.com/libyuv/931): Add NEON and AVX2 versions.
- void (*InterpolateRow_16To8)(uint8_t * dst_argb, const uint16_t* src_argb,
- ptrdiff_t src_stride, int scale, int dst_width,
- int source_y_fraction) = InterpolateRow_16To8_C;
- const int max_y = (src_height > 1) ? ((src_height - 1) << 16) - 1 : 0;
- int j;
- assert(wpp >= 1 && wpp <= 2);
- assert(src_height != 0);
- assert(dst_width > 0);
- assert(dst_height > 0);
- src_argb += (x >> 16) * wpp;
-
- for (j = 0; j < dst_height; ++j) {
- int yi;
- int yf;
- if (y > max_y) {
- y = max_y;
- }
- yi = y >> 16;
- yf = filtering ? ((y >> 8) & 255) : 0;
- InterpolateRow_16To8(dst_argb, src_argb + yi * src_stride, src_stride,
- scale, dst_width_words, yf);
- dst_argb += dst_stride;
- y += dy;
- }
-}
-
// Simplify the filtering based on scale factors.
enum FilterMode ScaleFilterReduce(int src_width,
int src_height,
@@ -1696,7 +1653,7 @@ int FixedDiv_C(int num, int div) {
return (int)(((int64_t)(num) << 16) / div);
}
-// Divide num - 1 by div - 1 and return as 16.16 fixed point result.
+// Divide num by div and return as 16.16 fixed point result.
int FixedDiv1_C(int num, int div) {
return (int)((((int64_t)(num) << 16) - 0x00010001) / (div - 1));
}
@@ -1739,14 +1696,14 @@ void ScaleSlope(int src_width,
if (dst_width <= Abs(src_width)) {
*dx = FixedDiv(Abs(src_width), dst_width);
*x = CENTERSTART(*dx, -32768); // Subtract 0.5 (32768) to center filter.
- } else if (src_width > 1 && dst_width > 1) {
+ } else if (dst_width > 1) {
*dx = FixedDiv1(Abs(src_width), dst_width);
*x = 0;
}
if (dst_height <= src_height) {
*dy = FixedDiv(src_height, dst_height);
*y = CENTERSTART(*dy, -32768); // Subtract 0.5 (32768) to center filter.
- } else if (src_height > 1 && dst_height > 1) {
+ } else if (dst_height > 1) {
*dy = FixedDiv1(src_height, dst_height);
*y = 0;
}
@@ -1755,7 +1712,7 @@ void ScaleSlope(int src_width,
if (dst_width <= Abs(src_width)) {
*dx = FixedDiv(Abs(src_width), dst_width);
*x = CENTERSTART(*dx, -32768); // Subtract 0.5 (32768) to center filter.
- } else if (src_width > 1 && dst_width > 1) {
+ } else if (dst_width > 1) {
*dx = FixedDiv1(Abs(src_width), dst_width);
*x = 0;
}