summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/libyuv/source/planar_functions.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/libyuv/source/planar_functions.cc')
-rw-r--r--chromium/third_party/libyuv/source/planar_functions.cc503
1 files changed, 298 insertions, 205 deletions
diff --git a/chromium/third_party/libyuv/source/planar_functions.cc b/chromium/third_party/libyuv/source/planar_functions.cc
index 114faaef627..f1297ca538a 100644
--- a/chromium/third_party/libyuv/source/planar_functions.cc
+++ b/chromium/third_party/libyuv/source/planar_functions.cc
@@ -28,6 +28,8 @@ LIBYUV_API
void CopyPlane(const uint8* src_y, int src_stride_y,
uint8* dst_y, int dst_stride_y,
int width, int height) {
+ int y;
+ void (*CopyRow)(const uint8* src, uint8* dst, int width) = CopyRow_C;
// Coalesce rows.
if (src_stride_y == width &&
dst_stride_y == width) {
@@ -35,7 +37,6 @@ void CopyPlane(const uint8* src_y, int src_stride_y,
height = 1;
src_stride_y = dst_stride_y = 0;
}
- void (*CopyRow)(const uint8* src, uint8* dst, int width) = CopyRow_C;
#if defined(HAS_COPYROW_X86)
if (TestCpuFlag(kCpuHasX86) && IS_ALIGNED(width, 4)) {
CopyRow = CopyRow_X86;
@@ -65,7 +66,56 @@ void CopyPlane(const uint8* src_y, int src_stride_y,
#endif
// Copy plane
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
+ CopyRow(src_y, dst_y, width);
+ src_y += src_stride_y;
+ dst_y += dst_stride_y;
+ }
+}
+
+LIBYUV_API
+void CopyPlane_16(const uint16* src_y, int src_stride_y,
+ uint16* dst_y, int dst_stride_y,
+ int width, int height) {
+ int y;
+ void (*CopyRow)(const uint16* src, uint16* 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_X86)
+ if (TestCpuFlag(kCpuHasX86) && IS_ALIGNED(width, 4)) {
+ CopyRow = CopyRow_16_X86;
+ }
+#endif
+#if defined(HAS_COPYROW_16_SSE2)
+ if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 32) &&
+ IS_ALIGNED(src_y, 16) && IS_ALIGNED(src_stride_y, 16) &&
+ IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) {
+ 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
+#if defined(HAS_COPYROW_16_MIPS)
+ if (TestCpuFlag(kCpuHasMIPS)) {
+ CopyRow = CopyRow_16_MIPS;
+ }
+#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;
@@ -81,6 +131,7 @@ int I422Copy(const uint8* src_y, int src_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height) {
+ int halfwidth = (width + 1) >> 1;
if (!src_y || !src_u || !src_v ||
!dst_y || !dst_u || !dst_v ||
width <= 0 || height == 0) {
@@ -96,7 +147,6 @@ int I422Copy(const uint8* src_y, int src_stride_y,
src_stride_u = -src_stride_u;
src_stride_v = -src_stride_v;
}
- int halfwidth = (width + 1) >> 1;
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, height);
CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, height);
@@ -155,8 +205,8 @@ int I400ToI400(const uint8* src_y, int src_stride_y,
// Convert I420 to I400.
LIBYUV_API
int I420ToI400(const uint8* src_y, int src_stride_y,
- uint8*, int, // src_u
- uint8*, int, // src_v
+ const uint8* src_u, int src_stride_u,
+ const uint8* src_v, int src_stride_v,
uint8* dst_y, int dst_stride_y,
int width, int height) {
if (!src_y || !dst_y || width <= 0 || height == 0) {
@@ -176,13 +226,14 @@ int I420ToI400(const uint8* src_y, int src_stride_y,
void MirrorPlane(const uint8* src_y, int src_stride_y,
uint8* dst_y, int dst_stride_y,
int width, int height) {
+ int y;
+ void (*MirrorRow)(const uint8* src, uint8* dst, int width) = MirrorRow_C;
// Negative height means invert the image.
if (height < 0) {
height = -height;
src_y = src_y + (height - 1) * src_stride_y;
src_stride_y = -src_stride_y;
}
- void (*MirrorRow)(const uint8* src, uint8* dst, int width) = MirrorRow_C;
#if defined(HAS_MIRRORROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) {
MirrorRow = MirrorRow_NEON;
@@ -207,7 +258,7 @@ void MirrorPlane(const uint8* src_y, int src_stride_y,
#endif
// Mirror plane
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
MirrorRow(src_y, dst_y, width);
src_y += src_stride_y;
dst_y += dst_stride_y;
@@ -221,6 +272,12 @@ int YUY2ToI422(const uint8* src_yuy2, int src_stride_yuy2,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height) {
+ int y;
+ void (*YUY2ToUV422Row)(const uint8* src_yuy2,
+ uint8* dst_u, uint8* dst_v, int pix) =
+ YUY2ToUV422Row_C;
+ void (*YUY2ToYRow)(const uint8* src_yuy2, uint8* dst_y, int pix) =
+ YUY2ToYRow_C;
// Negative height means invert the image.
if (height < 0) {
height = -height;
@@ -236,12 +293,6 @@ int YUY2ToI422(const uint8* src_yuy2, int src_stride_yuy2,
height = 1;
src_stride_yuy2 = dst_stride_y = dst_stride_u = dst_stride_v = 0;
}
- void (*YUY2ToUV422Row)(const uint8* src_yuy2,
- uint8* dst_u, uint8* dst_v, int pix);
- void (*YUY2ToYRow)(const uint8* src_yuy2,
- uint8* dst_y, int pix);
- YUY2ToYRow = YUY2ToYRow_C;
- YUY2ToUV422Row = YUY2ToUV422Row_C;
#if defined(HAS_YUY2TOYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && width >= 16) {
YUY2ToUV422Row = YUY2ToUV422Row_Any_SSE2;
@@ -281,7 +332,7 @@ int YUY2ToI422(const uint8* src_yuy2, int src_stride_yuy2,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
YUY2ToUV422Row(src_yuy2, dst_u, dst_v, width);
YUY2ToYRow(src_yuy2, dst_y, width);
src_yuy2 += src_stride_yuy2;
@@ -299,6 +350,12 @@ int UYVYToI422(const uint8* src_uyvy, int src_stride_uyvy,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height) {
+ int y;
+ void (*UYVYToUV422Row)(const uint8* src_uyvy,
+ uint8* dst_u, uint8* dst_v, int pix) =
+ UYVYToUV422Row_C;
+ void (*UYVYToYRow)(const uint8* src_uyvy,
+ uint8* dst_y, int pix) = UYVYToYRow_C;
// Negative height means invert the image.
if (height < 0) {
height = -height;
@@ -314,12 +371,6 @@ int UYVYToI422(const uint8* src_uyvy, int src_stride_uyvy,
height = 1;
src_stride_uyvy = dst_stride_y = dst_stride_u = dst_stride_v = 0;
}
- void (*UYVYToUV422Row)(const uint8* src_uyvy,
- uint8* dst_u, uint8* dst_v, int pix);
- void (*UYVYToYRow)(const uint8* src_uyvy,
- uint8* dst_y, int pix);
- UYVYToYRow = UYVYToYRow_C;
- UYVYToUV422Row = UYVYToUV422Row_C;
#if defined(HAS_UYVYTOYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && width >= 16) {
UYVYToUV422Row = UYVYToUV422Row_Any_SSE2;
@@ -359,7 +410,7 @@ int UYVYToI422(const uint8* src_uyvy, int src_stride_uyvy,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
UYVYToUV422Row(src_uyvy, dst_u, dst_v, width);
UYVYToYRow(src_uyvy, dst_y, width);
src_uyvy += src_stride_uyvy;
@@ -399,6 +450,8 @@ int I420Mirror(const uint8* src_y, int src_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height) {
+ int halfwidth = (width + 1) >> 1;
+ int halfheight = (height + 1) >> 1;
if (!src_y || !src_u || !src_v || !dst_y || !dst_u || !dst_v ||
width <= 0 || height == 0) {
return -1;
@@ -406,7 +459,7 @@ int I420Mirror(const uint8* src_y, int src_stride_y,
// Negative height means invert the image.
if (height < 0) {
height = -height;
- int halfheight = (height + 1) >> 1;
+ 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;
@@ -415,8 +468,6 @@ int I420Mirror(const uint8* src_y, int src_stride_y,
src_stride_v = -src_stride_v;
}
- int halfwidth = (width + 1) >> 1;
- int halfheight = (height + 1) >> 1;
if (dst_y) {
MirrorPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
}
@@ -430,6 +481,9 @@ LIBYUV_API
int ARGBMirror(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
+ int y;
+ void (*ARGBMirrorRow)(const uint8* src, uint8* dst, int width) =
+ ARGBMirrorRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -440,8 +494,6 @@ int ARGBMirror(const uint8* src_argb, int src_stride_argb,
src_stride_argb = -src_stride_argb;
}
- void (*ARGBMirrorRow)(const uint8* src, uint8* dst, int width) =
- ARGBMirrorRow_C;
#if defined(HAS_ARGBMIRRORROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 4) &&
IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride_argb, 16) &&
@@ -461,7 +513,7 @@ int ARGBMirror(const uint8* src_argb, int src_stride_argb,
#endif
// Mirror plane
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBMirrorRow(src_argb, dst_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
@@ -501,6 +553,9 @@ int ARGBBlend(const uint8* src_argb0, int src_stride_argb0,
const uint8* src_argb1, int src_stride_argb1,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
+ int y;
+ void (*ARGBBlendRow)(const uint8* src_argb, const uint8* src_argb1,
+ uint8* dst_argb, int width) = GetARGBBlend();
if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -518,10 +573,8 @@ int ARGBBlend(const uint8* src_argb0, int src_stride_argb0,
height = 1;
src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0;
}
- void (*ARGBBlendRow)(const uint8* src_argb, const uint8* src_argb1,
- uint8* dst_argb, int width) = GetARGBBlend();
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBBlendRow(src_argb0, src_argb1, dst_argb, width);
src_argb0 += src_stride_argb0;
src_argb1 += src_stride_argb1;
@@ -536,6 +589,9 @@ int ARGBMultiply(const uint8* src_argb0, int src_stride_argb0,
const uint8* src_argb1, int src_stride_argb1,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
+ int y;
+ void (*ARGBMultiplyRow)(const uint8* src0, const uint8* src1, uint8* dst,
+ int width) = ARGBMultiplyRow_C;
if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -553,8 +609,6 @@ int ARGBMultiply(const uint8* src_argb0, int src_stride_argb0,
height = 1;
src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0;
}
- void (*ARGBMultiplyRow)(const uint8* src0, const uint8* src1, uint8* dst,
- int width) = ARGBMultiplyRow_C;
#if defined(HAS_ARGBMULTIPLYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && width >= 4) {
ARGBMultiplyRow = ARGBMultiplyRow_Any_SSE2;
@@ -581,7 +635,7 @@ int ARGBMultiply(const uint8* src_argb0, int src_stride_argb0,
#endif
// Multiply plane
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBMultiplyRow(src_argb0, src_argb1, dst_argb, width);
src_argb0 += src_stride_argb0;
src_argb1 += src_stride_argb1;
@@ -596,6 +650,9 @@ int ARGBAdd(const uint8* src_argb0, int src_stride_argb0,
const uint8* src_argb1, int src_stride_argb1,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
+ int y;
+ void (*ARGBAddRow)(const uint8* src0, const uint8* src1, uint8* dst,
+ int width) = ARGBAddRow_C;
if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -613,8 +670,6 @@ int ARGBAdd(const uint8* src_argb0, int src_stride_argb0,
height = 1;
src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0;
}
- void (*ARGBAddRow)(const uint8* src0, const uint8* src1, uint8* dst,
- int width) = ARGBAddRow_C;
#if defined(HAS_ARGBADDROW_SSE2) && defined(_MSC_VER)
if (TestCpuFlag(kCpuHasSSE2)) {
ARGBAddRow = ARGBAddRow_SSE2;
@@ -646,7 +701,7 @@ int ARGBAdd(const uint8* src_argb0, int src_stride_argb0,
#endif
// Add plane
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBAddRow(src_argb0, src_argb1, dst_argb, width);
src_argb0 += src_stride_argb0;
src_argb1 += src_stride_argb1;
@@ -661,6 +716,9 @@ int ARGBSubtract(const uint8* src_argb0, int src_stride_argb0,
const uint8* src_argb1, int src_stride_argb1,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
+ int y;
+ void (*ARGBSubtractRow)(const uint8* src0, const uint8* src1, uint8* dst,
+ int width) = ARGBSubtractRow_C;
if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -678,8 +736,6 @@ int ARGBSubtract(const uint8* src_argb0, int src_stride_argb0,
height = 1;
src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0;
}
- void (*ARGBSubtractRow)(const uint8* src0, const uint8* src1, uint8* dst,
- int width) = ARGBSubtractRow_C;
#if defined(HAS_ARGBSUBTRACTROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && width >= 4) {
ARGBSubtractRow = ARGBSubtractRow_Any_SSE2;
@@ -706,7 +762,7 @@ int ARGBSubtract(const uint8* src_argb0, int src_stride_argb0,
#endif
// Subtract plane
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBSubtractRow(src_argb0, src_argb1, dst_argb, width);
src_argb0 += src_stride_argb0;
src_argb1 += src_stride_argb1;
@@ -722,6 +778,12 @@ int I422ToBGRA(const uint8* src_y, int src_stride_y,
const uint8* src_v, int src_stride_v,
uint8* dst_bgra, int dst_stride_bgra,
int width, int height) {
+ int y;
+ void (*I422ToBGRARow)(const uint8* y_buf,
+ const uint8* u_buf,
+ const uint8* v_buf,
+ uint8* rgb_buf,
+ int width) = I422ToBGRARow_C;
if (!src_y || !src_u || !src_v ||
!dst_bgra ||
width <= 0 || height == 0) {
@@ -742,11 +804,6 @@ int I422ToBGRA(const uint8* src_y, int src_stride_y,
height = 1;
src_stride_y = src_stride_u = src_stride_v = dst_stride_bgra = 0;
}
- void (*I422ToBGRARow)(const uint8* y_buf,
- const uint8* u_buf,
- const uint8* v_buf,
- uint8* rgb_buf,
- int width) = I422ToBGRARow_C;
#if defined(HAS_I422TOBGRAROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
I422ToBGRARow = I422ToBGRARow_Any_NEON;
@@ -774,7 +831,7 @@ int I422ToBGRA(const uint8* src_y, int src_stride_y,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
I422ToBGRARow(src_y, src_u, src_v, dst_bgra, width);
dst_bgra += dst_stride_bgra;
src_y += src_stride_y;
@@ -791,6 +848,12 @@ int I422ToABGR(const uint8* src_y, int src_stride_y,
const uint8* src_v, int src_stride_v,
uint8* dst_abgr, int dst_stride_abgr,
int width, int height) {
+ int y;
+ void (*I422ToABGRRow)(const uint8* y_buf,
+ const uint8* u_buf,
+ const uint8* v_buf,
+ uint8* rgb_buf,
+ int width) = I422ToABGRRow_C;
if (!src_y || !src_u || !src_v ||
!dst_abgr ||
width <= 0 || height == 0) {
@@ -811,11 +874,6 @@ int I422ToABGR(const uint8* src_y, int src_stride_y,
height = 1;
src_stride_y = src_stride_u = src_stride_v = dst_stride_abgr = 0;
}
- void (*I422ToABGRRow)(const uint8* y_buf,
- const uint8* u_buf,
- const uint8* v_buf,
- uint8* rgb_buf,
- int width) = I422ToABGRRow_C;
#if defined(HAS_I422TOABGRROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
I422ToABGRRow = I422ToABGRRow_Any_NEON;
@@ -835,7 +893,7 @@ int I422ToABGR(const uint8* src_y, int src_stride_y,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
I422ToABGRRow(src_y, src_u, src_v, dst_abgr, width);
dst_abgr += dst_stride_abgr;
src_y += src_stride_y;
@@ -852,6 +910,12 @@ int I422ToRGBA(const uint8* src_y, int src_stride_y,
const uint8* src_v, int src_stride_v,
uint8* dst_rgba, int dst_stride_rgba,
int width, int height) {
+ int y;
+ void (*I422ToRGBARow)(const uint8* y_buf,
+ const uint8* u_buf,
+ const uint8* v_buf,
+ uint8* rgb_buf,
+ int width) = I422ToRGBARow_C;
if (!src_y || !src_u || !src_v ||
!dst_rgba ||
width <= 0 || height == 0) {
@@ -872,11 +936,6 @@ int I422ToRGBA(const uint8* src_y, int src_stride_y,
height = 1;
src_stride_y = src_stride_u = src_stride_v = dst_stride_rgba = 0;
}
- void (*I422ToRGBARow)(const uint8* y_buf,
- const uint8* u_buf,
- const uint8* v_buf,
- uint8* rgb_buf,
- int width) = I422ToRGBARow_C;
#if defined(HAS_I422TORGBAROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
I422ToRGBARow = I422ToRGBARow_Any_NEON;
@@ -896,7 +955,7 @@ int I422ToRGBA(const uint8* src_y, int src_stride_y,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
I422ToRGBARow(src_y, src_u, src_v, dst_rgba, width);
dst_rgba += dst_stride_rgba;
src_y += src_stride_y;
@@ -912,6 +971,11 @@ int NV12ToRGB565(const uint8* src_y, int src_stride_y,
const uint8* src_uv, int src_stride_uv,
uint8* dst_rgb565, int dst_stride_rgb565,
int width, int height) {
+ int y;
+ void (*NV12ToRGB565Row)(const uint8* y_buf,
+ const uint8* uv_buf,
+ uint8* rgb_buf,
+ int width) = NV12ToRGB565Row_C;
if (!src_y || !src_uv || !dst_rgb565 ||
width <= 0 || height == 0) {
return -1;
@@ -922,12 +986,8 @@ int NV12ToRGB565(const uint8* src_y, int src_stride_y,
dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565;
dst_stride_rgb565 = -dst_stride_rgb565;
}
- void (*NV12ToRGB565Row)(const uint8* y_buf,
- const uint8* uv_buf,
- uint8* rgb_buf,
- int width) = NV12ToRGB565Row_C;
#if defined(HAS_NV12TORGB565ROW_SSSE3)
- if (TestCpuFlag(kCpuHasSSSE3) && width >= 8 && width * 4 <= kMaxStride) {
+ if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
NV12ToRGB565Row = NV12ToRGB565Row_Any_SSSE3;
if (IS_ALIGNED(width, 8)) {
NV12ToRGB565Row = NV12ToRGB565Row_SSSE3;
@@ -942,7 +1002,7 @@ int NV12ToRGB565(const uint8* src_y, int src_stride_y,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
NV12ToRGB565Row(src_y, src_uv, dst_rgb565, width);
dst_rgb565 += dst_stride_rgb565;
src_y += src_stride_y;
@@ -959,6 +1019,11 @@ int NV21ToRGB565(const uint8* src_y, int src_stride_y,
const uint8* src_vu, int src_stride_vu,
uint8* dst_rgb565, int dst_stride_rgb565,
int width, int height) {
+ int y;
+ void (*NV21ToRGB565Row)(const uint8* y_buf,
+ const uint8* src_vu,
+ uint8* rgb_buf,
+ int width) = NV21ToRGB565Row_C;
if (!src_y || !src_vu || !dst_rgb565 ||
width <= 0 || height == 0) {
return -1;
@@ -969,12 +1034,8 @@ int NV21ToRGB565(const uint8* src_y, int src_stride_y,
dst_rgb565 = dst_rgb565 + (height - 1) * dst_stride_rgb565;
dst_stride_rgb565 = -dst_stride_rgb565;
}
- void (*NV21ToRGB565Row)(const uint8* y_buf,
- const uint8* src_vu,
- uint8* rgb_buf,
- int width) = NV21ToRGB565Row_C;
#if defined(HAS_NV21TORGB565ROW_SSSE3)
- if (TestCpuFlag(kCpuHasSSSE3) && width >= 8 && width * 4 <= kMaxStride) {
+ if (TestCpuFlag(kCpuHasSSSE3) && width >= 8) {
NV21ToRGB565Row = NV21ToRGB565Row_Any_SSSE3;
if (IS_ALIGNED(width, 8)) {
NV21ToRGB565Row = NV21ToRGB565Row_SSSE3;
@@ -989,7 +1050,7 @@ int NV21ToRGB565(const uint8* src_y, int src_stride_y,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
NV21ToRGB565Row(src_y, src_vu, dst_rgb565, width);
dst_rgb565 += dst_stride_rgb565;
src_y += src_stride_y;
@@ -1004,13 +1065,15 @@ LIBYUV_API
void SetPlane(uint8* dst_y, int dst_stride_y,
int width, int height,
uint32 value) {
+ int y;
+ uint32 v32 = value | (value << 8) | (value << 16) | (value << 24);
+ void (*SetRow)(uint8* dst, uint32 value, int pix) = SetRow_C;
// Coalesce rows.
if (dst_stride_y == width) {
width *= height;
height = 1;
dst_stride_y = 0;
}
- void (*SetRow)(uint8* dst, uint32 value, int pix) = SetRow_C;
#if defined(HAS_SETROW_NEON)
if (TestCpuFlag(kCpuHasNEON) &&
IS_ALIGNED(width, 16) &&
@@ -1024,9 +1087,8 @@ void SetPlane(uint8* dst_y, int dst_stride_y,
}
#endif
- uint32 v32 = value | (value << 8) | (value << 16) | (value << 24);
// Set plane
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
SetRow(dst_y, v32, width);
dst_y += dst_stride_y;
}
@@ -1040,6 +1102,11 @@ int I420Rect(uint8* dst_y, int dst_stride_y,
int x, int y,
int width, int height,
int value_y, int value_u, int value_v) {
+ int halfwidth = (width + 1) >> 1;
+ int halfheight = (height + 1) >> 1;
+ uint8* start_y = dst_y + y * dst_stride_y + x;
+ uint8* start_u = dst_u + (y / 2) * dst_stride_u + (x / 2);
+ uint8* start_v = dst_v + (y / 2) * dst_stride_v + (x / 2);
if (!dst_y || !dst_u || !dst_v ||
width <= 0 || height <= 0 ||
x < 0 || y < 0 ||
@@ -1048,11 +1115,6 @@ int I420Rect(uint8* dst_y, int dst_stride_y,
value_v < 0 || value_v > 255) {
return -1;
}
- int halfwidth = (width + 1) >> 1;
- int halfheight = (height + 1) >> 1;
- uint8* start_y = dst_y + y * dst_stride_y + x;
- uint8* start_u = dst_u + (y / 2) * dst_stride_u + (x / 2);
- uint8* start_v = dst_v + (y / 2) * dst_stride_v + (x / 2);
SetPlane(start_y, dst_stride_y, width, height, value_y);
SetPlane(start_u, dst_stride_u, halfwidth, halfheight, value_u);
@@ -1112,6 +1174,9 @@ LIBYUV_API
int ARGBAttenuate(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
+ int y;
+ void (*ARGBAttenuateRow)(const uint8* src_argb, uint8* dst_argb,
+ int width) = ARGBAttenuateRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -1127,8 +1192,6 @@ int ARGBAttenuate(const uint8* src_argb, int src_stride_argb,
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
- void (*ARGBAttenuateRow)(const uint8* src_argb, uint8* dst_argb,
- int width) = ARGBAttenuateRow_C;
#if defined(HAS_ARGBATTENUATEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && width >= 4 &&
IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride_argb, 16) &&
@@ -1164,7 +1227,7 @@ int ARGBAttenuate(const uint8* src_argb, int src_stride_argb,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBAttenuateRow(src_argb, dst_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
@@ -1177,6 +1240,9 @@ LIBYUV_API
int ARGBUnattenuate(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
+ int y;
+ void (*ARGBUnattenuateRow)(const uint8* src_argb, uint8* dst_argb,
+ int width) = ARGBUnattenuateRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -1192,8 +1258,6 @@ int ARGBUnattenuate(const uint8* src_argb, int src_stride_argb,
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
- void (*ARGBUnattenuateRow)(const uint8* src_argb, uint8* dst_argb,
- int width) = ARGBUnattenuateRow_C;
#if defined(HAS_ARGBUNATTENUATEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && width >= 4) {
ARGBUnattenuateRow = ARGBUnattenuateRow_Any_SSE2;
@@ -1212,7 +1276,7 @@ int ARGBUnattenuate(const uint8* src_argb, int src_stride_argb,
#endif
// TODO(fbarchard): Neon version.
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBUnattenuateRow(src_argb, dst_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
@@ -1225,6 +1289,9 @@ LIBYUV_API
int ARGBGrayTo(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
+ int y;
+ void (*ARGBGrayRow)(const uint8* src_argb, uint8* dst_argb,
+ int width) = ARGBGrayRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -1240,8 +1307,6 @@ int ARGBGrayTo(const uint8* src_argb, int src_stride_argb,
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
- void (*ARGBGrayRow)(const uint8* src_argb, uint8* dst_argb,
- int width) = ARGBGrayRow_C;
#if defined(HAS_ARGBGRAYROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8) &&
IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride_argb, 16) &&
@@ -1254,7 +1319,7 @@ int ARGBGrayTo(const uint8* src_argb, int src_stride_argb,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBGrayRow(src_argb, dst_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
@@ -1267,6 +1332,10 @@ LIBYUV_API
int ARGBGray(uint8* dst_argb, int dst_stride_argb,
int dst_x, int dst_y,
int width, int height) {
+ int y;
+ void (*ARGBGrayRow)(const uint8* src_argb, uint8* dst_argb,
+ int width) = ARGBGrayRow_C;
+ uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) {
return -1;
}
@@ -1276,8 +1345,6 @@ int ARGBGray(uint8* dst_argb, int dst_stride_argb,
height = 1;
dst_stride_argb = 0;
}
- void (*ARGBGrayRow)(const uint8* src_argb, uint8* dst_argb,
- int width) = ARGBGrayRow_C;
#if defined(HAS_ARGBGRAYROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8) &&
IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) {
@@ -1288,8 +1355,7 @@ int ARGBGray(uint8* dst_argb, int dst_stride_argb,
ARGBGrayRow = ARGBGrayRow_NEON;
}
#endif
- uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBGrayRow(dst, dst, width);
dst += dst_stride_argb;
}
@@ -1300,6 +1366,9 @@ int ARGBGray(uint8* dst_argb, int dst_stride_argb,
LIBYUV_API
int ARGBSepia(uint8* dst_argb, int dst_stride_argb,
int dst_x, int dst_y, int width, int height) {
+ int y;
+ void (*ARGBSepiaRow)(uint8* dst_argb, int width) = ARGBSepiaRow_C;
+ uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) {
return -1;
}
@@ -1309,7 +1378,6 @@ int ARGBSepia(uint8* dst_argb, int dst_stride_argb,
height = 1;
dst_stride_argb = 0;
}
- void (*ARGBSepiaRow)(uint8* dst_argb, int width) = ARGBSepiaRow_C;
#if defined(HAS_ARGBSEPIAROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8) &&
IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) {
@@ -1320,8 +1388,7 @@ int ARGBSepia(uint8* dst_argb, int dst_stride_argb,
ARGBSepiaRow = ARGBSepiaRow_NEON;
}
#endif
- uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBSepiaRow(dst, width);
dst += dst_stride_argb;
}
@@ -1335,6 +1402,9 @@ int ARGBColorMatrix(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
const int8* matrix_argb,
int width, int height) {
+ int y;
+ void (*ARGBColorMatrixRow)(const uint8* src_argb, uint8* dst_argb,
+ const int8* matrix_argb, int width) = ARGBColorMatrixRow_C;
if (!src_argb || !dst_argb || !matrix_argb || width <= 0 || height == 0) {
return -1;
}
@@ -1350,8 +1420,6 @@ int ARGBColorMatrix(const uint8* src_argb, int src_stride_argb,
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
- void (*ARGBColorMatrixRow)(const uint8* src_argb, uint8* dst_argb,
- const int8* matrix_argb, int width) = ARGBColorMatrixRow_C;
#if defined(HAS_ARGBCOLORMATRIXROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8) &&
IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) {
@@ -1362,7 +1430,7 @@ int ARGBColorMatrix(const uint8* src_argb, int src_stride_argb,
ARGBColorMatrixRow = ARGBColorMatrixRow_NEON;
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBColorMatrixRow(src_argb, dst_argb, matrix_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
@@ -1372,17 +1440,18 @@ int ARGBColorMatrix(const uint8* src_argb, int src_stride_argb,
// Apply a 4x3 matrix to each ARGB pixel.
// Deprecated.
-LIBYUV_API SAFEBUFFERS
+LIBYUV_API
int RGBColorMatrix(uint8* dst_argb, int dst_stride_argb,
const int8* matrix_rgb,
int dst_x, int dst_y, int width, int height) {
+ SIMD_ALIGNED(int8 matrix_argb[16]);
+ uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || !matrix_rgb || width <= 0 || height <= 0 ||
dst_x < 0 || dst_y < 0) {
return -1;
}
// Convert 4x3 7 bit matrix to 4x4 6 bit matrix.
- SIMD_ALIGNED(int8 matrix_argb[16]);
matrix_argb[0] = matrix_rgb[0] / 2;
matrix_argb[1] = matrix_rgb[1] / 2;
matrix_argb[2] = matrix_rgb[2] / 2;
@@ -1398,8 +1467,7 @@ int RGBColorMatrix(uint8* dst_argb, int dst_stride_argb,
matrix_argb[14] = matrix_argb[13] = matrix_argb[12] = 0;
matrix_argb[15] = 64; // 1.0
- uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
- return ARGBColorMatrix(const_cast<const uint8*>(dst), dst_stride_argb,
+ return ARGBColorMatrix((const uint8*)(dst), dst_stride_argb,
dst, dst_stride_argb,
&matrix_argb[0], width, height);
}
@@ -1410,6 +1478,10 @@ LIBYUV_API
int ARGBColorTable(uint8* dst_argb, int dst_stride_argb,
const uint8* table_argb,
int dst_x, int dst_y, int width, int height) {
+ int y;
+ void (*ARGBColorTableRow)(uint8* dst_argb, const uint8* table_argb,
+ int width) = ARGBColorTableRow_C;
+ uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || !table_argb || width <= 0 || height <= 0 ||
dst_x < 0 || dst_y < 0) {
return -1;
@@ -1420,15 +1492,12 @@ int ARGBColorTable(uint8* dst_argb, int dst_stride_argb,
height = 1;
dst_stride_argb = 0;
}
- void (*ARGBColorTableRow)(uint8* dst_argb, const uint8* table_argb,
- int width) = ARGBColorTableRow_C;
#if defined(HAS_ARGBCOLORTABLEROW_X86)
if (TestCpuFlag(kCpuHasX86)) {
ARGBColorTableRow = ARGBColorTableRow_X86;
}
#endif
- uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBColorTableRow(dst, table_argb, width);
dst += dst_stride_argb;
}
@@ -1441,6 +1510,10 @@ LIBYUV_API
int RGBColorTable(uint8* dst_argb, int dst_stride_argb,
const uint8* table_argb,
int dst_x, int dst_y, int width, int height) {
+ int y;
+ void (*RGBColorTableRow)(uint8* dst_argb, const uint8* table_argb,
+ int width) = RGBColorTableRow_C;
+ uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || !table_argb || width <= 0 || height <= 0 ||
dst_x < 0 || dst_y < 0) {
return -1;
@@ -1451,15 +1524,12 @@ int RGBColorTable(uint8* dst_argb, int dst_stride_argb,
height = 1;
dst_stride_argb = 0;
}
- void (*RGBColorTableRow)(uint8* dst_argb, const uint8* table_argb,
- int width) = RGBColorTableRow_C;
#if defined(HAS_RGBCOLORTABLEROW_X86)
if (TestCpuFlag(kCpuHasX86)) {
RGBColorTableRow = RGBColorTableRow_X86;
}
#endif
- uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
RGBColorTableRow(dst, table_argb, width);
dst += dst_stride_argb;
}
@@ -1479,6 +1549,10 @@ LIBYUV_API
int ARGBQuantize(uint8* dst_argb, int dst_stride_argb,
int scale, int interval_size, int interval_offset,
int dst_x, int dst_y, int width, int height) {
+ int y;
+ void (*ARGBQuantizeRow)(uint8* dst_argb, int scale, int interval_size,
+ int interval_offset, int width) = ARGBQuantizeRow_C;
+ uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0 ||
interval_size < 1 || interval_size > 255) {
return -1;
@@ -1489,8 +1563,6 @@ int ARGBQuantize(uint8* dst_argb, int dst_stride_argb,
height = 1;
dst_stride_argb = 0;
}
- void (*ARGBQuantizeRow)(uint8* dst_argb, int scale, int interval_size,
- int interval_offset, int width) = ARGBQuantizeRow_C;
#if defined(HAS_ARGBQUANTIZEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 4) &&
IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) {
@@ -1501,8 +1573,7 @@ int ARGBQuantize(uint8* dst_argb, int dst_stride_argb,
ARGBQuantizeRow = ARGBQuantizeRow_NEON;
}
#endif
- uint8* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBQuantizeRow(dst, scale, interval_size, interval_offset, width);
dst += dst_stride_argb;
}
@@ -1515,19 +1586,20 @@ LIBYUV_API
int ARGBComputeCumulativeSum(const uint8* src_argb, int src_stride_argb,
int32* dst_cumsum, int dst_stride32_cumsum,
int width, int height) {
+ int y;
+ void (*ComputeCumulativeSumRow)(const uint8* row, int32* cumsum,
+ const int32* previous_cumsum, int width) = ComputeCumulativeSumRow_C;
+ int32* previous_cumsum = dst_cumsum;
if (!dst_cumsum || !src_argb || width <= 0 || height <= 0) {
return -1;
}
- void (*ComputeCumulativeSumRow)(const uint8* row, int32* cumsum,
- const int32* previous_cumsum, int width) = ComputeCumulativeSumRow_C;
#if defined(HAS_CUMULATIVESUMTOAVERAGEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ComputeCumulativeSumRow = ComputeCumulativeSumRow_SSE2;
}
#endif
memset(dst_cumsum, 0, width * sizeof(dst_cumsum[0]) * 4); // 4 int per pixel.
- int32* previous_cumsum = dst_cumsum;
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ComputeCumulativeSumRow(src_argb, dst_cumsum, previous_cumsum, width);
previous_cumsum = dst_cumsum;
dst_cumsum += dst_stride32_cumsum;
@@ -1545,6 +1617,15 @@ int ARGBBlur(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
int32* dst_cumsum, int dst_stride32_cumsum,
int width, int height, int radius) {
+ int y;
+ void (*ComputeCumulativeSumRow)(const uint8 *row, int32 *cumsum,
+ const int32* previous_cumsum, int width) = ComputeCumulativeSumRow_C;
+ void (*CumulativeSumToAverageRow)(const int32* topleft, const int32* botleft,
+ int width, int area, uint8* dst, int count) = CumulativeSumToAverageRow_C;
+ int32* cumsum_bot_row;
+ int32* max_cumsum_bot_row;
+ int32* cumsum_top_row;
+
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -1562,10 +1643,6 @@ int ARGBBlur(const uint8* src_argb, int src_stride_argb,
if (radius <= 0) {
return -1;
}
- void (*ComputeCumulativeSumRow)(const uint8 *row, int32 *cumsum,
- const int32* previous_cumsum, int width) = ComputeCumulativeSumRow_C;
- void (*CumulativeSumToAverageRow)(const int32* topleft, const int32* botleft,
- int width, int area, uint8* dst, int count) = CumulativeSumToAverageRow_C;
#if defined(HAS_CUMULATIVESUMTOAVERAGEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ComputeCumulativeSumRow = ComputeCumulativeSumRow_SSE2;
@@ -1579,16 +1656,18 @@ int ARGBBlur(const uint8* src_argb, int src_stride_argb,
width, radius);
src_argb = src_argb + radius * src_stride_argb;
- int32* cumsum_bot_row = &dst_cumsum[(radius - 1) * dst_stride32_cumsum];
+ cumsum_bot_row = &dst_cumsum[(radius - 1) * dst_stride32_cumsum];
- const int32* max_cumsum_bot_row =
- &dst_cumsum[(radius * 2 + 2) * dst_stride32_cumsum];
- const int32* cumsum_top_row = &dst_cumsum[0];
+ max_cumsum_bot_row = &dst_cumsum[(radius * 2 + 2) * dst_stride32_cumsum];
+ cumsum_top_row = &dst_cumsum[0];
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
int top_y = ((y - radius - 1) >= 0) ? (y - radius - 1) : 0;
int bot_y = ((y + radius) < height) ? (y + radius) : (height - 1);
int area = radius * (bot_y - top_y);
+ int boxwidth = radius * 4;
+ int x;
+ int n;
// Increment cumsum_top_row pointer with circular buffer wrap around.
if (top_y) {
@@ -1611,8 +1690,6 @@ int ARGBBlur(const uint8* src_argb, int src_stride_argb,
}
// Left clipped.
- int boxwidth = radius * 4;
- int x;
for (x = 0; x < radius + 1; ++x) {
CumulativeSumToAverageRow(cumsum_top_row, cumsum_bot_row,
boxwidth, area, &dst_argb[x * 4], 1);
@@ -1621,7 +1698,7 @@ int ARGBBlur(const uint8* src_argb, int src_stride_argb,
}
// Middle unclipped.
- int n = (width - 1) - radius - x + 1;
+ n = (width - 1) - radius - x + 1;
CumulativeSumToAverageRow(cumsum_top_row, cumsum_bot_row,
boxwidth, area, &dst_argb[x * 4], n);
@@ -1643,6 +1720,9 @@ LIBYUV_API
int ARGBShade(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
int width, int height, uint32 value) {
+ int y;
+ void (*ARGBShadeRow)(const uint8* src_argb, uint8* dst_argb,
+ int width, uint32 value) = ARGBShadeRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0 || value == 0u) {
return -1;
}
@@ -1658,8 +1738,6 @@ int ARGBShade(const uint8* src_argb, int src_stride_argb,
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
- void (*ARGBShadeRow)(const uint8* src_argb, uint8* dst_argb,
- int width, uint32 value) = ARGBShadeRow_C;
#if defined(HAS_ARGBSHADEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 4) &&
IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride_argb, 16) &&
@@ -1672,7 +1750,7 @@ int ARGBShade(const uint8* src_argb, int src_stride_argb,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBShadeRow(src_argb, dst_argb, width, value);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
@@ -1686,6 +1764,10 @@ int ARGBInterpolate(const uint8* src_argb0, int src_stride_argb0,
const uint8* src_argb1, int src_stride_argb1,
uint8* dst_argb, int dst_stride_argb,
int width, int height, int interpolation) {
+ int y;
+ void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr,
+ ptrdiff_t src_stride, int dst_width,
+ int source_y_fraction) = InterpolateRow_C;
if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -1703,9 +1785,6 @@ int ARGBInterpolate(const uint8* src_argb0, int src_stride_argb0,
height = 1;
src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0;
}
- void (*InterpolateRow)(uint8* dst_ptr, const uint8* src_ptr,
- ptrdiff_t src_stride, int dst_width,
- int source_y_fraction) = InterpolateRow_C;
#if defined(HAS_INTERPOLATEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && width >= 4) {
InterpolateRow = InterpolateRow_Any_SSE2;
@@ -1757,7 +1836,7 @@ int ARGBInterpolate(const uint8* src_argb0, int src_stride_argb0,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
InterpolateRow(dst_argb, src_argb0, src_argb1 - src_argb0,
width * 4, interpolation);
src_argb0 += src_stride_argb0;
@@ -1772,6 +1851,9 @@ LIBYUV_API
int ARGBShuffle(const uint8* src_bgra, int src_stride_bgra,
uint8* dst_argb, int dst_stride_argb,
const uint8* shuffler, int width, int height) {
+ int y;
+ void (*ARGBShuffleRow)(const uint8* src_bgra, uint8* dst_argb,
+ const uint8* shuffler, int pix) = ARGBShuffleRow_C;
if (!src_bgra || !dst_argb ||
width <= 0 || height == 0) {
return -1;
@@ -1789,8 +1871,6 @@ int ARGBShuffle(const uint8* src_bgra, int src_stride_bgra,
height = 1;
src_stride_bgra = dst_stride_argb = 0;
}
- void (*ARGBShuffleRow)(const uint8* src_bgra, uint8* dst_argb,
- const uint8* shuffler, int pix) = ARGBShuffleRow_C;
#if defined(HAS_ARGBSHUFFLEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && width >= 4) {
ARGBShuffleRow = ARGBShuffleRow_Any_SSE2;
@@ -1828,7 +1908,7 @@ int ARGBShuffle(const uint8* src_bgra, int src_stride_bgra,
}
#endif
- for (int y = 0; y < height; ++y) {
+ for (y = 0; y < height; ++y) {
ARGBShuffleRow(src_bgra, dst_argb, shuffler, width);
src_bgra += src_stride_bgra;
dst_argb += dst_stride_argb;
@@ -1837,17 +1917,22 @@ int ARGBShuffle(const uint8* src_bgra, int src_stride_bgra,
}
// Sobel ARGB effect.
-static SAFEBUFFERS
-int ARGBSobelize(const uint8* src_argb, int src_stride_argb,
- uint8* dst_argb, int dst_stride_argb,
- int width, int height,
- void (*SobelRow)(const uint8* src_sobelx,
- const uint8* src_sobely,
- uint8* dst, int width)) {
- const int kMaxRow = kMaxStride / 4;
+static int ARGBSobelize(const uint8* src_argb, int src_stride_argb,
+ uint8* dst_argb, int dst_stride_argb,
+ int width, int height,
+ void (*SobelRow)(const uint8* src_sobelx,
+ const uint8* src_sobely,
+ uint8* dst, int width)) {
+ int y;
+ void (*ARGBToBayerRow)(const uint8* src_argb, uint8* dst_bayer,
+ uint32 selector, int pix) = ARGBToBayerGGRow_C;
+ void (*SobelYRow)(const uint8* src_y0, const uint8* src_y1,
+ uint8* dst_sobely, int width) = SobelYRow_C;
+ void (*SobelXRow)(const uint8* src_y0, const uint8* src_y1,
+ const uint8* src_y2, uint8* dst_sobely, int width) =
+ SobelXRow_C;
const int kEdge = 16; // Extra pixels at start of row for extrude/align.
- if (!src_argb || !dst_argb ||
- width <= 0 || height == 0 || width > (kMaxRow - kEdge)) {
+ if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
// Negative height means invert the image.
@@ -1857,8 +1942,6 @@ int ARGBSobelize(const uint8* src_argb, int src_stride_argb,
src_stride_argb = -src_stride_argb;
}
// ARGBToBayer used to select G channel from ARGB.
- void (*ARGBToBayerRow)(const uint8* src_argb, uint8* dst_bayer,
- uint32 selector, int pix) = ARGBToBayerGGRow_C;
#if defined(HAS_ARGBTOBAYERGGROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && width >= 8 &&
IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride_argb, 16)) {
@@ -1885,8 +1968,6 @@ int ARGBSobelize(const uint8* src_argb, int src_stride_argb,
}
}
#endif
- void (*SobelYRow)(const uint8* src_y0, const uint8* src_y1,
- uint8* dst_sobely, int width) = SobelYRow_C;
#if defined(HAS_SOBELYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
SobelYRow = SobelYRow_SSE2;
@@ -1897,9 +1978,6 @@ int ARGBSobelize(const uint8* src_argb, int src_stride_argb,
SobelYRow = SobelYRow_NEON;
}
#endif
- void (*SobelXRow)(const uint8* src_y0, const uint8* src_y1,
- const uint8* src_y2, uint8* dst_sobely, int width) =
- SobelXRow_C;
#if defined(HAS_SOBELXROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
SobelXRow = SobelXRow_SSE2;
@@ -1910,43 +1988,50 @@ int ARGBSobelize(const uint8* src_argb, int src_stride_argb,
SobelXRow = SobelXRow_NEON;
}
#endif
- // 3 rows with edges before/after.
- SIMD_ALIGNED(uint8 row_y[kEdge + kMaxRow * 3]);
- SIMD_ALIGNED(uint8 row_sobelx[kMaxRow]);
- SIMD_ALIGNED(uint8 row_sobely[kMaxRow]);
-
- // Convert first row.
- uint8* row_y0 = row_y + kEdge;
- uint8* row_y1 = row_y0 + kMaxRow;
- uint8* row_y2 = row_y1 + kMaxRow;
- ARGBToBayerRow(src_argb, row_y0, 0x0d090501, width);
- row_y0[-1] = row_y0[0];
- memset(row_y0 + width, row_y0[width - 1], 16); // extrude 16 pixels.
- ARGBToBayerRow(src_argb, row_y1, 0x0d090501, width);
- row_y1[-1] = row_y1[0];
- memset(row_y1 + width, row_y1[width - 1], 16);
- memset(row_y2 + width, 0, 16);
-
- for (int y = 0; y < height; ++y) {
- // Convert next row of ARGB to Y.
- if (y < (height - 1)) {
- src_argb += src_stride_argb;
- }
- ARGBToBayerRow(src_argb, row_y2, 0x0d090501, width);
- row_y2[-1] = row_y2[0];
- row_y2[width] = row_y2[width - 1];
-
- SobelXRow(row_y0 - 1, row_y1 - 1, row_y2 - 1, row_sobelx, width);
- SobelYRow(row_y0 - 1, row_y2 - 1, row_sobely, width);
- SobelRow(row_sobelx, row_sobely, dst_argb, width);
-
- // Cycle thru circular queue of 3 row_y buffers.
- uint8* row_yt = row_y0;
- row_y0 = row_y1;
- row_y1 = row_y2;
- row_y2 = row_yt;
+ {
+ // 3 rows with edges before/after.
+ const int kRowSize = (width + kEdge + 15) & ~15;
+ align_buffer_64(rows, kRowSize * 2 + (kEdge + kRowSize * 3 + kEdge));
+ uint8* row_sobelx = rows;
+ uint8* row_sobely = rows + kRowSize;
+ uint8* row_y = rows + kRowSize * 2;
+
+ // Convert first row.
+ uint8* row_y0 = row_y + kEdge;
+ uint8* row_y1 = row_y0 + kRowSize;
+ uint8* row_y2 = row_y1 + kRowSize;
+ ARGBToBayerRow(src_argb, row_y0, 0x0d090501, width);
+ row_y0[-1] = row_y0[0];
+ memset(row_y0 + width, row_y0[width - 1], 16); // Extrude 16 for valgrind.
+ ARGBToBayerRow(src_argb, row_y1, 0x0d090501, width);
+ row_y1[-1] = row_y1[0];
+ memset(row_y1 + width, row_y1[width - 1], 16);
+ memset(row_y2 + width, 0, 16);
+
+ for (y = 0; y < height; ++y) {
+ // Convert next row of ARGB to Y.
+ if (y < (height - 1)) {
+ src_argb += src_stride_argb;
+ }
+ ARGBToBayerRow(src_argb, row_y2, 0x0d090501, width);
+ row_y2[-1] = row_y2[0];
+ row_y2[width] = row_y2[width - 1];
+
+ SobelXRow(row_y0 - 1, row_y1 - 1, row_y2 - 1, row_sobelx, width);
+ SobelYRow(row_y0 - 1, row_y2 - 1, row_sobely, width);
+ SobelRow(row_sobelx, row_sobely, dst_argb, width);
+
+ // Cycle thru circular queue of 3 row_y buffers.
+ {
+ uint8* row_yt = row_y0;
+ row_y0 = row_y1;
+ row_y1 = row_y2;
+ row_y2 = row_yt;
+ }
- dst_argb += dst_stride_argb;
+ dst_argb += dst_stride_argb;
+ }
+ free_aligned_buffer_64(rows);
}
return 0;
}
@@ -2024,6 +2109,10 @@ int ARGBPolynomial(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
const float* poly,
int width, int height) {
+ int y;
+ void (*ARGBPolynomialRow)(const uint8* src_argb,
+ uint8* dst_argb, const float* poly,
+ int width) = ARGBPolynomialRow_C;
if (!src_argb || !dst_argb || !poly || width <= 0 || height == 0) {
return -1;
}
@@ -2040,9 +2129,6 @@ int ARGBPolynomial(const uint8* src_argb, int src_stride_argb,
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
- void (*ARGBPolynomialRow)(const uint8* src_argb,
- uint8* dst_argb, const float* poly,
- int width) = ARGBPolynomialRow_C;
#if defined(HAS_ARGBPOLYNOMIALROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 2)) {
ARGBPolynomialRow = ARGBPolynomialRow_SSE2;
@@ -2054,7 +2140,8 @@ int ARGBPolynomial(const uint8* src_argb, int src_stride_argb,
ARGBPolynomialRow = ARGBPolynomialRow_AVX2;
}
#endif
- for (int y = 0; y < height; ++y) {
+
+ for (y = 0; y < height; ++y) {
ARGBPolynomialRow(src_argb, dst_argb, poly, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
@@ -2068,6 +2155,10 @@ int ARGBLumaColorTable(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
const uint8* luma,
int width, int height) {
+ int y;
+ void (*ARGBLumaColorTableRow)(const uint8* src_argb, uint8* dst_argb,
+ int width, const uint8* luma, const uint32 lumacoeff) =
+ ARGBLumaColorTableRow_C;
if (!src_argb || !dst_argb || !luma || width <= 0 || height == 0) {
return -1;
}
@@ -2084,15 +2175,13 @@ int ARGBLumaColorTable(const uint8* src_argb, int src_stride_argb,
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
- void (*ARGBLumaColorTableRow)(const uint8* src_argb, uint8* dst_argb,
- int width, const uint8* luma, const uint32 lumacoeff) =
- ARGBLumaColorTableRow_C;
#if defined(HAS_ARGBLUMACOLORTABLEROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 4)) {
ARGBLumaColorTableRow = ARGBLumaColorTableRow_SSSE3;
}
#endif
- for (int y = 0; y < height; ++y) {
+
+ for (y = 0; y < height; ++y) {
ARGBLumaColorTableRow(src_argb, dst_argb, width, luma, 0x00264b0f);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
@@ -2105,6 +2194,9 @@ LIBYUV_API
int ARGBCopyAlpha(const uint8* src_argb, int src_stride_argb,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
+ int y;
+ void (*ARGBCopyAlphaRow)(const uint8* src_argb, uint8* dst_argb, int width) =
+ ARGBCopyAlphaRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -2121,8 +2213,6 @@ int ARGBCopyAlpha(const uint8* src_argb, int src_stride_argb,
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
- void (*ARGBCopyAlphaRow)(const uint8* src_argb, uint8* dst_argb, int width) =
- ARGBCopyAlphaRow_C;
#if defined(HAS_ARGBCOPYALPHAROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) &&
IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride_argb, 16) &&
@@ -2136,7 +2226,8 @@ int ARGBCopyAlpha(const uint8* src_argb, int src_stride_argb,
ARGBCopyAlphaRow = ARGBCopyAlphaRow_AVX2;
}
#endif
- for (int y = 0; y < height; ++y) {
+
+ for (y = 0; y < height; ++y) {
ARGBCopyAlphaRow(src_argb, dst_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
@@ -2149,6 +2240,9 @@ LIBYUV_API
int ARGBCopyYToAlpha(const uint8* src_y, int src_stride_y,
uint8* dst_argb, int dst_stride_argb,
int width, int height) {
+ int y;
+ void (*ARGBCopyYToAlphaRow)(const uint8* src_y, uint8* dst_argb, int width) =
+ ARGBCopyYToAlphaRow_C;
if (!src_y || !dst_argb || width <= 0 || height == 0) {
return -1;
}
@@ -2165,8 +2259,6 @@ int ARGBCopyYToAlpha(const uint8* src_y, int src_stride_y,
height = 1;
src_stride_y = dst_stride_argb = 0;
}
- void (*ARGBCopyYToAlphaRow)(const uint8* src_y, uint8* dst_argb, int width) =
- ARGBCopyYToAlphaRow_C;
#if defined(HAS_ARGBCOPYYTOALPHAROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) &&
IS_ALIGNED(src_y, 16) && IS_ALIGNED(src_stride_y, 16) &&
@@ -2180,7 +2272,8 @@ int ARGBCopyYToAlpha(const uint8* src_y, int src_stride_y,
ARGBCopyYToAlphaRow = ARGBCopyYToAlphaRow_AVX2;
}
#endif
- for (int y = 0; y < height; ++y) {
+
+ for (y = 0; y < height; ++y) {
ARGBCopyYToAlphaRow(src_y, dst_argb, width);
src_y += src_stride_y;
dst_argb += dst_stride_argb;