mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-17 06:48:33 +00:00
update libyuv to hash bcd8238 from https://chromium.googlesource.com/libyuv/libyuv/
This commit is contained in:
1 parent
d6bf6705de
commit
93591e2f47
93 files changed
+3194
-2023
No files matched your search
@@ -40,13 +40,14 @@ static int I4xxToI420(const uint8* src_y, int src_stride_y,
|
||||
const int dst_y_height = Abs(src_y_height);
|
||||
const int dst_uv_width = SUBSAMPLE(dst_y_width, 1, 1);
|
||||
const int dst_uv_height = SUBSAMPLE(dst_y_height, 1, 1);
|
||||
if (src_y_width == 0 || src_y_height == 0 ||
|
||||
src_uv_width == 0 || src_uv_height == 0) {
|
||||
if (src_uv_width == 0 || src_uv_height == 0) {
|
||||
return -1;
|
||||
}
|
||||
ScalePlane(src_y, src_stride_y, src_y_width, src_y_height,
|
||||
dst_y, dst_stride_y, dst_y_width, dst_y_height,
|
||||
kFilterBilinear);
|
||||
if (dst_y) {
|
||||
ScalePlane(src_y, src_stride_y, src_y_width, src_y_height,
|
||||
dst_y, dst_stride_y, dst_y_width, dst_y_height,
|
||||
kFilterBilinear);
|
||||
}
|
||||
ScalePlane(src_u, src_stride_u, src_uv_width, src_uv_height,
|
||||
dst_u, dst_stride_u, dst_uv_width, dst_uv_height,
|
||||
kFilterBilinear);
|
||||
@@ -69,8 +70,8 @@ int I420Copy(const uint8* src_y, int src_stride_y,
|
||||
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 ||
|
||||
if (!src_u || !src_v ||
|
||||
!dst_u || !dst_v ||
|
||||
width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -166,7 +167,7 @@ int I400ToI420(const uint8* src_y, int src_stride_y,
|
||||
int width, int height) {
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
if (!src_y || !dst_y || !dst_u || !dst_v ||
|
||||
if (!dst_u || !dst_v ||
|
||||
width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -177,7 +178,9 @@ int I400ToI420(const uint8* src_y, int src_stride_y,
|
||||
src_y = src_y + (height - 1) * src_stride_y;
|
||||
src_stride_y = -src_stride_y;
|
||||
}
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
if (dst_y) {
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
}
|
||||
SetPlane(dst_u, dst_stride_u, halfwidth, halfheight, 128);
|
||||
SetPlane(dst_v, dst_stride_v, halfwidth, halfheight, 128);
|
||||
return 0;
|
||||
@@ -242,13 +245,9 @@ static int X420ToI420(const uint8* src_y,
|
||||
uint8* dst_u, int dst_stride_u,
|
||||
uint8* dst_v, int dst_stride_v,
|
||||
int width, int height) {
|
||||
int y;
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v,
|
||||
int width) = SplitUVRow_C;
|
||||
if (!src_y || !src_uv ||
|
||||
!dst_y || !dst_u || !dst_v ||
|
||||
if (!src_uv || !dst_u || !dst_v ||
|
||||
width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -256,7 +255,9 @@ static int X420ToI420(const uint8* src_y,
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
halfheight = (height + 1) >> 1;
|
||||
dst_y = dst_y + (height - 1) * dst_stride_y;
|
||||
if (dst_y) {
|
||||
dst_y = dst_y + (height - 1) * dst_stride_y;
|
||||
}
|
||||
dst_u = dst_u + (halfheight - 1) * dst_stride_u;
|
||||
dst_v = dst_v + (halfheight - 1) * dst_stride_v;
|
||||
dst_stride_y = -dst_stride_y;
|
||||
@@ -279,41 +280,6 @@ static int X420ToI420(const uint8* src_y,
|
||||
halfheight = 1;
|
||||
src_stride_uv = dst_stride_u = dst_stride_v = 0;
|
||||
}
|
||||
#if defined(HAS_SPLITUVROW_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
SplitUVRow = SplitUVRow_Any_SSE2;
|
||||
if (IS_ALIGNED(halfwidth, 16)) {
|
||||
SplitUVRow = SplitUVRow_SSE2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
SplitUVRow = SplitUVRow_Any_AVX2;
|
||||
if (IS_ALIGNED(halfwidth, 32)) {
|
||||
SplitUVRow = SplitUVRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
SplitUVRow = SplitUVRow_Any_NEON;
|
||||
if (IS_ALIGNED(halfwidth, 16)) {
|
||||
SplitUVRow = SplitUVRow_NEON;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_DSPR2)
|
||||
if (TestCpuFlag(kCpuHasDSPR2) &&
|
||||
IS_ALIGNED(src_uv, 4) && IS_ALIGNED(src_stride_uv, 4) &&
|
||||
IS_ALIGNED(dst_u, 4) && IS_ALIGNED(dst_stride_u, 4) &&
|
||||
IS_ALIGNED(dst_v, 4) && IS_ALIGNED(dst_stride_v, 4)) {
|
||||
SplitUVRow = SplitUVRow_Any_DSPR2;
|
||||
if (IS_ALIGNED(halfwidth, 16)) {
|
||||
SplitUVRow = SplitUVRow_DSPR2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dst_y) {
|
||||
if (src_stride_y0 == src_stride_y1) {
|
||||
@@ -324,13 +290,10 @@ static int X420ToI420(const uint8* src_y,
|
||||
}
|
||||
}
|
||||
|
||||
for (y = 0; y < halfheight; ++y) {
|
||||
// Copy a row of UV.
|
||||
SplitUVRow(src_uv, dst_u, dst_v, halfwidth);
|
||||
dst_u += dst_stride_u;
|
||||
dst_v += dst_stride_v;
|
||||
src_uv += src_stride_uv;
|
||||
}
|
||||
// Split UV plane - NV12 / NV21
|
||||
SplitUVPlane(src_uv, src_stride_uv, dst_u, dst_stride_u, dst_v, dst_stride_v,
|
||||
halfwidth, halfheight);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1383,6 +1346,81 @@ int ARGB4444ToI420(const uint8* src_argb4444, int src_stride_argb4444,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SplitPixels(const uint8* src_u, int src_pixel_stride_uv,
|
||||
uint8* dst_u, int width) {
|
||||
int i;
|
||||
for (i = 0; i < width; ++i) {
|
||||
*dst_u = *src_u;
|
||||
++dst_u;
|
||||
src_u += src_pixel_stride_uv;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert Android420 to I420.
|
||||
LIBYUV_API
|
||||
int Android420ToI420(const uint8* src_y, int src_stride_y,
|
||||
const uint8* src_u, int src_stride_u,
|
||||
const uint8* src_v, int src_stride_v,
|
||||
int src_pixel_stride_uv,
|
||||
uint8* dst_y, int dst_stride_y,
|
||||
uint8* dst_u, int dst_stride_u,
|
||||
uint8* dst_v, int dst_stride_v,
|
||||
int width, int height) {
|
||||
int y;
|
||||
const int vu_off = src_v - src_u;
|
||||
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;
|
||||
}
|
||||
|
||||
if (dst_y) {
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
}
|
||||
|
||||
// Copy UV planes as is - I420
|
||||
if (src_pixel_stride_uv == 1) {
|
||||
CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, halfheight);
|
||||
CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, halfheight);
|
||||
return 0;
|
||||
// Split UV planes - NV21
|
||||
} else if (src_pixel_stride_uv == 2 && vu_off == -1 &&
|
||||
src_stride_u == src_stride_v) {
|
||||
SplitUVPlane(src_v, src_stride_v, dst_v, dst_stride_v, dst_u, dst_stride_u,
|
||||
halfwidth, halfheight);
|
||||
return 0;
|
||||
// Split UV planes - NV12
|
||||
} else if (src_pixel_stride_uv == 2 && vu_off == 1 &&
|
||||
src_stride_u == src_stride_v) {
|
||||
SplitUVPlane(src_u, src_stride_u, dst_u, dst_stride_u, dst_v, dst_stride_v,
|
||||
halfwidth, halfheight);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (y = 0; y < halfheight; ++y) {
|
||||
SplitPixels(src_u, src_pixel_stride_uv, dst_u, halfwidth);
|
||||
SplitPixels(src_v, src_pixel_stride_uv, dst_v, halfwidth);
|
||||
src_u += src_stride_u;
|
||||
src_v += src_stride_v;
|
||||
dst_u += dst_stride_u;
|
||||
dst_v += dst_stride_v;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#ifdef HAVE_JPEG
|
||||
#include "libyuv/mjpeg_decoder.h"
|
||||
#endif
|
||||
#include "libyuv/planar_functions.h" // For CopyPlane and ARGBShuffle.
|
||||
#include "libyuv/rotate_argb.h"
|
||||
#include "libyuv/row.h"
|
||||
#include "libyuv/video_common.h"
|
||||
|
||||
@@ -46,9 +46,11 @@ static int I420ToI4xx(const uint8* src_y, int src_stride_y,
|
||||
dst_uv_width <= 0 || dst_uv_height <= 0) {
|
||||
return -1;
|
||||
}
|
||||
ScalePlane(src_y, src_stride_y, src_y_width, src_y_height,
|
||||
dst_y, dst_stride_y, dst_y_width, dst_y_height,
|
||||
kFilterBilinear);
|
||||
if (dst_y) {
|
||||
ScalePlane(src_y, src_stride_y, src_y_width, src_y_height,
|
||||
dst_y, dst_stride_y, dst_y_width, dst_y_height,
|
||||
kFilterBilinear);
|
||||
}
|
||||
ScalePlane(src_u, src_stride_u, src_uv_width, src_uv_height,
|
||||
dst_u, dst_stride_u, dst_uv_width, dst_uv_height,
|
||||
kFilterBilinear);
|
||||
@@ -359,6 +361,7 @@ int I420ToUYVY(const uint8* src_y, int src_stride_y,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO(fbarchard): test negative height for invert.
|
||||
LIBYUV_API
|
||||
int I420ToNV12(const uint8* src_y, int src_stride_y,
|
||||
const uint8* src_u, int src_stride_u,
|
||||
@@ -366,72 +369,19 @@ int I420ToNV12(const uint8* src_y, int src_stride_y,
|
||||
uint8* dst_y, int dst_stride_y,
|
||||
uint8* dst_uv, int dst_stride_uv,
|
||||
int width, int height) {
|
||||
int y;
|
||||
void (*MergeUVRow_)(const uint8* src_u, const uint8* src_v, uint8* dst_uv,
|
||||
int width) = MergeUVRow_C;
|
||||
// Coalesce rows.
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
if (!src_y || !src_u || !src_v || !dst_y || !dst_uv ||
|
||||
width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
halfheight = (height + 1) >> 1;
|
||||
dst_y = dst_y + (height - 1) * dst_stride_y;
|
||||
dst_uv = dst_uv + (halfheight - 1) * dst_stride_uv;
|
||||
dst_stride_y = -dst_stride_y;
|
||||
dst_stride_uv = -dst_stride_uv;
|
||||
}
|
||||
if (src_stride_y == width &&
|
||||
dst_stride_y == width) {
|
||||
width *= height;
|
||||
height = 1;
|
||||
src_stride_y = dst_stride_y = 0;
|
||||
}
|
||||
// Coalesce rows.
|
||||
if (src_stride_u == halfwidth &&
|
||||
src_stride_v == halfwidth &&
|
||||
dst_stride_uv == halfwidth * 2) {
|
||||
halfwidth *= halfheight;
|
||||
halfheight = 1;
|
||||
src_stride_u = src_stride_v = dst_stride_uv = 0;
|
||||
}
|
||||
#if defined(HAS_MERGEUVROW_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
MergeUVRow_ = MergeUVRow_Any_SSE2;
|
||||
if (IS_ALIGNED(halfwidth, 16)) {
|
||||
MergeUVRow_ = MergeUVRow_SSE2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_MERGEUVROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
MergeUVRow_ = MergeUVRow_Any_AVX2;
|
||||
if (IS_ALIGNED(halfwidth, 32)) {
|
||||
MergeUVRow_ = MergeUVRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_MERGEUVROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
MergeUVRow_ = MergeUVRow_Any_NEON;
|
||||
if (IS_ALIGNED(halfwidth, 16)) {
|
||||
MergeUVRow_ = MergeUVRow_NEON;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
for (y = 0; y < halfheight; ++y) {
|
||||
// Merge a row of U and V into a row of UV.
|
||||
MergeUVRow_(src_u, src_v, dst_uv, halfwidth);
|
||||
src_u += src_stride_u;
|
||||
src_v += src_stride_v;
|
||||
dst_uv += dst_stride_uv;
|
||||
int halfwidth = (width + 1) / 2;
|
||||
int halfheight = height > 0 ? (height + 1) / 2 : (height - 1) / 2;
|
||||
if (dst_y) {
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
}
|
||||
MergeUVPlane(src_u, src_stride_u,
|
||||
src_v, src_stride_v,
|
||||
dst_uv, dst_stride_uv,
|
||||
halfwidth, halfheight);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1077,7 +1027,6 @@ int ConvertFromI420(const uint8* y, int y_stride,
|
||||
// Triplanar formats
|
||||
// TODO(fbarchard): halfstride instead of halfwidth
|
||||
case FOURCC_I420:
|
||||
case FOURCC_YU12:
|
||||
case FOURCC_YV12: {
|
||||
int halfwidth = (width + 1) / 2;
|
||||
int halfheight = (height + 1) / 2;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "libyuv/convert.h"
|
||||
#include "libyuv/convert_argb.h"
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
#include "libyuv/mjpeg_decoder.h"
|
||||
|
||||
@@ -176,7 +176,6 @@ int ConvertToARGB(const uint8* sample, size_t sample_size,
|
||||
break;
|
||||
// Triplanar formats
|
||||
case FOURCC_I420:
|
||||
case FOURCC_YU12:
|
||||
case FOURCC_YV12: {
|
||||
const uint8* src_y = sample + (src_width * crop_y + crop_x);
|
||||
const uint8* src_u;
|
||||
|
||||
@@ -39,12 +39,13 @@ int ConvertToI420(const uint8* sample,
|
||||
int aligned_src_width = (src_width + 1) & ~1;
|
||||
const uint8* src;
|
||||
const uint8* src_uv;
|
||||
int abs_src_height = (src_height < 0) ? -src_height : src_height;
|
||||
int inv_crop_height = (crop_height < 0) ? -crop_height : crop_height;
|
||||
const int abs_src_height = (src_height < 0) ? -src_height : src_height;
|
||||
// TODO(nisse): Why allow crop_height < 0?
|
||||
const int abs_crop_height = (crop_height < 0) ? -crop_height : crop_height;
|
||||
int r = 0;
|
||||
LIBYUV_BOOL need_buf = (rotation && format != FOURCC_I420 &&
|
||||
format != FOURCC_NV12 && format != FOURCC_NV21 &&
|
||||
format != FOURCC_YU12 && format != FOURCC_YV12) || y == sample;
|
||||
format != FOURCC_YV12) || y == sample;
|
||||
uint8* tmp_y = y;
|
||||
uint8* tmp_u = u;
|
||||
uint8* tmp_v = v;
|
||||
@@ -52,16 +53,14 @@ int ConvertToI420(const uint8* sample,
|
||||
int tmp_u_stride = u_stride;
|
||||
int tmp_v_stride = v_stride;
|
||||
uint8* rotate_buffer = NULL;
|
||||
int abs_crop_height = (crop_height < 0) ? -crop_height : crop_height;
|
||||
const int inv_crop_height =
|
||||
(src_height < 0) ? -abs_crop_height : abs_crop_height;
|
||||
|
||||
if (!y || !u || !v || !sample ||
|
||||
src_width <= 0 || crop_width <= 0 ||
|
||||
src_height == 0 || crop_height == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (src_height < 0) {
|
||||
inv_crop_height = -inv_crop_height;
|
||||
}
|
||||
|
||||
// One pass rotation is available for some formats. For the rest, convert
|
||||
// to I420 (with optional vertical flipping) into a temporary I420 buffer,
|
||||
@@ -214,7 +213,6 @@ int ConvertToI420(const uint8* sample,
|
||||
break;
|
||||
// Triplanar formats
|
||||
case FOURCC_I420:
|
||||
case FOURCC_YU12:
|
||||
case FOURCC_YV12: {
|
||||
const uint8* src_y = sample + (src_width * crop_y + crop_x);
|
||||
const uint8* src_u;
|
||||
|
||||
@@ -161,6 +161,38 @@ int ArmCpuCaps(const char* cpuinfo_name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
LIBYUV_API SAFEBUFFERS
|
||||
int MipsCpuCaps(const char* cpuinfo_name, const char ase[]) {
|
||||
char cpuinfo_line[512];
|
||||
int len = (int)strlen(ase);
|
||||
FILE* f = fopen(cpuinfo_name, "r");
|
||||
if (!f) {
|
||||
// ase enabled if /proc/cpuinfo is unavailable.
|
||||
if (strcmp(ase, " msa") == 0) {
|
||||
return kCpuHasMSA;
|
||||
}
|
||||
if (strcmp(ase, " dspr2") == 0) {
|
||||
return kCpuHasDSPR2;
|
||||
}
|
||||
}
|
||||
while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) {
|
||||
if (memcmp(cpuinfo_line, "ASEs implemented", 16) == 0) {
|
||||
char* p = strstr(cpuinfo_line, ase);
|
||||
if (p && (p[len] == ' ' || p[len] == '\n')) {
|
||||
fclose(f);
|
||||
if (strcmp(ase, " msa") == 0) {
|
||||
return kCpuHasMSA;
|
||||
}
|
||||
if (strcmp(ase, " dspr2") == 0) {
|
||||
return kCpuHasDSPR2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CPU detect function for SIMD instruction sets.
|
||||
LIBYUV_API
|
||||
int cpu_info_ = 0; // cpu_info is not initialized yet.
|
||||
@@ -253,11 +285,17 @@ int InitCpuFlags(void) {
|
||||
#if defined(__mips__) && defined(__linux__)
|
||||
#if defined(__mips_dspr2)
|
||||
cpu_info |= kCpuHasDSPR2;
|
||||
#endif
|
||||
#if defined(__mips_msa)
|
||||
cpu_info = MipsCpuCaps("/proc/cpuinfo", " msa");
|
||||
#endif
|
||||
cpu_info |= kCpuHasMIPS;
|
||||
if (getenv("LIBYUV_DISABLE_DSPR2")) {
|
||||
cpu_info &= ~kCpuHasDSPR2;
|
||||
}
|
||||
if (getenv("LIBYUV_DISABLE_MSA")) {
|
||||
cpu_info &= ~kCpuHasMSA;
|
||||
}
|
||||
#endif
|
||||
#if defined(__arm__) || defined(__aarch64__)
|
||||
// gcc -mfpu=neon defines __ARM_NEON__
|
||||
|
||||
@@ -62,6 +62,7 @@ void init_source(jpeg_decompress_struct* cinfo);
|
||||
void skip_input_data(jpeg_decompress_struct* cinfo, long num_bytes); // NOLINT
|
||||
void term_source(jpeg_decompress_struct* cinfo);
|
||||
void ErrorHandler(jpeg_common_struct* cinfo);
|
||||
void OutputHandler(jpeg_common_struct* cinfo);
|
||||
|
||||
MJpegDecoder::MJpegDecoder()
|
||||
: has_scanline_padding_(LIBYUV_FALSE),
|
||||
@@ -77,6 +78,7 @@ MJpegDecoder::MJpegDecoder()
|
||||
decompress_struct_->err = jpeg_std_error(&error_mgr_->base);
|
||||
// Override standard exit()-based error handler.
|
||||
error_mgr_->base.error_exit = &ErrorHandler;
|
||||
error_mgr_->base.output_message = &OutputHandler;
|
||||
#endif
|
||||
decompress_struct_->client_data = NULL;
|
||||
source_mgr_->init_source = &init_source;
|
||||
@@ -456,7 +458,12 @@ void ErrorHandler(j_common_ptr cinfo) {
|
||||
// and causes it to return (for a second time) with value 1.
|
||||
longjmp(mgr->setjmp_buffer, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
void OutputHandler(j_common_ptr cinfo) {
|
||||
// Suppress fprintf warnings.
|
||||
}
|
||||
|
||||
#endif // HAVE_SETJMP
|
||||
|
||||
void MJpegDecoder::AllocOutputBuffers(int num_outbufs) {
|
||||
if (num_outbufs != num_outbufs_) {
|
||||
|
||||
@@ -31,6 +31,12 @@ void CopyPlane(const uint8* src_y, int src_stride_y,
|
||||
int width, int height) {
|
||||
int y;
|
||||
void (*CopyRow)(const uint8* src, uint8* dst, int width) = CopyRow_C;
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
dst_y = dst_y + (height - 1) * dst_stride_y;
|
||||
dst_stride_y = -dst_stride_y;
|
||||
}
|
||||
// Coalesce rows.
|
||||
if (src_stride_y == width &&
|
||||
dst_stride_y == width) {
|
||||
@@ -76,6 +82,7 @@ void CopyPlane(const uint8* src_y, int src_stride_y,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(fbarchard): Consider support for negative height.
|
||||
LIBYUV_API
|
||||
void CopyPlane_16(const uint16* src_y, int src_stride_y,
|
||||
uint16* dst_y, int dst_stride_y,
|
||||
@@ -128,8 +135,8 @@ int I422Copy(const uint8* src_y, int src_stride_y,
|
||||
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 ||
|
||||
if (!src_u || !src_v ||
|
||||
!dst_u || !dst_v ||
|
||||
width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -143,7 +150,10 @@ int I422Copy(const uint8* src_y, int src_stride_y,
|
||||
src_stride_u = -src_stride_u;
|
||||
src_stride_v = -src_stride_v;
|
||||
}
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
|
||||
if (dst_y) {
|
||||
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);
|
||||
return 0;
|
||||
@@ -158,8 +168,8 @@ int I444Copy(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) {
|
||||
if (!src_y || !src_u || !src_v ||
|
||||
!dst_y || !dst_u || !dst_v ||
|
||||
if (!src_u || !src_v ||
|
||||
!dst_u || !dst_v ||
|
||||
width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -174,7 +184,9 @@ int I444Copy(const uint8* src_y, int src_stride_y,
|
||||
src_stride_v = -src_stride_v;
|
||||
}
|
||||
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
if (dst_y) {
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
}
|
||||
CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height);
|
||||
CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height);
|
||||
return 0;
|
||||
@@ -214,10 +226,138 @@ int I420ToI400(const uint8* src_y, int src_stride_y,
|
||||
src_y = src_y + (height - 1) * src_stride_y;
|
||||
src_stride_y = -src_stride_y;
|
||||
}
|
||||
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Support function for NV12 etc UV channels.
|
||||
// Width and height are plane sizes (typically half pixel width).
|
||||
LIBYUV_API
|
||||
void SplitUVPlane(const uint8* src_uv, int src_stride_uv,
|
||||
uint8* dst_u, int dst_stride_u,
|
||||
uint8* dst_v, int dst_stride_v,
|
||||
int width, int height) {
|
||||
int y;
|
||||
void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v,
|
||||
int width) = SplitUVRow_C;
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
dst_u = dst_u + (height - 1) * dst_stride_u;
|
||||
dst_v = dst_v + (height - 1) * dst_stride_v;
|
||||
dst_stride_u = -dst_stride_u;
|
||||
dst_stride_v = -dst_stride_v;
|
||||
}
|
||||
// Coalesce rows.
|
||||
if (src_stride_uv == width * 2 &&
|
||||
dst_stride_u == width &&
|
||||
dst_stride_v == width) {
|
||||
width *= height;
|
||||
height = 1;
|
||||
src_stride_uv = dst_stride_u = dst_stride_v = 0;
|
||||
}
|
||||
#if defined(HAS_SPLITUVROW_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
SplitUVRow = SplitUVRow_Any_SSE2;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
SplitUVRow = SplitUVRow_SSE2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
SplitUVRow = SplitUVRow_Any_AVX2;
|
||||
if (IS_ALIGNED(width, 32)) {
|
||||
SplitUVRow = SplitUVRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
SplitUVRow = SplitUVRow_Any_NEON;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
SplitUVRow = SplitUVRow_NEON;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_DSPR2)
|
||||
if (TestCpuFlag(kCpuHasDSPR2) &&
|
||||
IS_ALIGNED(dst_u, 4) && IS_ALIGNED(dst_stride_u, 4) &&
|
||||
IS_ALIGNED(dst_v, 4) && IS_ALIGNED(dst_stride_v, 4)) {
|
||||
SplitUVRow = SplitUVRow_Any_DSPR2;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
SplitUVRow = SplitUVRow_DSPR2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (y = 0; y < height; ++y) {
|
||||
// Copy a row of UV.
|
||||
SplitUVRow(src_uv, dst_u, dst_v, width);
|
||||
dst_u += dst_stride_u;
|
||||
dst_v += dst_stride_v;
|
||||
src_uv += src_stride_uv;
|
||||
}
|
||||
}
|
||||
|
||||
LIBYUV_API
|
||||
void MergeUVPlane(const uint8* src_u, int src_stride_u,
|
||||
const uint8* src_v, int src_stride_v,
|
||||
uint8* dst_uv, int dst_stride_uv,
|
||||
int width, int height) {
|
||||
int y;
|
||||
void (*MergeUVRow)(const uint8* src_u, const uint8* src_v, uint8* dst_uv,
|
||||
int width) = MergeUVRow_C;
|
||||
// Coalesce rows.
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
dst_uv = dst_uv + (height - 1) * dst_stride_uv;
|
||||
dst_stride_uv = -dst_stride_uv;
|
||||
}
|
||||
// Coalesce rows.
|
||||
if (src_stride_u == width &&
|
||||
src_stride_v == width &&
|
||||
dst_stride_uv == width * 2) {
|
||||
width *= height;
|
||||
height = 1;
|
||||
src_stride_u = src_stride_v = dst_stride_uv = 0;
|
||||
}
|
||||
#if defined(HAS_MERGEUVROW_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
MergeUVRow = MergeUVRow_Any_SSE2;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
MergeUVRow = MergeUVRow_SSE2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_MERGEUVROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
MergeUVRow = MergeUVRow_Any_AVX2;
|
||||
if (IS_ALIGNED(width, 32)) {
|
||||
MergeUVRow = MergeUVRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_MERGEUVROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
MergeUVRow = MergeUVRow_Any_NEON;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
MergeUVRow = MergeUVRow_NEON;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (y = 0; y < height; ++y) {
|
||||
// Merge a row of U and V into a row of UV.
|
||||
MergeUVRow(src_u, src_v, dst_uv, width);
|
||||
src_u += src_stride_u;
|
||||
src_v += src_stride_v;
|
||||
dst_uv += dst_stride_uv;
|
||||
}
|
||||
}
|
||||
|
||||
// Mirror a plane of data.
|
||||
void MirrorPlane(const uint8* src_y, int src_stride_y,
|
||||
uint8* dst_y, int dst_stride_y,
|
||||
@@ -261,6 +401,14 @@ void MirrorPlane(const uint8* src_y, int src_stride_y,
|
||||
IS_ALIGNED(dst_y, 4) && IS_ALIGNED(dst_stride_y, 4)) {
|
||||
MirrorRow = MirrorRow_DSPR2;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_MIRRORROW_MSA)
|
||||
if (TestCpuFlag(kCpuHasMSA)) {
|
||||
MirrorRow = MirrorRow_Any_MSA;
|
||||
if (IS_ALIGNED(width, 64)) {
|
||||
MirrorRow = MirrorRow_MSA;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Mirror plane
|
||||
@@ -511,6 +659,14 @@ int ARGBMirror(const uint8* src_argb, int src_stride_argb,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBMIRRORROW_MSA)
|
||||
if (TestCpuFlag(kCpuHasMSA)) {
|
||||
ARGBMirrorRow = ARGBMirrorRow_Any_MSA;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
ARGBMirrorRow = ARGBMirrorRow_MSA;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Mirror plane
|
||||
for (y = 0; y < height; ++y) {
|
||||
@@ -2374,6 +2530,49 @@ int ARGBCopyAlpha(const uint8* src_argb, int src_stride_argb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Extract just the alpha channel from ARGB.
|
||||
LIBYUV_API
|
||||
int ARGBExtractAlpha(const uint8* src_argb, int src_stride,
|
||||
uint8* dst_a, int dst_stride,
|
||||
int width, int height) {
|
||||
if (!src_argb || !dst_a || width <= 0 || height == 0) {
|
||||
return -1;
|
||||
}
|
||||
// Negative height means invert the image.
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
src_argb += (height - 1) * src_stride;
|
||||
src_stride = -src_stride;
|
||||
}
|
||||
// Coalesce rows.
|
||||
if (src_stride == width * 4 && dst_stride == width) {
|
||||
width *= height;
|
||||
height = 1;
|
||||
src_stride = dst_stride = 0;
|
||||
}
|
||||
void (*ARGBExtractAlphaRow)(const uint8 *src_argb, uint8 *dst_a, int width) =
|
||||
ARGBExtractAlphaRow_C;
|
||||
#if defined(HAS_ARGBEXTRACTALPHAROW_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
ARGBExtractAlphaRow = IS_ALIGNED(width, 8) ? ARGBExtractAlphaRow_SSE2
|
||||
: ARGBExtractAlphaRow_Any_SSE2;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBEXTRACTALPHAROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
ARGBExtractAlphaRow = IS_ALIGNED(width, 16) ? ARGBExtractAlphaRow_NEON
|
||||
: ARGBExtractAlphaRow_Any_NEON;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
ARGBExtractAlphaRow(src_argb, dst_a, width);
|
||||
src_argb += src_stride;
|
||||
dst_a += dst_stride;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Copy a planar Y channel to the alpha channel of a destination ARGB image.
|
||||
LIBYUV_API
|
||||
int ARGBCopyYToAlpha(const uint8* src_y, int src_stride_y,
|
||||
|
||||
@@ -141,6 +141,14 @@ void RotatePlane180(const uint8* src, int src_stride,
|
||||
MirrorRow = MirrorRow_DSPR2;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_MIRRORROW_MSA)
|
||||
if (TestCpuFlag(kCpuHasMSA)) {
|
||||
MirrorRow = MirrorRow_Any_MSA;
|
||||
if (IS_ALIGNED(width, 64)) {
|
||||
MirrorRow = MirrorRow_MSA;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_COPYROW_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
CopyRow = IS_ALIGNED(width, 32) ? CopyRow_SSE2 : CopyRow_Any_SSE2;
|
||||
|
||||
@@ -118,6 +118,14 @@ void ARGBRotate180(const uint8* src, int src_stride,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBMIRRORROW_MSA)
|
||||
if (TestCpuFlag(kCpuHasMSA)) {
|
||||
ARGBMirrorRow = ARGBMirrorRow_Any_MSA;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
ARGBMirrorRow = ARGBMirrorRow_MSA;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_COPYROW_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
CopyRow = IS_ALIGNED(width * 4, 32) ? CopyRow_SSE2 : CopyRow_Any_SSE2;
|
||||
|
||||
@@ -23,7 +23,7 @@ extern "C" {
|
||||
(_MIPS_SIM == _MIPS_SIM_ABI32)
|
||||
|
||||
void TransposeWx8_DSPR2(const uint8* src, int src_stride,
|
||||
uint8* dst, int dst_stride, int width) {
|
||||
uint8* dst, int dst_stride, int width) {
|
||||
__asm__ __volatile__ (
|
||||
".set push \n"
|
||||
".set noreorder \n"
|
||||
@@ -107,7 +107,7 @@ void TransposeWx8_DSPR2(const uint8* src, int src_stride,
|
||||
}
|
||||
|
||||
void TransposeWx8_Fast_DSPR2(const uint8* src, int src_stride,
|
||||
uint8* dst, int dst_stride, int width) {
|
||||
uint8* dst, int dst_stride, int width) {
|
||||
__asm__ __volatile__ (
|
||||
".set noat \n"
|
||||
".set push \n"
|
||||
@@ -309,9 +309,9 @@ void TransposeWx8_Fast_DSPR2(const uint8* src, int src_stride,
|
||||
}
|
||||
|
||||
void TransposeUVWx8_DSPR2(const uint8* src, int src_stride,
|
||||
uint8* dst_a, int dst_stride_a,
|
||||
uint8* dst_b, int dst_stride_b,
|
||||
int width) {
|
||||
uint8* dst_a, int dst_stride_a,
|
||||
uint8* dst_b, int dst_stride_b,
|
||||
int width) {
|
||||
__asm__ __volatile__ (
|
||||
".set push \n"
|
||||
".set noreorder \n"
|
||||
|
||||
@@ -466,38 +466,15 @@ ANY11(ARGBUnattenuateRow_Any_AVX2, ARGBUnattenuateRow_AVX2, 0, 4, 4, 7)
|
||||
#ifdef HAS_ARGBATTENUATEROW_NEON
|
||||
ANY11(ARGBAttenuateRow_Any_NEON, ARGBAttenuateRow_NEON, 0, 4, 4, 7)
|
||||
#endif
|
||||
#ifdef HAS_ARGBEXTRACTALPHAROW_SSE2
|
||||
ANY11(ARGBExtractAlphaRow_Any_SSE2, ARGBExtractAlphaRow_SSE2, 0, 4, 1, 7)
|
||||
#endif
|
||||
#ifdef HAS_ARGBEXTRACTALPHAROW_NEON
|
||||
ANY11(ARGBExtractAlphaRow_Any_NEON, ARGBExtractAlphaRow_NEON, 0, 4, 1, 15)
|
||||
#endif
|
||||
#undef ANY11
|
||||
|
||||
// Any 1 to 1 with yuvconstants
|
||||
#define ANY11C(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, BPP, MASK) \
|
||||
void NAMEANY(const uint8* src_ptr, uint8* dst_ptr, \
|
||||
const struct YuvConstants* yuvconstants, int width) { \
|
||||
SIMD_ALIGNED(uint8 temp[128 * 2]); \
|
||||
memset(temp, 0, 128); /* for YUY2 and msan */ \
|
||||
int r = width & MASK; \
|
||||
int n = width & ~MASK; \
|
||||
if (n > 0) { \
|
||||
ANY_SIMD(src_ptr, dst_ptr, yuvconstants, n); \
|
||||
} \
|
||||
memcpy(temp, src_ptr + (n >> UVSHIFT) * SBPP, SS(r, UVSHIFT) * SBPP); \
|
||||
ANY_SIMD(temp, temp + 128, yuvconstants, MASK + 1); \
|
||||
memcpy(dst_ptr + n * BPP, temp + 128, r * BPP); \
|
||||
}
|
||||
#if defined(HAS_YUY2TOARGBROW_SSSE3)
|
||||
ANY11C(YUY2ToARGBRow_Any_SSSE3, YUY2ToARGBRow_SSSE3, 1, 4, 4, 15)
|
||||
ANY11C(UYVYToARGBRow_Any_SSSE3, UYVYToARGBRow_SSSE3, 1, 4, 4, 15)
|
||||
#endif
|
||||
#if defined(HAS_YUY2TOARGBROW_AVX2)
|
||||
ANY11C(YUY2ToARGBRow_Any_AVX2, YUY2ToARGBRow_AVX2, 1, 4, 4, 31)
|
||||
ANY11C(UYVYToARGBRow_Any_AVX2, UYVYToARGBRow_AVX2, 1, 4, 4, 31)
|
||||
#endif
|
||||
#if defined(HAS_YUY2TOARGBROW_NEON)
|
||||
ANY11C(YUY2ToARGBRow_Any_NEON, YUY2ToARGBRow_NEON, 1, 4, 4, 7)
|
||||
ANY11C(UYVYToARGBRow_Any_NEON, UYVYToARGBRow_NEON, 1, 4, 4, 7)
|
||||
#endif
|
||||
#undef ANY11C
|
||||
|
||||
// Any 1 to 1 blended.
|
||||
// Any 1 to 1 blended. Destination is read, modify, write.
|
||||
#define ANY11B(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, BPP, MASK) \
|
||||
void NAMEANY(const uint8* src_ptr, uint8* dst_ptr, int width) { \
|
||||
SIMD_ALIGNED(uint8 temp[128 * 2]); \
|
||||
@@ -516,7 +493,7 @@ ANY11C(UYVYToARGBRow_Any_NEON, UYVYToARGBRow_NEON, 1, 4, 4, 7)
|
||||
#ifdef HAS_ARGBCOPYALPHAROW_AVX2
|
||||
ANY11B(ARGBCopyAlphaRow_Any_AVX2, ARGBCopyAlphaRow_AVX2, 0, 4, 4, 15)
|
||||
#endif
|
||||
#ifdef HAS_ARGBCOPYYTOALPHAROW_SSE2
|
||||
#ifdef HAS_ARGBCOPYALPHAROW_SSE2
|
||||
ANY11B(ARGBCopyAlphaRow_Any_SSE2, ARGBCopyAlphaRow_SSE2, 0, 4, 4, 7)
|
||||
#endif
|
||||
#ifdef HAS_ARGBCOPYYTOALPHAROW_AVX2
|
||||
@@ -569,6 +546,35 @@ ANY11P(ARGBShuffleRow_Any_NEON, ARGBShuffleRow_NEON, const uint8*, 4, 4, 3)
|
||||
#endif
|
||||
#undef ANY11P
|
||||
|
||||
// Any 1 to 1 with yuvconstants
|
||||
#define ANY11C(NAMEANY, ANY_SIMD, UVSHIFT, SBPP, BPP, MASK) \
|
||||
void NAMEANY(const uint8* src_ptr, uint8* dst_ptr, \
|
||||
const struct YuvConstants* yuvconstants, int width) { \
|
||||
SIMD_ALIGNED(uint8 temp[128 * 2]); \
|
||||
memset(temp, 0, 128); /* for YUY2 and msan */ \
|
||||
int r = width & MASK; \
|
||||
int n = width & ~MASK; \
|
||||
if (n > 0) { \
|
||||
ANY_SIMD(src_ptr, dst_ptr, yuvconstants, n); \
|
||||
} \
|
||||
memcpy(temp, src_ptr + (n >> UVSHIFT) * SBPP, SS(r, UVSHIFT) * SBPP); \
|
||||
ANY_SIMD(temp, temp + 128, yuvconstants, MASK + 1); \
|
||||
memcpy(dst_ptr + n * BPP, temp + 128, r * BPP); \
|
||||
}
|
||||
#if defined(HAS_YUY2TOARGBROW_SSSE3)
|
||||
ANY11C(YUY2ToARGBRow_Any_SSSE3, YUY2ToARGBRow_SSSE3, 1, 4, 4, 15)
|
||||
ANY11C(UYVYToARGBRow_Any_SSSE3, UYVYToARGBRow_SSSE3, 1, 4, 4, 15)
|
||||
#endif
|
||||
#if defined(HAS_YUY2TOARGBROW_AVX2)
|
||||
ANY11C(YUY2ToARGBRow_Any_AVX2, YUY2ToARGBRow_AVX2, 1, 4, 4, 31)
|
||||
ANY11C(UYVYToARGBRow_Any_AVX2, UYVYToARGBRow_AVX2, 1, 4, 4, 31)
|
||||
#endif
|
||||
#if defined(HAS_YUY2TOARGBROW_NEON)
|
||||
ANY11C(YUY2ToARGBRow_Any_NEON, YUY2ToARGBRow_NEON, 1, 4, 4, 7)
|
||||
ANY11C(UYVYToARGBRow_Any_NEON, UYVYToARGBRow_NEON, 1, 4, 4, 7)
|
||||
#endif
|
||||
#undef ANY11C
|
||||
|
||||
// Any 1 to 1 interpolate. Takes 2 rows of source via stride.
|
||||
#define ANY11T(NAMEANY, ANY_SIMD, SBPP, BPP, MASK) \
|
||||
void NAMEANY(uint8* dst_ptr, const uint8* src_ptr, \
|
||||
@@ -625,6 +631,9 @@ ANY11M(MirrorRow_Any_SSSE3, MirrorRow_SSSE3, 1, 15)
|
||||
#ifdef HAS_MIRRORROW_NEON
|
||||
ANY11M(MirrorRow_Any_NEON, MirrorRow_NEON, 1, 15)
|
||||
#endif
|
||||
#ifdef HAS_MIRRORROW_MSA
|
||||
ANY11M(MirrorRow_Any_MSA, MirrorRow_MSA, 1, 63)
|
||||
#endif
|
||||
#ifdef HAS_ARGBMIRRORROW_AVX2
|
||||
ANY11M(ARGBMirrorRow_Any_AVX2, ARGBMirrorRow_AVX2, 4, 7)
|
||||
#endif
|
||||
@@ -634,6 +643,9 @@ ANY11M(ARGBMirrorRow_Any_SSE2, ARGBMirrorRow_SSE2, 4, 3)
|
||||
#ifdef HAS_ARGBMIRRORROW_NEON
|
||||
ANY11M(ARGBMirrorRow_Any_NEON, ARGBMirrorRow_NEON, 4, 3)
|
||||
#endif
|
||||
#ifdef HAS_ARGBMIRRORROW_MSA
|
||||
ANY11M(ARGBMirrorRow_Any_MSA, ARGBMirrorRow_MSA, 4, 15)
|
||||
#endif
|
||||
#undef ANY11M
|
||||
|
||||
// Any 1 plane. (memset)
|
||||
|
||||
@@ -988,8 +988,8 @@ void J400ToARGBRow_C(const uint8* src_y, uint8* dst_argb, int width) {
|
||||
#define BG (UG * 128 + VG * 128 + YGB)
|
||||
#define BR (VR * 128 + YGB)
|
||||
|
||||
#if defined(__aarch64__)
|
||||
const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = {
|
||||
#if defined(__aarch64__) // 64 bit arm
|
||||
const struct YuvConstants SIMD_ALIGNED(kYuvI601Constants) = {
|
||||
{ -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR },
|
||||
{ -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR },
|
||||
{ UG, VG, UG, VG, UG, VG, UG, VG },
|
||||
@@ -997,7 +997,7 @@ const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = {
|
||||
{ BB, BG, BR, 0, 0, 0, 0, 0 },
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYvuI601Constants) = {
|
||||
{ -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB },
|
||||
{ -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB },
|
||||
{ VG, UG, VG, UG, VG, UG, VG, UG },
|
||||
@@ -1005,21 +1005,21 @@ const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = {
|
||||
{ BR, BG, BB, 0, 0, 0, 0, 0 },
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
#elif defined(__arm__)
|
||||
const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = {
|
||||
#elif defined(__arm__) // 32 bit arm
|
||||
const struct YuvConstants SIMD_ALIGNED(kYuvI601Constants) = {
|
||||
{ -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ BB, BG, BR, 0, 0, 0, 0, 0 },
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYvuI601Constants) = {
|
||||
{ -VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ BR, BG, BB, 0, 0, 0, 0, 0 },
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
#else
|
||||
const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYuvI601Constants) = {
|
||||
{ UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0,
|
||||
UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0 },
|
||||
{ UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG,
|
||||
@@ -1031,7 +1031,7 @@ const YuvConstants SIMD_ALIGNED(kYuvI601Constants) = {
|
||||
{ BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR },
|
||||
{ YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG }
|
||||
};
|
||||
const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYvuI601Constants) = {
|
||||
{ VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0,
|
||||
VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0 },
|
||||
{ VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG,
|
||||
@@ -1076,7 +1076,7 @@ const YuvConstants SIMD_ALIGNED(kYvuI601Constants) = {
|
||||
#define BR (VR * 128 + YGB)
|
||||
|
||||
#if defined(__aarch64__)
|
||||
const YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = {
|
||||
{ -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR },
|
||||
{ -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR },
|
||||
{ UG, VG, UG, VG, UG, VG, UG, VG },
|
||||
@@ -1084,7 +1084,7 @@ const YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = {
|
||||
{ BB, BG, BR, 0, 0, 0, 0, 0 },
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
const YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = {
|
||||
{ -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB },
|
||||
{ -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB },
|
||||
{ VG, UG, VG, UG, VG, UG, VG, UG },
|
||||
@@ -1093,20 +1093,20 @@ const YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = {
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
#elif defined(__arm__)
|
||||
const YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = {
|
||||
{ -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ BB, BG, BR, 0, 0, 0, 0, 0 },
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
const YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = {
|
||||
{ -VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ BR, BG, BB, 0, 0, 0, 0, 0 },
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
#else
|
||||
const YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = {
|
||||
{ UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0,
|
||||
UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0 },
|
||||
{ UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG,
|
||||
@@ -1118,7 +1118,7 @@ const YuvConstants SIMD_ALIGNED(kYuvJPEGConstants) = {
|
||||
{ BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR },
|
||||
{ YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG }
|
||||
};
|
||||
const YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = {
|
||||
{ VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0,
|
||||
VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0 },
|
||||
{ VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG,
|
||||
@@ -1164,7 +1164,7 @@ const YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = {
|
||||
#define BR (VR * 128 + YGB)
|
||||
|
||||
#if defined(__aarch64__)
|
||||
const YuvConstants SIMD_ALIGNED(kYuvH709Constants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYuvH709Constants) = {
|
||||
{ -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR },
|
||||
{ -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR },
|
||||
{ UG, VG, UG, VG, UG, VG, UG, VG },
|
||||
@@ -1172,7 +1172,7 @@ const YuvConstants SIMD_ALIGNED(kYuvH709Constants) = {
|
||||
{ BB, BG, BR, 0, 0, 0, 0, 0 },
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
const YuvConstants SIMD_ALIGNED(kYvuH709Constants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYvuH709Constants) = {
|
||||
{ -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB },
|
||||
{ -VR, -UB, -VR, -UB, -VR, -UB, -VR, -UB },
|
||||
{ VG, UG, VG, UG, VG, UG, VG, UG },
|
||||
@@ -1181,20 +1181,20 @@ const YuvConstants SIMD_ALIGNED(kYvuH709Constants) = {
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
#elif defined(__arm__)
|
||||
const YuvConstants SIMD_ALIGNED(kYuvH709Constants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYuvH709Constants) = {
|
||||
{ -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ BB, BG, BR, 0, 0, 0, 0, 0 },
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
const YuvConstants SIMD_ALIGNED(kYvuH709Constants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYvuH709Constants) = {
|
||||
{ -VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ BR, BG, BB, 0, 0, 0, 0, 0 },
|
||||
{ 0x0101 * YG, 0, 0, 0 }
|
||||
};
|
||||
#else
|
||||
const YuvConstants SIMD_ALIGNED(kYuvH709Constants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYuvH709Constants) = {
|
||||
{ UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0,
|
||||
UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0 },
|
||||
{ UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG,
|
||||
@@ -1206,7 +1206,7 @@ const YuvConstants SIMD_ALIGNED(kYuvH709Constants) = {
|
||||
{ BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR, BR },
|
||||
{ YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG, YG }
|
||||
};
|
||||
const YuvConstants SIMD_ALIGNED(kYvuH709Constants) = {
|
||||
const struct YuvConstants SIMD_ALIGNED(kYvuH709Constants) = {
|
||||
{ VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0,
|
||||
VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0 },
|
||||
{ VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG,
|
||||
@@ -1264,9 +1264,9 @@ static __inline void YuvPixel(uint8 y, uint8 u, uint8 v,
|
||||
#endif
|
||||
|
||||
uint32 y1 = (uint32)(y * 0x0101 * yg) >> 16;
|
||||
*b = Clamp((int32)(-(u * ub ) + y1 + bb) >> 6);
|
||||
*b = Clamp((int32)(-(u * ub) + y1 + bb) >> 6);
|
||||
*g = Clamp((int32)(-(u * ug + v * vg) + y1 + bg) >> 6);
|
||||
*r = Clamp((int32)(-( v * vr) + y1 + br) >> 6);
|
||||
*r = Clamp((int32) (-(v * vr) + y1 + br) >> 6);
|
||||
}
|
||||
|
||||
// Y contribution to R,G,B. Scale and bias.
|
||||
@@ -2167,7 +2167,7 @@ static void HalfRow_16_C(const uint16* src_uv, ptrdiff_t src_uv_stride,
|
||||
void InterpolateRow_C(uint8* dst_ptr, const uint8* src_ptr,
|
||||
ptrdiff_t src_stride,
|
||||
int width, int source_y_fraction) {
|
||||
int y1_fraction = source_y_fraction ;
|
||||
int y1_fraction = source_y_fraction;
|
||||
int y0_fraction = 256 - y1_fraction;
|
||||
const uint8* src_ptr1 = src_ptr + src_stride;
|
||||
int x;
|
||||
@@ -2381,6 +2381,19 @@ void ARGBCopyAlphaRow_C(const uint8* src, uint8* dst, int width) {
|
||||
}
|
||||
}
|
||||
|
||||
void ARGBExtractAlphaRow_C(const uint8* src_argb, uint8* dst_a, int width) {
|
||||
int i;
|
||||
for (i = 0; i < width - 1; i += 2) {
|
||||
dst_a[0] = src_argb[3];
|
||||
dst_a[1] = src_argb[7];
|
||||
dst_a += 2;
|
||||
src_argb += 8;
|
||||
}
|
||||
if (width & 1) {
|
||||
dst_a[0] = src_argb[3];
|
||||
}
|
||||
}
|
||||
|
||||
void ARGBCopyYToAlphaRow_C(const uint8* src, uint8* dst, int width) {
|
||||
int i;
|
||||
for (i = 0; i < width - 1; i += 2) {
|
||||
@@ -2491,7 +2504,7 @@ void I422ToRGB565Row_AVX2(const uint8* src_y,
|
||||
uint8* dst_rgb565,
|
||||
const struct YuvConstants* yuvconstants,
|
||||
int width) {
|
||||
SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]);
|
||||
SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]);
|
||||
while (width > 0) {
|
||||
int twidth = width > MAXTWIDTH ? MAXTWIDTH : width;
|
||||
I422ToARGBRow_AVX2(src_y, src_u, src_v, row, yuvconstants, twidth);
|
||||
@@ -2517,7 +2530,7 @@ void I422ToARGB1555Row_AVX2(const uint8* src_y,
|
||||
const struct YuvConstants* yuvconstants,
|
||||
int width) {
|
||||
// Row buffer for intermediate ARGB pixels.
|
||||
SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]);
|
||||
SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]);
|
||||
while (width > 0) {
|
||||
int twidth = width > MAXTWIDTH ? MAXTWIDTH : width;
|
||||
I422ToARGBRow_AVX2(src_y, src_u, src_v, row, yuvconstants, twidth);
|
||||
@@ -2543,7 +2556,7 @@ void I422ToARGB4444Row_AVX2(const uint8* src_y,
|
||||
const struct YuvConstants* yuvconstants,
|
||||
int width) {
|
||||
// Row buffer for intermediate ARGB pixels.
|
||||
SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]);
|
||||
SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]);
|
||||
while (width > 0) {
|
||||
int twidth = width > MAXTWIDTH ? MAXTWIDTH : width;
|
||||
I422ToARGBRow_AVX2(src_y, src_u, src_v, row, yuvconstants, twidth);
|
||||
@@ -2569,7 +2582,7 @@ void I422ToRGB24Row_AVX2(const uint8* src_y,
|
||||
const struct YuvConstants* yuvconstants,
|
||||
int width) {
|
||||
// Row buffer for intermediate ARGB pixels.
|
||||
SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]);
|
||||
SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]);
|
||||
while (width > 0) {
|
||||
int twidth = width > MAXTWIDTH ? MAXTWIDTH : width;
|
||||
I422ToARGBRow_AVX2(src_y, src_u, src_v, row, yuvconstants, twidth);
|
||||
@@ -2591,7 +2604,7 @@ void NV12ToRGB565Row_AVX2(const uint8* src_y,
|
||||
const struct YuvConstants* yuvconstants,
|
||||
int width) {
|
||||
// Row buffer for intermediate ARGB pixels.
|
||||
SIMD_ALIGNED32(uint8 row[MAXTWIDTH * 4]);
|
||||
SIMD_ALIGNED(uint8 row[MAXTWIDTH * 4]);
|
||||
while (width > 0) {
|
||||
int twidth = width > MAXTWIDTH ? MAXTWIDTH : width;
|
||||
NV12ToARGBRow_AVX2(src_y, src_uv, row, yuvconstants, twidth);
|
||||
|
||||
@@ -2936,6 +2936,33 @@ void ARGBCopyAlphaRow_AVX2(const uint8* src, uint8* dst, int width) {
|
||||
}
|
||||
#endif // HAS_ARGBCOPYALPHAROW_AVX2
|
||||
|
||||
#ifdef HAS_ARGBEXTRACTALPHAROW_SSE2
|
||||
// width in pixels
|
||||
void ARGBExtractAlphaRow_SSE2(const uint8* src_argb, uint8* dst_a, int width) {
|
||||
asm volatile (
|
||||
LABELALIGN
|
||||
"1: \n"
|
||||
"movdqu " MEMACCESS(0) ", %%xmm0 \n"
|
||||
"movdqu " MEMACCESS2(0x10, 0) ", %%xmm1 \n"
|
||||
"lea " MEMLEA(0x20, 0) ", %0 \n"
|
||||
"psrld $0x18, %%xmm0 \n"
|
||||
"psrld $0x18, %%xmm1 \n"
|
||||
"packssdw %%xmm1, %%xmm0 \n"
|
||||
"packuswb %%xmm0, %%xmm0 \n"
|
||||
"movq %%xmm0," MEMACCESS(1) " \n"
|
||||
"lea " MEMLEA(0x8, 1) ", %1 \n"
|
||||
"sub $0x8, %2 \n"
|
||||
"jg 1b \n"
|
||||
: "+r"(src_argb), // %0
|
||||
"+r"(dst_a), // %1
|
||||
"+rm"(width) // %2
|
||||
:
|
||||
: "memory", "cc"
|
||||
, "xmm0", "xmm1"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBEXTRACTALPHAROW_SSE2
|
||||
|
||||
#ifdef HAS_ARGBCOPYYTOALPHAROW_SSE2
|
||||
// width in pixels
|
||||
void ARGBCopyYToAlphaRow_SSE2(const uint8* src, uint8* dst, int width) {
|
||||
@@ -3569,7 +3596,7 @@ void BlendPlaneRow_SSSE3(const uint8* src0, const uint8* src1,
|
||||
"+r"(src1), // %1
|
||||
"+r"(alpha), // %2
|
||||
"+r"(dst), // %3
|
||||
"+r"(width) // %4
|
||||
"+rm"(width) // %4
|
||||
:: "memory", "cc", "eax", "xmm0", "xmm1", "xmm2", "xmm5", "xmm6", "xmm7"
|
||||
);
|
||||
}
|
||||
@@ -3626,7 +3653,7 @@ void BlendPlaneRow_AVX2(const uint8* src0, const uint8* src1,
|
||||
"+r"(src1), // %1
|
||||
"+r"(alpha), // %2
|
||||
"+r"(dst), // %3
|
||||
"+r"(width) // %4
|
||||
"+rm"(width) // %4
|
||||
:: "memory", "cc", "eax",
|
||||
"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"
|
||||
);
|
||||
@@ -4909,9 +4936,9 @@ void InterpolateRow_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
|
||||
"jg 100b \n"
|
||||
|
||||
"99: \n"
|
||||
: "+r"(dst_ptr), // %0
|
||||
"+r"(src_ptr), // %1
|
||||
"+r"(dst_width), // %2
|
||||
: "+r"(dst_ptr), // %0
|
||||
"+r"(src_ptr), // %1
|
||||
"+rm"(dst_width), // %2
|
||||
"+r"(source_y_fraction) // %3
|
||||
: "r"((intptr_t)(src_stride)) // %4
|
||||
: "memory", "cc", "eax", NACL_R14
|
||||
@@ -4987,7 +5014,7 @@ void InterpolateRow_AVX2(uint8* dst_ptr, const uint8* src_ptr,
|
||||
"999: \n"
|
||||
: "+D"(dst_ptr), // %0
|
||||
"+S"(src_ptr), // %1
|
||||
"+c"(dst_width), // %2
|
||||
"+cm"(dst_width), // %2
|
||||
"+r"(source_y_fraction) // %3
|
||||
: "r"((intptr_t)(src_stride)) // %4
|
||||
: "memory", "cc", "eax", NACL_R14
|
||||
|
||||
@@ -381,7 +381,7 @@ void CopyRow_MIPS(const uint8* src, uint8* dst, int count) {
|
||||
(_MIPS_SIM == _MIPS_SIM_ABI32) && (__mips_isa_rev < 6)
|
||||
|
||||
void SplitUVRow_DSPR2(const uint8* src_uv, uint8* dst_u, uint8* dst_v,
|
||||
int width) {
|
||||
int width) {
|
||||
__asm__ __volatile__ (
|
||||
".set push \n"
|
||||
".set noreorder \n"
|
||||
@@ -497,7 +497,7 @@ void MirrorRow_DSPR2(const uint8* src, uint8* dst, int width) {
|
||||
}
|
||||
|
||||
void MirrorUVRow_DSPR2(const uint8* src_uv, uint8* dst_u, uint8* dst_v,
|
||||
int width) {
|
||||
int width) {
|
||||
int x;
|
||||
int y;
|
||||
__asm__ __volatile__ (
|
||||
@@ -654,11 +654,11 @@ void MirrorUVRow_DSPR2(const uint8* src_uv, uint8* dst_u, uint8* dst_v,
|
||||
|
||||
// TODO(fbarchard): accept yuv conversion constants.
|
||||
void I422ToARGBRow_DSPR2(const uint8* y_buf,
|
||||
const uint8* u_buf,
|
||||
const uint8* v_buf,
|
||||
uint8* rgb_buf,
|
||||
const struct YuvConstants* yuvconstants,
|
||||
int width) {
|
||||
const uint8* u_buf,
|
||||
const uint8* v_buf,
|
||||
uint8* rgb_buf,
|
||||
const struct YuvConstants* yuvconstants,
|
||||
int width) {
|
||||
__asm__ __volatile__ (
|
||||
".set push \n"
|
||||
".set noreorder \n"
|
||||
@@ -717,8 +717,8 @@ void I422ToARGBRow_DSPR2(const uint8* y_buf,
|
||||
|
||||
// Bilinear filter 8x2 -> 8x1
|
||||
void InterpolateRow_DSPR2(uint8* dst_ptr, const uint8* src_ptr,
|
||||
ptrdiff_t src_stride, int dst_width,
|
||||
int source_y_fraction) {
|
||||
ptrdiff_t src_stride, int dst_width,
|
||||
int source_y_fraction) {
|
||||
int y0_fraction = 256 - source_y_fraction;
|
||||
const uint8* src_ptr1 = src_ptr + src_stride;
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2016 The LibYuv Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "libyuv/row.h"
|
||||
|
||||
// This module is for GCC MSA
|
||||
#if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
|
||||
#include "libyuv/macros_msa.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void MirrorRow_MSA(const uint8* src, uint8* dst, int width) {
|
||||
int x;
|
||||
v16u8 src0, src1, src2, src3;
|
||||
v16u8 dst0, dst1, dst2, dst3;
|
||||
v16i8 shuffler = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
|
||||
src += width - 64;
|
||||
|
||||
for (x = 0; x < width; x += 64) {
|
||||
LD_UB4(src, 16, src3, src2, src1, src0);
|
||||
VSHF_B2_UB(src3, src3, src2, src2, shuffler, shuffler, dst3, dst2);
|
||||
VSHF_B2_UB(src1, src1, src0, src0, shuffler, shuffler, dst1, dst0);
|
||||
ST_UB4(dst0, dst1, dst2, dst3, dst, 16);
|
||||
dst += 64;
|
||||
src -= 64;
|
||||
}
|
||||
}
|
||||
|
||||
void ARGBMirrorRow_MSA(const uint8* src, uint8* dst, int width) {
|
||||
int x;
|
||||
v16u8 src0, src1, src2, src3;
|
||||
v16u8 dst0, dst1, dst2, dst3;
|
||||
v16i8 shuffler = { 12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3 };
|
||||
src += width * 4 - 64;
|
||||
|
||||
for (x = 0; x < width; x += 16) {
|
||||
LD_UB4(src, 16, src3, src2, src1, src0);
|
||||
VSHF_B2_UB(src3, src3, src2, src2, shuffler, shuffler, dst3, dst2);
|
||||
VSHF_B2_UB(src1, src1, src0, src0, shuffler, shuffler, dst1, dst0);
|
||||
ST_UB4(dst0, dst1, dst2, dst3, dst, 16);
|
||||
dst += 64;
|
||||
src -= 64;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
|
||||
@@ -1298,6 +1298,24 @@ void ARGBToYRow_NEON(const uint8* src_argb, uint8* dst_y, int width) {
|
||||
);
|
||||
}
|
||||
|
||||
void ARGBExtractAlphaRow_NEON(const uint8* src_argb, uint8* dst_a, int width) {
|
||||
asm volatile (
|
||||
"1: \n"
|
||||
MEMACCESS(0)
|
||||
"vld4.8 {d0, d2, d4, d6}, [%0]! \n" // load 8 ARGB pixels
|
||||
"vld4.8 {d1, d3, d5, d7}, [%0]! \n" // load next 8 ARGB pixels
|
||||
"subs %2, %2, #16 \n" // 16 processed per loop
|
||||
MEMACCESS(1)
|
||||
"vst1.8 {q3}, [%1]! \n" // store 16 A's.
|
||||
"bgt 1b \n"
|
||||
: "+r"(src_argb), // %0
|
||||
"+r"(dst_a), // %1
|
||||
"+r"(width) // %2
|
||||
:
|
||||
: "cc", "memory", "q0", "q1", "q2", "q3" // Clobber List
|
||||
);
|
||||
}
|
||||
|
||||
void ARGBToYJRow_NEON(const uint8* src_argb, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"vmov.u8 d24, #15 \n" // B * 0.11400 coefficient
|
||||
@@ -2565,8 +2583,6 @@ void ARGBColorMatrixRow_NEON(const uint8* src_argb, uint8* dst_argb,
|
||||
);
|
||||
}
|
||||
|
||||
// TODO(fbarchard): fix vqshrun in ARGBMultiplyRow_NEON and reenable.
|
||||
#ifdef HAS_ARGBMULTIPLYROW_NEON
|
||||
// Multiply 2 rows of ARGB pixels together, 8 pixels at a time.
|
||||
void ARGBMultiplyRow_NEON(const uint8* src_argb0, const uint8* src_argb1,
|
||||
uint8* dst_argb, int width) {
|
||||
@@ -2598,7 +2614,6 @@ void ARGBMultiplyRow_NEON(const uint8* src_argb0, const uint8* src_argb1,
|
||||
: "cc", "memory", "q0", "q1", "q2", "q3"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBMULTIPLYROW_NEON
|
||||
|
||||
// Add 2 rows of ARGB pixels together, 8 pixels at a time.
|
||||
void ARGBAddRow_NEON(const uint8* src_argb0, const uint8* src_argb1,
|
||||
|
||||
@@ -127,7 +127,6 @@ extern "C" {
|
||||
"sqshrun " #vG ".8b, " #vG ".8h, #6 \n" /* G */ \
|
||||
"sqshrun " #vR ".8b, " #vR ".8h, #6 \n" /* R */ \
|
||||
|
||||
#ifdef HAS_I444TOARGBROW_NEON
|
||||
void I444ToARGBRow_NEON(const uint8* src_y,
|
||||
const uint8* src_u,
|
||||
const uint8* src_v,
|
||||
@@ -157,9 +156,7 @@ void I444ToARGBRow_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I444TOARGBROW_NEON
|
||||
|
||||
#ifdef HAS_I422TOARGBROW_NEON
|
||||
void I422ToARGBRow_NEON(const uint8* src_y,
|
||||
const uint8* src_u,
|
||||
const uint8* src_v,
|
||||
@@ -189,9 +186,7 @@ void I422ToARGBRow_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I422TOARGBROW_NEON
|
||||
|
||||
#ifdef HAS_I422ALPHATOARGBROW_NEON
|
||||
void I422AlphaToARGBRow_NEON(const uint8* src_y,
|
||||
const uint8* src_u,
|
||||
const uint8* src_v,
|
||||
@@ -224,9 +219,7 @@ void I422AlphaToARGBRow_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I422ALPHATOARGBROW_NEON
|
||||
|
||||
#ifdef HAS_I411TOARGBROW_NEON
|
||||
void I411ToARGBRow_NEON(const uint8* src_y,
|
||||
const uint8* src_u,
|
||||
const uint8* src_v,
|
||||
@@ -256,9 +249,7 @@ void I411ToARGBRow_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I411TOARGBROW_NEON
|
||||
|
||||
#ifdef HAS_I422TORGBAROW_NEON
|
||||
void I422ToRGBARow_NEON(const uint8* src_y,
|
||||
const uint8* src_u,
|
||||
const uint8* src_v,
|
||||
@@ -288,9 +279,7 @@ void I422ToRGBARow_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I422TORGBAROW_NEON
|
||||
|
||||
#ifdef HAS_I422TORGB24ROW_NEON
|
||||
void I422ToRGB24Row_NEON(const uint8* src_y,
|
||||
const uint8* src_u,
|
||||
const uint8* src_v,
|
||||
@@ -319,7 +308,6 @@ void I422ToRGB24Row_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I422TORGB24ROW_NEON
|
||||
|
||||
#define ARGBTORGB565 \
|
||||
"shll v0.8h, v22.8b, #8 \n" /* R */ \
|
||||
@@ -328,7 +316,6 @@ void I422ToRGB24Row_NEON(const uint8* src_y,
|
||||
"sri v0.8h, v21.8h, #5 \n" /* RG */ \
|
||||
"sri v0.8h, v20.8h, #11 \n" /* RGB */
|
||||
|
||||
#ifdef HAS_I422TORGB565ROW_NEON
|
||||
void I422ToRGB565Row_NEON(const uint8* src_y,
|
||||
const uint8* src_u,
|
||||
const uint8* src_v,
|
||||
@@ -358,7 +345,6 @@ void I422ToRGB565Row_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I422TORGB565ROW_NEON
|
||||
|
||||
#define ARGBTOARGB1555 \
|
||||
"shll v0.8h, v23.8b, #8 \n" /* A */ \
|
||||
@@ -369,7 +355,6 @@ void I422ToRGB565Row_NEON(const uint8* src_y,
|
||||
"sri v0.8h, v21.8h, #6 \n" /* ARG */ \
|
||||
"sri v0.8h, v20.8h, #11 \n" /* ARGB */
|
||||
|
||||
#ifdef HAS_I422TOARGB1555ROW_NEON
|
||||
void I422ToARGB1555Row_NEON(const uint8* src_y,
|
||||
const uint8* src_u,
|
||||
const uint8* src_v,
|
||||
@@ -400,7 +385,6 @@ void I422ToARGB1555Row_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I422TOARGB1555ROW_NEON
|
||||
|
||||
#define ARGBTOARGB4444 \
|
||||
/* Input v20.8b<=B, v21.8b<=G, v22.8b<=R, v23.8b<=A, v4.8b<=0x0f */ \
|
||||
@@ -412,7 +396,6 @@ void I422ToARGB1555Row_NEON(const uint8* src_y,
|
||||
"orr v1.8b, v22.8b, v23.8b \n" /* RA */ \
|
||||
"zip1 v0.16b, v0.16b, v1.16b \n" /* BGRA */
|
||||
|
||||
#ifdef HAS_I422TOARGB4444ROW_NEON
|
||||
void I422ToARGB4444Row_NEON(const uint8* src_y,
|
||||
const uint8* src_u,
|
||||
const uint8* src_v,
|
||||
@@ -444,13 +427,10 @@ void I422ToARGB4444Row_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I422TOARGB4444ROW_NEON
|
||||
|
||||
#ifdef HAS_I400TOARGBROW_NEON
|
||||
void I400ToARGBRow_NEON(const uint8* src_y,
|
||||
uint8* dst_argb,
|
||||
int width) {
|
||||
int64 width64 = (int64)(width);
|
||||
asm volatile (
|
||||
YUVTORGB_SETUP
|
||||
"movi v23.8b, #255 \n"
|
||||
@@ -463,7 +443,7 @@ void I400ToARGBRow_NEON(const uint8* src_y,
|
||||
"b.gt 1b \n"
|
||||
: "+r"(src_y), // %0
|
||||
"+r"(dst_argb), // %1
|
||||
"+r"(width64) // %2
|
||||
"+r"(width) // %2
|
||||
: [kUVToRB]"r"(&kYuvI601Constants.kUVToRB),
|
||||
[kUVToG]"r"(&kYuvI601Constants.kUVToG),
|
||||
[kUVBiasBGR]"r"(&kYuvI601Constants.kUVBiasBGR),
|
||||
@@ -472,9 +452,7 @@ void I400ToARGBRow_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I400TOARGBROW_NEON
|
||||
|
||||
#ifdef HAS_J400TOARGBROW_NEON
|
||||
void J400ToARGBRow_NEON(const uint8* src_y,
|
||||
uint8* dst_argb,
|
||||
int width) {
|
||||
@@ -496,9 +474,7 @@ void J400ToARGBRow_NEON(const uint8* src_y,
|
||||
: "cc", "memory", "v20", "v21", "v22", "v23"
|
||||
);
|
||||
}
|
||||
#endif // HAS_J400TOARGBROW_NEON
|
||||
|
||||
#ifdef HAS_NV12TOARGBROW_NEON
|
||||
void NV12ToARGBRow_NEON(const uint8* src_y,
|
||||
const uint8* src_uv,
|
||||
uint8* dst_argb,
|
||||
@@ -526,9 +502,7 @@ void NV12ToARGBRow_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_NV12TOARGBROW_NEON
|
||||
|
||||
#ifdef HAS_NV12TOARGBROW_NEON
|
||||
void NV21ToARGBRow_NEON(const uint8* src_y,
|
||||
const uint8* src_vu,
|
||||
uint8* dst_argb,
|
||||
@@ -556,9 +530,7 @@ void NV21ToARGBRow_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_NV12TOARGBROW_NEON
|
||||
|
||||
#ifdef HAS_NV12TORGB565ROW_NEON
|
||||
void NV12ToRGB565Row_NEON(const uint8* src_y,
|
||||
const uint8* src_uv,
|
||||
uint8* dst_rgb565,
|
||||
@@ -586,14 +558,11 @@ void NV12ToRGB565Row_NEON(const uint8* src_y,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_NV12TORGB565ROW_NEON
|
||||
|
||||
#ifdef HAS_YUY2TOARGBROW_NEON
|
||||
void YUY2ToARGBRow_NEON(const uint8* src_yuy2,
|
||||
uint8* dst_argb,
|
||||
const struct YuvConstants* yuvconstants,
|
||||
int width) {
|
||||
int64 width64 = (int64)(width);
|
||||
asm volatile (
|
||||
YUVTORGB_SETUP
|
||||
"movi v23.8b, #255 \n"
|
||||
@@ -606,7 +575,7 @@ void YUY2ToARGBRow_NEON(const uint8* src_yuy2,
|
||||
"b.gt 1b \n"
|
||||
: "+r"(src_yuy2), // %0
|
||||
"+r"(dst_argb), // %1
|
||||
"+r"(width64) // %2
|
||||
"+r"(width) // %2
|
||||
: [kUVToRB]"r"(&yuvconstants->kUVToRB),
|
||||
[kUVToG]"r"(&yuvconstants->kUVToG),
|
||||
[kUVBiasBGR]"r"(&yuvconstants->kUVBiasBGR),
|
||||
@@ -615,14 +584,11 @@ void YUY2ToARGBRow_NEON(const uint8* src_yuy2,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_YUY2TOARGBROW_NEON
|
||||
|
||||
#ifdef HAS_UYVYTOARGBROW_NEON
|
||||
void UYVYToARGBRow_NEON(const uint8* src_uyvy,
|
||||
uint8* dst_argb,
|
||||
const struct YuvConstants* yuvconstants,
|
||||
int width) {
|
||||
int64 width64 = (int64)(width);
|
||||
asm volatile (
|
||||
YUVTORGB_SETUP
|
||||
"movi v23.8b, #255 \n"
|
||||
@@ -635,7 +601,7 @@ void UYVYToARGBRow_NEON(const uint8* src_uyvy,
|
||||
"b.gt 1b \n"
|
||||
: "+r"(src_uyvy), // %0
|
||||
"+r"(dst_argb), // %1
|
||||
"+r"(width64) // %2
|
||||
"+r"(width) // %2
|
||||
: [kUVToRB]"r"(&yuvconstants->kUVToRB),
|
||||
[kUVToG]"r"(&yuvconstants->kUVToG),
|
||||
[kUVBiasBGR]"r"(&yuvconstants->kUVBiasBGR),
|
||||
@@ -644,10 +610,8 @@ void UYVYToARGBRow_NEON(const uint8* src_uyvy,
|
||||
"v21", "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_UYVYTOARGBROW_NEON
|
||||
|
||||
// Reads 16 pairs of UV and write even values to dst_u and odd to dst_v.
|
||||
#ifdef HAS_SPLITUVROW_NEON
|
||||
void SplitUVRow_NEON(const uint8* src_uv, uint8* dst_u, uint8* dst_v,
|
||||
int width) {
|
||||
asm volatile (
|
||||
@@ -668,10 +632,8 @@ void SplitUVRow_NEON(const uint8* src_uv, uint8* dst_u, uint8* dst_v,
|
||||
: "cc", "memory", "v0", "v1" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_SPLITUVROW_NEON
|
||||
|
||||
// Reads 16 U's and V's and writes out 16 pairs of UV.
|
||||
#ifdef HAS_MERGEUVROW_NEON
|
||||
void MergeUVRow_NEON(const uint8* src_u, const uint8* src_v, uint8* dst_uv,
|
||||
int width) {
|
||||
asm volatile (
|
||||
@@ -693,10 +655,8 @@ void MergeUVRow_NEON(const uint8* src_u, const uint8* src_v, uint8* dst_uv,
|
||||
: "cc", "memory", "v0", "v1" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_MERGEUVROW_NEON
|
||||
|
||||
// Copy multiple of 32. vld4.8 allow unaligned and is fastest on a15.
|
||||
#ifdef HAS_COPYROW_NEON
|
||||
void CopyRow_NEON(const uint8* src, uint8* dst, int count) {
|
||||
asm volatile (
|
||||
"1: \n"
|
||||
@@ -713,17 +673,16 @@ void CopyRow_NEON(const uint8* src, uint8* dst, int count) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_COPYROW_NEON
|
||||
|
||||
// SetRow writes 'count' bytes using an 8 bit value repeated.
|
||||
void SetRow_NEON(uint8* dst, uint8 v8, int count) {
|
||||
asm volatile (
|
||||
"dup v0.16b, %w2 \n" // duplicate 16 bytes
|
||||
"1: \n"
|
||||
"subs %w1, %w1, #16 \n" // 16 bytes per loop
|
||||
"subs %w1, %w1, #16 \n" // 16 bytes per loop
|
||||
MEMACCESS(0)
|
||||
"st1 {v0.16b}, [%0], #16 \n" // store
|
||||
"b.gt 1b \n"
|
||||
"b.gt 1b \n"
|
||||
: "+r"(dst), // %0
|
||||
"+r"(count) // %1
|
||||
: "r"(v8) // %2
|
||||
@@ -735,10 +694,10 @@ void ARGBSetRow_NEON(uint8* dst, uint32 v32, int count) {
|
||||
asm volatile (
|
||||
"dup v0.4s, %w2 \n" // duplicate 4 ints
|
||||
"1: \n"
|
||||
"subs %w1, %w1, #4 \n" // 4 ints per loop
|
||||
"subs %w1, %w1, #4 \n" // 4 ints per loop
|
||||
MEMACCESS(0)
|
||||
"st1 {v0.16b}, [%0], #16 \n" // store
|
||||
"b.gt 1b \n"
|
||||
"b.gt 1b \n"
|
||||
: "+r"(dst), // %0
|
||||
"+r"(count) // %1
|
||||
: "r"(v32) // %2
|
||||
@@ -746,18 +705,15 @@ void ARGBSetRow_NEON(uint8* dst, uint32 v32, int count) {
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef HAS_MIRRORROW_NEON
|
||||
void MirrorRow_NEON(const uint8* src, uint8* dst, int width) {
|
||||
int64 width64 = (int64) width;
|
||||
asm volatile (
|
||||
// Start at end of source row.
|
||||
"add %0, %0, %2 \n"
|
||||
"add %0, %0, %w2, sxtw \n"
|
||||
"sub %0, %0, #16 \n"
|
||||
|
||||
"1: \n"
|
||||
MEMACCESS(0)
|
||||
"ld1 {v0.16b}, [%0], %3 \n" // src -= 16
|
||||
"subs %2, %2, #16 \n" // 16 pixels per loop.
|
||||
"subs %w2, %w2, #16 \n" // 16 pixels per loop.
|
||||
"rev64 v0.16b, v0.16b \n"
|
||||
MEMACCESS(1)
|
||||
"st1 {v0.D}[1], [%1], #8 \n" // dst += 16
|
||||
@@ -766,26 +722,22 @@ void MirrorRow_NEON(const uint8* src, uint8* dst, int width) {
|
||||
"b.gt 1b \n"
|
||||
: "+r"(src), // %0
|
||||
"+r"(dst), // %1
|
||||
"+r"(width64) // %2
|
||||
"+r"(width) // %2
|
||||
: "r"((ptrdiff_t)-16) // %3
|
||||
: "cc", "memory", "v0"
|
||||
);
|
||||
}
|
||||
#endif // HAS_MIRRORROW_NEON
|
||||
|
||||
#ifdef HAS_MIRRORUVROW_NEON
|
||||
void MirrorUVRow_NEON(const uint8* src_uv, uint8* dst_u, uint8* dst_v,
|
||||
int width) {
|
||||
int64 width64 = (int64) width;
|
||||
asm volatile (
|
||||
// Start at end of source row.
|
||||
"add %0, %0, %3, lsl #1 \n"
|
||||
"add %0, %0, %w3, sxtw #1 \n"
|
||||
"sub %0, %0, #16 \n"
|
||||
|
||||
"1: \n"
|
||||
MEMACCESS(0)
|
||||
"ld2 {v0.8b, v1.8b}, [%0], %4 \n" // src -= 16
|
||||
"subs %3, %3, #8 \n" // 8 pixels per loop.
|
||||
"subs %w3, %w3, #8 \n" // 8 pixels per loop.
|
||||
"rev64 v0.8b, v0.8b \n"
|
||||
"rev64 v1.8b, v1.8b \n"
|
||||
MEMACCESS(1)
|
||||
@@ -796,25 +748,21 @@ void MirrorUVRow_NEON(const uint8* src_uv, uint8* dst_u, uint8* dst_v,
|
||||
: "+r"(src_uv), // %0
|
||||
"+r"(dst_u), // %1
|
||||
"+r"(dst_v), // %2
|
||||
"+r"(width64) // %3
|
||||
"+r"(width) // %3
|
||||
: "r"((ptrdiff_t)-16) // %4
|
||||
: "cc", "memory", "v0", "v1"
|
||||
);
|
||||
}
|
||||
#endif // HAS_MIRRORUVROW_NEON
|
||||
|
||||
#ifdef HAS_ARGBMIRRORROW_NEON
|
||||
void ARGBMirrorRow_NEON(const uint8* src, uint8* dst, int width) {
|
||||
int64 width64 = (int64) width;
|
||||
asm volatile (
|
||||
// Start at end of source row.
|
||||
"add %0, %0, %2, lsl #2 \n"
|
||||
// Start at end of source row.
|
||||
"add %0, %0, %w2, sxtw #2 \n"
|
||||
"sub %0, %0, #16 \n"
|
||||
|
||||
"1: \n"
|
||||
MEMACCESS(0)
|
||||
"ld1 {v0.16b}, [%0], %3 \n" // src -= 16
|
||||
"subs %2, %2, #4 \n" // 4 pixels per loop.
|
||||
"subs %w2, %w2, #4 \n" // 4 pixels per loop.
|
||||
"rev64 v0.4s, v0.4s \n"
|
||||
MEMACCESS(1)
|
||||
"st1 {v0.D}[1], [%1], #8 \n" // dst += 16
|
||||
@@ -823,14 +771,12 @@ void ARGBMirrorRow_NEON(const uint8* src, uint8* dst, int width) {
|
||||
"b.gt 1b \n"
|
||||
: "+r"(src), // %0
|
||||
"+r"(dst), // %1
|
||||
"+r"(width64) // %2
|
||||
"+r"(width) // %2
|
||||
: "r"((ptrdiff_t)-16) // %3
|
||||
: "cc", "memory", "v0"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBMIRRORROW_NEON
|
||||
|
||||
#ifdef HAS_RGB24TOARGBROW_NEON
|
||||
void RGB24ToARGBRow_NEON(const uint8* src_rgb24, uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
"movi v4.8b, #255 \n" // Alpha
|
||||
@@ -843,14 +789,12 @@ void RGB24ToARGBRow_NEON(const uint8* src_rgb24, uint8* dst_argb, int width) {
|
||||
"b.gt 1b \n"
|
||||
: "+r"(src_rgb24), // %0
|
||||
"+r"(dst_argb), // %1
|
||||
"+r"(width) // %2
|
||||
"+r"(width) // %2
|
||||
:
|
||||
: "cc", "memory", "v1", "v2", "v3", "v4" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_RGB24TOARGBROW_NEON
|
||||
|
||||
#ifdef HAS_RAWTOARGBROW_NEON
|
||||
void RAWToARGBRow_NEON(const uint8* src_raw, uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
"movi v5.8b, #255 \n" // Alpha
|
||||
@@ -865,12 +809,11 @@ void RAWToARGBRow_NEON(const uint8* src_raw, uint8* dst_argb, int width) {
|
||||
"b.gt 1b \n"
|
||||
: "+r"(src_raw), // %0
|
||||
"+r"(dst_argb), // %1
|
||||
"+r"(width) // %2
|
||||
"+r"(width) // %2
|
||||
:
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_RAWTOARGBROW_NEON
|
||||
|
||||
void RAWToRGB24Row_NEON(const uint8* src_raw, uint8* dst_rgb24, int width) {
|
||||
asm volatile (
|
||||
@@ -904,7 +847,6 @@ void RAWToRGB24Row_NEON(const uint8* src_raw, uint8* dst_rgb24, int width) {
|
||||
"orr v0.16b, v0.16b, v2.16b \n" /* R,B */ \
|
||||
"dup v2.2D, v0.D[1] \n" /* R */
|
||||
|
||||
#ifdef HAS_RGB565TOARGBROW_NEON
|
||||
void RGB565ToARGBRow_NEON(const uint8* src_rgb565, uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
"movi v3.8b, #255 \n" // Alpha
|
||||
@@ -923,7 +865,6 @@ void RGB565ToARGBRow_NEON(const uint8* src_rgb565, uint8* dst_argb, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v6" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_RGB565TOARGBROW_NEON
|
||||
|
||||
#define ARGB1555TOARGB \
|
||||
"ushr v2.8h, v0.8h, #10 \n" /* R xxxRRRRR */ \
|
||||
@@ -962,7 +903,6 @@ void RGB565ToARGBRow_NEON(const uint8* src_rgb565, uint8* dst_argb, int width) {
|
||||
"orr v2.16b, v1.16b, v3.16b \n" /* R */ \
|
||||
"dup v1.2D, v0.D[1] \n" /* G */ \
|
||||
|
||||
#ifdef HAS_ARGB1555TOARGBROW_NEON
|
||||
void ARGB1555ToARGBRow_NEON(const uint8* src_argb1555, uint8* dst_argb,
|
||||
int width) {
|
||||
asm volatile (
|
||||
@@ -982,7 +922,6 @@ void ARGB1555ToARGBRow_NEON(const uint8* src_argb1555, uint8* dst_argb,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGB1555TOARGBROW_NEON
|
||||
|
||||
#define ARGB4444TOARGB \
|
||||
"shrn v1.8b, v0.8h, #8 \n" /* v1(l) AR */ \
|
||||
@@ -996,7 +935,6 @@ void ARGB1555ToARGBRow_NEON(const uint8* src_argb1555, uint8* dst_argb,
|
||||
"dup v0.2D, v2.D[1] \n" \
|
||||
"dup v1.2D, v3.D[1] \n"
|
||||
|
||||
#ifdef HAS_ARGB4444TOARGBROW_NEON
|
||||
void ARGB4444ToARGBRow_NEON(const uint8* src_argb4444, uint8* dst_argb,
|
||||
int width) {
|
||||
asm volatile (
|
||||
@@ -1015,9 +953,7 @@ void ARGB4444ToARGBRow_NEON(const uint8* src_argb4444, uint8* dst_argb,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGB4444TOARGBROW_NEON
|
||||
|
||||
#ifdef HAS_ARGBTORGB24ROW_NEON
|
||||
void ARGBToRGB24Row_NEON(const uint8* src_argb, uint8* dst_rgb24, int width) {
|
||||
asm volatile (
|
||||
"1: \n"
|
||||
@@ -1034,9 +970,7 @@ void ARGBToRGB24Row_NEON(const uint8* src_argb, uint8* dst_rgb24, int width) {
|
||||
: "cc", "memory", "v1", "v2", "v3", "v4" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTORGB24ROW_NEON
|
||||
|
||||
#ifdef HAS_ARGBTORAWROW_NEON
|
||||
void ARGBToRAWRow_NEON(const uint8* src_argb, uint8* dst_raw, int width) {
|
||||
asm volatile (
|
||||
"1: \n"
|
||||
@@ -1055,9 +989,7 @@ void ARGBToRAWRow_NEON(const uint8* src_argb, uint8* dst_raw, int width) {
|
||||
: "cc", "memory", "v1", "v2", "v3", "v4", "v5" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTORAWROW_NEON
|
||||
|
||||
#ifdef HAS_YUY2TOYROW_NEON
|
||||
void YUY2ToYRow_NEON(const uint8* src_yuy2, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"1: \n"
|
||||
@@ -1074,9 +1006,7 @@ void YUY2ToYRow_NEON(const uint8* src_yuy2, uint8* dst_y, int width) {
|
||||
: "cc", "memory", "v0", "v1" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_YUY2TOYROW_NEON
|
||||
|
||||
#ifdef HAS_UYVYTOYROW_NEON
|
||||
void UYVYToYRow_NEON(const uint8* src_uyvy, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"1: \n"
|
||||
@@ -1093,9 +1023,7 @@ void UYVYToYRow_NEON(const uint8* src_uyvy, uint8* dst_y, int width) {
|
||||
: "cc", "memory", "v0", "v1" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_UYVYTOYROW_NEON
|
||||
|
||||
#ifdef HAS_YUY2TOUV422ROW_NEON
|
||||
void YUY2ToUV422Row_NEON(const uint8* src_yuy2, uint8* dst_u, uint8* dst_v,
|
||||
int width) {
|
||||
asm volatile (
|
||||
@@ -1116,9 +1044,7 @@ void YUY2ToUV422Row_NEON(const uint8* src_yuy2, uint8* dst_u, uint8* dst_v,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_YUY2TOUV422ROW_NEON
|
||||
|
||||
#ifdef HAS_UYVYTOUV422ROW_NEON
|
||||
void UYVYToUV422Row_NEON(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v,
|
||||
int width) {
|
||||
asm volatile (
|
||||
@@ -1139,9 +1065,7 @@ void UYVYToUV422Row_NEON(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_UYVYTOUV422ROW_NEON
|
||||
|
||||
#ifdef HAS_YUY2TOUVROW_NEON
|
||||
void YUY2ToUVRow_NEON(const uint8* src_yuy2, int stride_yuy2,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_yuy2b = src_yuy2 + stride_yuy2;
|
||||
@@ -1169,9 +1093,7 @@ void YUY2ToUVRow_NEON(const uint8* src_yuy2, int stride_yuy2,
|
||||
"v5", "v6", "v7" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_YUY2TOUVROW_NEON
|
||||
|
||||
#ifdef HAS_UYVYTOUVROW_NEON
|
||||
void UYVYToUVRow_NEON(const uint8* src_uyvy, int stride_uyvy,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_uyvyb = src_uyvy + stride_uyvy;
|
||||
@@ -1199,10 +1121,8 @@ void UYVYToUVRow_NEON(const uint8* src_uyvy, int stride_uyvy,
|
||||
"v5", "v6", "v7" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_UYVYTOUVROW_NEON
|
||||
|
||||
// For BGRAToARGB, ABGRToARGB, RGBAToARGB, and ARGBToRGBA.
|
||||
#ifdef HAS_ARGBSHUFFLEROW_NEON
|
||||
void ARGBShuffleRow_NEON(const uint8* src_argb, uint8* dst_argb,
|
||||
const uint8* shuffler, int width) {
|
||||
asm volatile (
|
||||
@@ -1223,9 +1143,7 @@ void ARGBShuffleRow_NEON(const uint8* src_argb, uint8* dst_argb,
|
||||
: "cc", "memory", "v0", "v1", "v2" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBSHUFFLEROW_NEON
|
||||
|
||||
#ifdef HAS_I422TOYUY2ROW_NEON
|
||||
void I422ToYUY2Row_NEON(const uint8* src_y,
|
||||
const uint8* src_u,
|
||||
const uint8* src_v,
|
||||
@@ -1252,9 +1170,7 @@ void I422ToYUY2Row_NEON(const uint8* src_y,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I422TOYUY2ROW_NEON
|
||||
|
||||
#ifdef HAS_I422TOUYVYROW_NEON
|
||||
void I422ToUYVYRow_NEON(const uint8* src_y,
|
||||
const uint8* src_u,
|
||||
const uint8* src_v,
|
||||
@@ -1281,9 +1197,7 @@ void I422ToUYVYRow_NEON(const uint8* src_y,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3"
|
||||
);
|
||||
}
|
||||
#endif // HAS_I422TOUYVYROW_NEON
|
||||
|
||||
#ifdef HAS_ARGBTORGB565ROW_NEON
|
||||
void ARGBToRGB565Row_NEON(const uint8* src_argb, uint8* dst_rgb565, int width) {
|
||||
asm volatile (
|
||||
"1: \n"
|
||||
@@ -1301,9 +1215,7 @@ void ARGBToRGB565Row_NEON(const uint8* src_argb, uint8* dst_rgb565, int width) {
|
||||
: "cc", "memory", "v0", "v20", "v21", "v22", "v23"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTORGB565ROW_NEON
|
||||
|
||||
#ifdef HAS_ARGBTORGB565DITHERROW_NEON
|
||||
void ARGBToRGB565DitherRow_NEON(const uint8* src_argb, uint8* dst_rgb,
|
||||
const uint32 dither4, int width) {
|
||||
asm volatile (
|
||||
@@ -1326,9 +1238,7 @@ void ARGBToRGB565DitherRow_NEON(const uint8* src_argb, uint8* dst_rgb,
|
||||
: "cc", "memory", "v0", "v1", "v20", "v21", "v22", "v23"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTORGB565ROW_NEON
|
||||
|
||||
#ifdef HAS_ARGBTOARGB1555ROW_NEON
|
||||
void ARGBToARGB1555Row_NEON(const uint8* src_argb, uint8* dst_argb1555,
|
||||
int width) {
|
||||
asm volatile (
|
||||
@@ -1347,9 +1257,7 @@ void ARGBToARGB1555Row_NEON(const uint8* src_argb, uint8* dst_argb1555,
|
||||
: "cc", "memory", "v0", "v20", "v21", "v22", "v23"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTOARGB1555ROW_NEON
|
||||
|
||||
#ifdef HAS_ARGBTOARGB4444ROW_NEON
|
||||
void ARGBToARGB4444Row_NEON(const uint8* src_argb, uint8* dst_argb4444,
|
||||
int width) {
|
||||
asm volatile (
|
||||
@@ -1369,9 +1277,7 @@ void ARGBToARGB4444Row_NEON(const uint8* src_argb, uint8* dst_argb4444,
|
||||
: "cc", "memory", "v0", "v1", "v4", "v20", "v21", "v22", "v23"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTOARGB4444ROW_NEON
|
||||
|
||||
#ifdef HAS_ARGBTOYROW_NEON
|
||||
void ARGBToYRow_NEON(const uint8* src_argb, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"movi v4.8b, #13 \n" // B * 0.1016 coefficient
|
||||
@@ -1397,9 +1303,24 @@ void ARGBToYRow_NEON(const uint8* src_argb, uint8* dst_y, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTOYROW_NEON
|
||||
|
||||
#ifdef HAS_ARGBTOYJROW_NEON
|
||||
void ARGBExtractAlphaRow_NEON(const uint8* src_argb, uint8* dst_a, int width) {
|
||||
asm volatile (
|
||||
"1: \n"
|
||||
MEMACCESS(0)
|
||||
"ld4 {v0.16b,v1.16b,v2.16b,v3.16b}, [%0], #64 \n" // load row 16 pixels
|
||||
"subs %w2, %w2, #16 \n" // 16 processed per loop
|
||||
MEMACCESS(1)
|
||||
"st1 {v3.16b}, [%1], #16 \n" // store 16 A's.
|
||||
"b.gt 1b \n"
|
||||
: "+r"(src_argb), // %0
|
||||
"+r"(dst_a), // %1
|
||||
"+r"(width) // %2
|
||||
:
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3" // Clobber List
|
||||
);
|
||||
}
|
||||
|
||||
void ARGBToYJRow_NEON(const uint8* src_argb, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"movi v4.8b, #15 \n" // B * 0.11400 coefficient
|
||||
@@ -1423,10 +1344,8 @@ void ARGBToYJRow_NEON(const uint8* src_argb, uint8* dst_y, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTOYJROW_NEON
|
||||
|
||||
// 8x1 pixels.
|
||||
#ifdef HAS_ARGBTOUV444ROW_NEON
|
||||
void ARGBToUV444Row_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v,
|
||||
int width) {
|
||||
asm volatile (
|
||||
@@ -1467,7 +1386,6 @@ void ARGBToUV444Row_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v,
|
||||
"v24", "v25", "v26", "v27", "v28", "v29"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTOUV444ROW_NEON
|
||||
|
||||
#define RGBTOUV_SETUP_REG \
|
||||
"movi v20.8h, #56, lsl #0 \n" /* UB/VR coefficient (0.875) / 2 */ \
|
||||
@@ -1478,7 +1396,6 @@ void ARGBToUV444Row_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v,
|
||||
"movi v25.16b, #0x80 \n" /* 128.5 (0x8080 in 16-bit) */
|
||||
|
||||
// 32x1 pixels -> 8x1. width is number of argb pixels. e.g. 32.
|
||||
#ifdef HAS_ARGBTOUV411ROW_NEON
|
||||
void ARGBToUV411Row_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v,
|
||||
int width) {
|
||||
asm volatile (
|
||||
@@ -1528,7 +1445,6 @@ void ARGBToUV411Row_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v,
|
||||
"v20", "v21", "v22", "v23", "v24", "v25"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTOUV411ROW_NEON
|
||||
|
||||
// 16x2 pixels -> 8x1. width is number of argb pixels. e.g. 16.
|
||||
#define RGBTOUV(QB, QG, QR) \
|
||||
@@ -1546,7 +1462,6 @@ void ARGBToUV411Row_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v,
|
||||
// TODO(fbarchard): Consider vhadd vertical, then vpaddl horizontal, avoid shr.
|
||||
// TODO(fbarchard): consider ptrdiff_t for all strides.
|
||||
|
||||
#ifdef HAS_ARGBTOUVROW_NEON
|
||||
void ARGBToUVRow_NEON(const uint8* src_argb, int src_stride_argb,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_argb_1 = src_argb + src_stride_argb;
|
||||
@@ -1586,10 +1501,8 @@ void ARGBToUVRow_NEON(const uint8* src_argb, int src_stride_argb,
|
||||
"v20", "v21", "v22", "v23", "v24", "v25"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTOUVROW_NEON
|
||||
|
||||
// TODO(fbarchard): Subsample match C code.
|
||||
#ifdef HAS_ARGBTOUVJROW_NEON
|
||||
void ARGBToUVJRow_NEON(const uint8* src_argb, int src_stride_argb,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_argb_1 = src_argb + src_stride_argb;
|
||||
@@ -1633,9 +1546,7 @@ void ARGBToUVJRow_NEON(const uint8* src_argb, int src_stride_argb,
|
||||
"v20", "v21", "v22", "v23", "v24", "v25"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBTOUVJROW_NEON
|
||||
|
||||
#ifdef HAS_BGRATOUVROW_NEON
|
||||
void BGRAToUVRow_NEON(const uint8* src_bgra, int src_stride_bgra,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_bgra_1 = src_bgra + src_stride_bgra;
|
||||
@@ -1674,9 +1585,7 @@ void BGRAToUVRow_NEON(const uint8* src_bgra, int src_stride_bgra,
|
||||
"v20", "v21", "v22", "v23", "v24", "v25"
|
||||
);
|
||||
}
|
||||
#endif // HAS_BGRATOUVROW_NEON
|
||||
|
||||
#ifdef HAS_ABGRTOUVROW_NEON
|
||||
void ABGRToUVRow_NEON(const uint8* src_abgr, int src_stride_abgr,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_abgr_1 = src_abgr + src_stride_abgr;
|
||||
@@ -1715,9 +1624,7 @@ void ABGRToUVRow_NEON(const uint8* src_abgr, int src_stride_abgr,
|
||||
"v20", "v21", "v22", "v23", "v24", "v25"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ABGRTOUVROW_NEON
|
||||
|
||||
#ifdef HAS_RGBATOUVROW_NEON
|
||||
void RGBAToUVRow_NEON(const uint8* src_rgba, int src_stride_rgba,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_rgba_1 = src_rgba + src_stride_rgba;
|
||||
@@ -1756,9 +1663,7 @@ void RGBAToUVRow_NEON(const uint8* src_rgba, int src_stride_rgba,
|
||||
"v20", "v21", "v22", "v23", "v24", "v25"
|
||||
);
|
||||
}
|
||||
#endif // HAS_RGBATOUVROW_NEON
|
||||
|
||||
#ifdef HAS_RGB24TOUVROW_NEON
|
||||
void RGB24ToUVRow_NEON(const uint8* src_rgb24, int src_stride_rgb24,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_rgb24_1 = src_rgb24 + src_stride_rgb24;
|
||||
@@ -1797,9 +1702,7 @@ void RGB24ToUVRow_NEON(const uint8* src_rgb24, int src_stride_rgb24,
|
||||
"v20", "v21", "v22", "v23", "v24", "v25"
|
||||
);
|
||||
}
|
||||
#endif // HAS_RGB24TOUVROW_NEON
|
||||
|
||||
#ifdef HAS_RAWTOUVROW_NEON
|
||||
void RAWToUVRow_NEON(const uint8* src_raw, int src_stride_raw,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_raw_1 = src_raw + src_stride_raw;
|
||||
@@ -1838,10 +1741,8 @@ void RAWToUVRow_NEON(const uint8* src_raw, int src_stride_raw,
|
||||
"v20", "v21", "v22", "v23", "v24", "v25"
|
||||
);
|
||||
}
|
||||
#endif // HAS_RAWTOUVROW_NEON
|
||||
|
||||
// 16x2 pixels -> 8x1. width is number of argb pixels. e.g. 16.
|
||||
#ifdef HAS_RGB565TOUVROW_NEON
|
||||
void RGB565ToUVRow_NEON(const uint8* src_rgb565, int src_stride_rgb565,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_rgb565_1 = src_rgb565 + src_stride_rgb565;
|
||||
@@ -1914,10 +1815,8 @@ void RGB565ToUVRow_NEON(const uint8* src_rgb565, int src_stride_rgb565,
|
||||
"v25", "v26", "v27"
|
||||
);
|
||||
}
|
||||
#endif // HAS_RGB565TOUVROW_NEON
|
||||
|
||||
// 16x2 pixels -> 8x1. width is number of argb pixels. e.g. 16.
|
||||
#ifdef HAS_ARGB1555TOUVROW_NEON
|
||||
void ARGB1555ToUVRow_NEON(const uint8* src_argb1555, int src_stride_argb1555,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_argb1555_1 = src_argb1555 + src_stride_argb1555;
|
||||
@@ -1985,10 +1884,8 @@ void ARGB1555ToUVRow_NEON(const uint8* src_argb1555, int src_stride_argb1555,
|
||||
"v26", "v27", "v28"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGB1555TOUVROW_NEON
|
||||
|
||||
// 16x2 pixels -> 8x1. width is number of argb pixels. e.g. 16.
|
||||
#ifdef HAS_ARGB4444TOUVROW_NEON
|
||||
void ARGB4444ToUVRow_NEON(const uint8* src_argb4444, int src_stride_argb4444,
|
||||
uint8* dst_u, uint8* dst_v, int width) {
|
||||
const uint8* src_argb4444_1 = src_argb4444 + src_stride_argb4444;
|
||||
@@ -2057,9 +1954,7 @@ void ARGB4444ToUVRow_NEON(const uint8* src_argb4444, int src_stride_argb4444,
|
||||
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGB4444TOUVROW_NEON
|
||||
|
||||
#ifdef HAS_RGB565TOYROW_NEON
|
||||
void RGB565ToYRow_NEON(const uint8* src_rgb565, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"movi v24.8b, #13 \n" // B * 0.1016 coefficient
|
||||
@@ -2087,9 +1982,7 @@ void RGB565ToYRow_NEON(const uint8* src_rgb565, uint8* dst_y, int width) {
|
||||
"v24", "v25", "v26", "v27"
|
||||
);
|
||||
}
|
||||
#endif // HAS_RGB565TOYROW_NEON
|
||||
|
||||
#ifdef HAS_ARGB1555TOYROW_NEON
|
||||
void ARGB1555ToYRow_NEON(const uint8* src_argb1555, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"movi v4.8b, #13 \n" // B * 0.1016 coefficient
|
||||
@@ -2116,9 +2009,7 @@ void ARGB1555ToYRow_NEON(const uint8* src_argb1555, uint8* dst_y, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGB1555TOYROW_NEON
|
||||
|
||||
#ifdef HAS_ARGB4444TOYROW_NEON
|
||||
void ARGB4444ToYRow_NEON(const uint8* src_argb4444, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"movi v24.8b, #13 \n" // B * 0.1016 coefficient
|
||||
@@ -2145,9 +2036,7 @@ void ARGB4444ToYRow_NEON(const uint8* src_argb4444, uint8* dst_y, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v24", "v25", "v26", "v27"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGB4444TOYROW_NEON
|
||||
|
||||
#ifdef HAS_BGRATOYROW_NEON
|
||||
void BGRAToYRow_NEON(const uint8* src_bgra, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"movi v4.8b, #33 \n" // R * 0.2578 coefficient
|
||||
@@ -2173,9 +2062,7 @@ void BGRAToYRow_NEON(const uint8* src_bgra, uint8* dst_y, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v16"
|
||||
);
|
||||
}
|
||||
#endif // HAS_BGRATOYROW_NEON
|
||||
|
||||
#ifdef HAS_ABGRTOYROW_NEON
|
||||
void ABGRToYRow_NEON(const uint8* src_abgr, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"movi v4.8b, #33 \n" // R * 0.2578 coefficient
|
||||
@@ -2201,9 +2088,7 @@ void ABGRToYRow_NEON(const uint8* src_abgr, uint8* dst_y, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v16"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ABGRTOYROW_NEON
|
||||
|
||||
#ifdef HAS_RGBATOYROW_NEON
|
||||
void RGBAToYRow_NEON(const uint8* src_rgba, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"movi v4.8b, #13 \n" // B * 0.1016 coefficient
|
||||
@@ -2229,9 +2114,7 @@ void RGBAToYRow_NEON(const uint8* src_rgba, uint8* dst_y, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v16"
|
||||
);
|
||||
}
|
||||
#endif // HAS_RGBATOYROW_NEON
|
||||
|
||||
#ifdef HAS_RGB24TOYROW_NEON
|
||||
void RGB24ToYRow_NEON(const uint8* src_rgb24, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"movi v4.8b, #13 \n" // B * 0.1016 coefficient
|
||||
@@ -2257,9 +2140,7 @@ void RGB24ToYRow_NEON(const uint8* src_rgb24, uint8* dst_y, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v16"
|
||||
);
|
||||
}
|
||||
#endif // HAS_RGB24TOYROW_NEON
|
||||
|
||||
#ifdef HAS_RAWTOYROW_NEON
|
||||
void RAWToYRow_NEON(const uint8* src_raw, uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
"movi v4.8b, #33 \n" // R * 0.2578 coefficient
|
||||
@@ -2285,10 +2166,8 @@ void RAWToYRow_NEON(const uint8* src_raw, uint8* dst_y, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v16"
|
||||
);
|
||||
}
|
||||
#endif // HAS_RAWTOYROW_NEON
|
||||
|
||||
// Bilinear filter 16x2 -> 16x1
|
||||
#ifdef HAS_INTERPOLATEROW_NEON
|
||||
void InterpolateRow_NEON(uint8* dst_ptr,
|
||||
const uint8* src_ptr, ptrdiff_t src_stride,
|
||||
int dst_width, int source_y_fraction) {
|
||||
@@ -2354,10 +2233,8 @@ void InterpolateRow_NEON(uint8* dst_ptr,
|
||||
: "cc", "memory", "v0", "v1", "v3", "v4", "v5"
|
||||
);
|
||||
}
|
||||
#endif // HAS_INTERPOLATEROW_NEON
|
||||
|
||||
// dr * (256 - sa) / 256 + sr = dr - dr * sa / 256 + sr
|
||||
#ifdef HAS_ARGBBLENDROW_NEON
|
||||
void ARGBBlendRow_NEON(const uint8* src_argb0, const uint8* src_argb1,
|
||||
uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
@@ -2426,10 +2303,8 @@ void ARGBBlendRow_NEON(const uint8* src_argb0, const uint8* src_argb1,
|
||||
"v16", "v17", "v18"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBBLENDROW_NEON
|
||||
|
||||
// Attenuate 8 pixels at a time.
|
||||
#ifdef HAS_ARGBATTENUATEROW_NEON
|
||||
void ARGBAttenuateRow_NEON(const uint8* src_argb, uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
// Attenuate 8 pixels.
|
||||
@@ -2453,11 +2328,9 @@ void ARGBAttenuateRow_NEON(const uint8* src_argb, uint8* dst_argb, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBATTENUATEROW_NEON
|
||||
|
||||
// Quantize 8 ARGB pixels (32 bytes).
|
||||
// dst = (dst * scale >> 16) * interval_size + interval_offset;
|
||||
#ifdef HAS_ARGBQUANTIZEROW_NEON
|
||||
void ARGBQuantizeRow_NEON(uint8* dst_argb, int scale, int interval_size,
|
||||
int interval_offset, int width) {
|
||||
asm volatile (
|
||||
@@ -2497,12 +2370,10 @@ void ARGBQuantizeRow_NEON(uint8* dst_argb, int scale, int interval_size,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBQUANTIZEROW_NEON
|
||||
|
||||
// Shade 8 pixels at a time by specified value.
|
||||
// NOTE vqrdmulh.s16 q10, q10, d0[0] must use a scaler register from 0 to 8.
|
||||
// Rounding in vqrdmulh does +1 to high if high bit of low s16 is set.
|
||||
#ifdef HAS_ARGBSHADEROW_NEON
|
||||
void ARGBShadeRow_NEON(const uint8* src_argb, uint8* dst_argb, int width,
|
||||
uint32 value) {
|
||||
asm volatile (
|
||||
@@ -2537,12 +2408,10 @@ void ARGBShadeRow_NEON(const uint8* src_argb, uint8* dst_argb, int width,
|
||||
: "cc", "memory", "v0", "v4", "v5", "v6", "v7"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBSHADEROW_NEON
|
||||
|
||||
// Convert 8 ARGB pixels (64 bytes) to 8 Gray ARGB pixels
|
||||
// Similar to ARGBToYJ but stores ARGB.
|
||||
// C code is (15 * b + 75 * g + 38 * r + 64) >> 7;
|
||||
#ifdef HAS_ARGBGRAYROW_NEON
|
||||
void ARGBGrayRow_NEON(const uint8* src_argb, uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
"movi v24.8b, #15 \n" // B * 0.11400 coefficient
|
||||
@@ -2568,14 +2437,12 @@ void ARGBGrayRow_NEON(const uint8* src_argb, uint8* dst_argb, int width) {
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v24", "v25", "v26"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBGRAYROW_NEON
|
||||
|
||||
// Convert 8 ARGB pixels (32 bytes) to 8 Sepia ARGB pixels.
|
||||
// b = (r * 35 + g * 68 + b * 17) >> 7
|
||||
// g = (r * 45 + g * 88 + b * 22) >> 7
|
||||
// r = (r * 50 + g * 98 + b * 24) >> 7
|
||||
|
||||
#ifdef HAS_ARGBSEPIAROW_NEON
|
||||
void ARGBSepiaRow_NEON(uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
"movi v20.8b, #17 \n" // BB coefficient
|
||||
@@ -2613,12 +2480,10 @@ void ARGBSepiaRow_NEON(uint8* dst_argb, int width) {
|
||||
"v20", "v21", "v22", "v24", "v25", "v26", "v28", "v29", "v30"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBSEPIAROW_NEON
|
||||
|
||||
// Tranform 8 ARGB pixels (32 bytes) with color matrix.
|
||||
// TODO(fbarchard): Was same as Sepia except matrix is provided. This function
|
||||
// needs to saturate. Consider doing a non-saturating version.
|
||||
#ifdef HAS_ARGBCOLORMATRIXROW_NEON
|
||||
void ARGBColorMatrixRow_NEON(const uint8* src_argb, uint8* dst_argb,
|
||||
const int8* matrix_argb, int width) {
|
||||
asm volatile (
|
||||
@@ -2678,11 +2543,9 @@ void ARGBColorMatrixRow_NEON(const uint8* src_argb, uint8* dst_argb,
|
||||
"v18", "v19", "v22", "v23", "v24", "v25"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBCOLORMATRIXROW_NEON
|
||||
|
||||
// TODO(fbarchard): fix vqshrun in ARGBMultiplyRow_NEON and reenable.
|
||||
// Multiply 2 rows of ARGB pixels together, 8 pixels at a time.
|
||||
#ifdef HAS_ARGBMULTIPLYROW_NEON
|
||||
void ARGBMultiplyRow_NEON(const uint8* src_argb0, const uint8* src_argb1,
|
||||
uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
@@ -2713,10 +2576,8 @@ void ARGBMultiplyRow_NEON(const uint8* src_argb0, const uint8* src_argb1,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBMULTIPLYROW_NEON
|
||||
|
||||
// Add 2 rows of ARGB pixels together, 8 pixels at a time.
|
||||
#ifdef HAS_ARGBADDROW_NEON
|
||||
void ARGBAddRow_NEON(const uint8* src_argb0, const uint8* src_argb1,
|
||||
uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
@@ -2743,10 +2604,8 @@ void ARGBAddRow_NEON(const uint8* src_argb0, const uint8* src_argb1,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBADDROW_NEON
|
||||
|
||||
// Subtract 2 rows of ARGB pixels, 8 pixels at a time.
|
||||
#ifdef HAS_ARGBSUBTRACTROW_NEON
|
||||
void ARGBSubtractRow_NEON(const uint8* src_argb0, const uint8* src_argb1,
|
||||
uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
@@ -2773,14 +2632,12 @@ void ARGBSubtractRow_NEON(const uint8* src_argb0, const uint8* src_argb1,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7"
|
||||
);
|
||||
}
|
||||
#endif // HAS_ARGBSUBTRACTROW_NEON
|
||||
|
||||
// Adds Sobel X and Sobel Y and stores Sobel into ARGB.
|
||||
// A = 255
|
||||
// R = Sobel
|
||||
// G = Sobel
|
||||
// B = Sobel
|
||||
#ifdef HAS_SOBELROW_NEON
|
||||
void SobelRow_NEON(const uint8* src_sobelx, const uint8* src_sobely,
|
||||
uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
@@ -2806,10 +2663,8 @@ void SobelRow_NEON(const uint8* src_sobelx, const uint8* src_sobely,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3"
|
||||
);
|
||||
}
|
||||
#endif // HAS_SOBELROW_NEON
|
||||
|
||||
// Adds Sobel X and Sobel Y and stores Sobel into plane.
|
||||
#ifdef HAS_SOBELTOPLANEROW_NEON
|
||||
void SobelToPlaneRow_NEON(const uint8* src_sobelx, const uint8* src_sobely,
|
||||
uint8* dst_y, int width) {
|
||||
asm volatile (
|
||||
@@ -2832,14 +2687,12 @@ void SobelToPlaneRow_NEON(const uint8* src_sobelx, const uint8* src_sobely,
|
||||
: "cc", "memory", "v0", "v1"
|
||||
);
|
||||
}
|
||||
#endif // HAS_SOBELTOPLANEROW_NEON
|
||||
|
||||
// Mixes Sobel X, Sobel Y and Sobel into ARGB.
|
||||
// A = 255
|
||||
// R = Sobel X
|
||||
// G = Sobel
|
||||
// B = Sobel Y
|
||||
#ifdef HAS_SOBELXYROW_NEON
|
||||
void SobelXYRow_NEON(const uint8* src_sobelx, const uint8* src_sobely,
|
||||
uint8* dst_argb, int width) {
|
||||
asm volatile (
|
||||
@@ -2863,13 +2716,11 @@ void SobelXYRow_NEON(const uint8* src_sobelx, const uint8* src_sobely,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3"
|
||||
);
|
||||
}
|
||||
#endif // HAS_SOBELXYROW_NEON
|
||||
|
||||
// SobelX as a matrix is
|
||||
// -1 0 1
|
||||
// -2 0 2
|
||||
// -1 0 1
|
||||
#ifdef HAS_SOBELXROW_NEON
|
||||
void SobelXRow_NEON(const uint8* src_y0, const uint8* src_y1,
|
||||
const uint8* src_y2, uint8* dst_sobelx, int width) {
|
||||
asm volatile (
|
||||
@@ -2908,13 +2759,11 @@ void SobelXRow_NEON(const uint8* src_y0, const uint8* src_y1,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_SOBELXROW_NEON
|
||||
|
||||
// SobelY as a matrix is
|
||||
// -1 -2 -1
|
||||
// 0 0 0
|
||||
// 1 2 1
|
||||
#ifdef HAS_SOBELYROW_NEON
|
||||
void SobelYRow_NEON(const uint8* src_y0, const uint8* src_y1,
|
||||
uint8* dst_sobely, int width) {
|
||||
asm volatile (
|
||||
@@ -2952,7 +2801,6 @@ void SobelYRow_NEON(const uint8* src_y0, const uint8* src_y1,
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3" // Clobber List
|
||||
);
|
||||
}
|
||||
#endif // HAS_SOBELYROW_NEON
|
||||
#endif // !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
|
||||
#include "libyuv/row.h"
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_X86) && defined(_M_X64) && \
|
||||
defined(_MSC_VER) && !defined(__clang__)
|
||||
// This module is for Visual C 32/64 bit and clangcl 32 bit
|
||||
#if !defined(LIBYUV_DISABLE_X86) && defined(_MSC_VER) && \
|
||||
(defined(_M_IX86) || (defined(_M_X64) && !defined(__clang__)))
|
||||
|
||||
#if defined(_M_X64)
|
||||
#include <emmintrin.h>
|
||||
#include <tmmintrin.h> // For _mm_maddubs_epi16
|
||||
#endif
|
||||
@@ -21,10 +24,6 @@ namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// This module is for Visual C 32/64 bit and clangcl 32 bit
|
||||
#if !defined(LIBYUV_DISABLE_X86) && \
|
||||
(defined(_M_IX86) || (defined(_M_X64) && !defined(__clang__)))
|
||||
|
||||
// 64 bit
|
||||
#if defined(_M_X64)
|
||||
|
||||
@@ -3532,6 +3531,33 @@ void ARGBCopyAlphaRow_AVX2(const uint8* src, uint8* dst, int width) {
|
||||
}
|
||||
#endif // HAS_ARGBCOPYALPHAROW_AVX2
|
||||
|
||||
#ifdef HAS_ARGBEXTRACTALPHAROW_SSE2
|
||||
// width in pixels
|
||||
__declspec(naked)
|
||||
void ARGBExtractAlphaRow_SSE2(const uint8* src_argb, uint8* dst_a, int width) {
|
||||
__asm {
|
||||
mov eax, [esp + 4] // src_argb
|
||||
mov edx, [esp + 8] // dst_a
|
||||
mov ecx, [esp + 12] // width
|
||||
|
||||
extractloop:
|
||||
movdqu xmm0, [eax]
|
||||
movdqu xmm1, [eax + 16]
|
||||
lea eax, [eax + 32]
|
||||
psrld xmm0, 24
|
||||
psrld xmm1, 24
|
||||
packssdw xmm0, xmm1
|
||||
packuswb xmm0, xmm0
|
||||
movq qword ptr [edx], xmm0
|
||||
lea edx, [edx + 8]
|
||||
sub ecx, 8
|
||||
jg extractloop
|
||||
|
||||
ret
|
||||
}
|
||||
}
|
||||
#endif // HAS_ARGBEXTRACTALPHAROW_SSE2
|
||||
|
||||
#ifdef HAS_ARGBCOPYYTOALPHAROW_SSE2
|
||||
// width in pixels
|
||||
__declspec(naked)
|
||||
@@ -5248,6 +5274,7 @@ void SobelXYRow_SSE2(const uint8* src_sobelx, const uint8* src_sobely,
|
||||
// dst points to pixel to store result to.
|
||||
// count is number of averaged pixels to produce.
|
||||
// Does 4 pixels at a time.
|
||||
// This function requires alignment on accumulation buffer pointers.
|
||||
void CumulativeSumToAverageRow_SSE2(const int32* topleft, const int32* botleft,
|
||||
int width, int area, uint8* dst,
|
||||
int count) {
|
||||
@@ -6233,9 +6260,10 @@ void ARGBLumaColorTableRow_SSSE3(const uint8* src_argb, uint8* dst_argb,
|
||||
#endif // HAS_ARGBLUMACOLORTABLEROW_SSSE3
|
||||
|
||||
#endif // defined(_M_X64)
|
||||
#endif // !defined(LIBYUV_DISABLE_X86) && (defined(_M_IX86) || defined(_M_X64))
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // !defined(LIBYUV_DISABLE_X86) && (defined(_M_IX86) || defined(_M_X64))
|
||||
@@ -1411,8 +1411,7 @@ void ScalePlane(const uint8* src, int src_stride,
|
||||
}
|
||||
if (dst_width <= Abs(src_width) && dst_height <= src_height) {
|
||||
// Scale down.
|
||||
if (4 * dst_width == 3 * src_width &&
|
||||
4 * dst_height == 3 * src_height) {
|
||||
if (4 * dst_width == 3 * src_width && 4 * dst_height == 3 * src_height) {
|
||||
// optimized, 3/4
|
||||
ScalePlaneDown34(src_width, src_height, dst_width, dst_height,
|
||||
src_stride, dst_stride, src, dst, filtering);
|
||||
@@ -1425,8 +1424,7 @@ void ScalePlane(const uint8* src, int src_stride,
|
||||
return;
|
||||
}
|
||||
// 3/8 rounded up for odd sized chroma height.
|
||||
if (8 * dst_width == 3 * src_width &&
|
||||
dst_height == ((src_height * 3 + 7) / 8)) {
|
||||
if (8 * dst_width == 3 * src_width && 8 * dst_height == 3 * src_height) {
|
||||
// optimized, 3/8
|
||||
ScalePlaneDown38(src_width, src_height, dst_width, dst_height,
|
||||
src_stride, dst_stride, src, dst, filtering);
|
||||
@@ -1508,8 +1506,7 @@ void ScalePlane_16(const uint16* src, int src_stride,
|
||||
return;
|
||||
}
|
||||
// 3/8 rounded up for odd sized chroma height.
|
||||
if (8 * dst_width == 3 * src_width &&
|
||||
dst_height == ((src_height * 3 + 7) / 8)) {
|
||||
if (8 * dst_width == 3 * src_width && 8 * dst_height == 3 * src_height) {
|
||||
// optimized, 3/8
|
||||
ScalePlaneDown38_16(src_width, src_height, dst_width, dst_height,
|
||||
src_stride, dst_stride, src, dst, filtering);
|
||||
|
||||
@@ -417,8 +417,14 @@ void ScaleColsUp2_16_C(uint16* dst_ptr, const uint16* src_ptr,
|
||||
}
|
||||
|
||||
// (1-f)a + fb can be replaced with a + f(b-a)
|
||||
#if defined(__arm__) || defined(__aarch64__)
|
||||
#define BLENDER(a, b, f) (uint8)((int)(a) + \
|
||||
((int)(f) * ((int)(b) - (int)(a)) >> 16))
|
||||
((((int)((f)) * ((int)(b) - (int)(a))) + 0x8000) >> 16))
|
||||
#else
|
||||
// Intel uses 7 bit math with rounding.
|
||||
#define BLENDER(a, b, f) (uint8)((int)(a) + \
|
||||
(((int)((f) >> 9) * ((int)(b) - (int)(a)) + 0x40) >> 7))
|
||||
#endif
|
||||
|
||||
void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr,
|
||||
int dst_width, int x, int dx) {
|
||||
@@ -470,8 +476,9 @@ void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr,
|
||||
}
|
||||
#undef BLENDER
|
||||
|
||||
// Same as 8 bit arm blender but return is cast to uint16
|
||||
#define BLENDER(a, b, f) (uint16)((int)(a) + \
|
||||
((int)(f) * ((int)(b) - (int)(a)) >> 16))
|
||||
((((int)((f)) * ((int)(b) - (int)(a))) + 0x8000) >> 16))
|
||||
|
||||
void ScaleFilterCols_16_C(uint16* dst_ptr, const uint16* src_ptr,
|
||||
int dst_width, int x, int dx) {
|
||||
@@ -809,6 +816,7 @@ void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(fbarchard): Replace 0x7f ^ f with 128-f. bug=607.
|
||||
// Mimics SSSE3 blender
|
||||
#define BLENDER1(a, b, f) ((a) * (0x7f ^ f) + (b) * f) >> 7
|
||||
#define BLENDERC(a, b, f, s) (uint32)( \
|
||||
|
||||
@@ -821,6 +821,16 @@ void ScaleAddRow_AVX2(const uint8* src_ptr, uint16* dst_ptr, int src_width) {
|
||||
}
|
||||
#endif // HAS_SCALEADDROW_AVX2
|
||||
|
||||
// Constant for making pixels signed to avoid pmaddubsw
|
||||
// saturation.
|
||||
static uvec8 kFsub80 =
|
||||
{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
|
||||
|
||||
// Constant for making pixels unsigned and adding .5 for rounding.
|
||||
static uvec16 kFadd40 =
|
||||
{ 0x4040, 0x4040, 0x4040, 0x4040, 0x4040, 0x4040, 0x4040, 0x4040 };
|
||||
|
||||
// Bilinear column filtering. SSSE3 version.
|
||||
void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
|
||||
int dst_width, int x, int dx) {
|
||||
@@ -831,7 +841,10 @@ void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
|
||||
"movl $0x04040000,%k2 \n"
|
||||
"movd %k2,%%xmm5 \n"
|
||||
"pcmpeqb %%xmm6,%%xmm6 \n"
|
||||
"psrlw $0x9,%%xmm6 \n"
|
||||
"psrlw $0x9,%%xmm6 \n" // 0x007f007f
|
||||
"pcmpeqb %%xmm7,%%xmm7 \n"
|
||||
"psrlw $15,%%xmm7 \n" // 0x00010001
|
||||
|
||||
"pextrw $0x1,%%xmm2,%k3 \n"
|
||||
"subl $0x2,%5 \n"
|
||||
"jl 29f \n"
|
||||
@@ -853,16 +866,19 @@ void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
|
||||
"movd %k2,%%xmm4 \n"
|
||||
"pshufb %%xmm5,%%xmm1 \n"
|
||||
"punpcklwd %%xmm4,%%xmm0 \n"
|
||||
"pxor %%xmm6,%%xmm1 \n"
|
||||
"pmaddubsw %%xmm1,%%xmm0 \n"
|
||||
"psubb %8,%%xmm0 \n" // make pixels signed.
|
||||
"pxor %%xmm6,%%xmm1 \n" // 128 - f = (f ^ 127 ) + 1
|
||||
"paddusb %%xmm7,%%xmm1 \n"
|
||||
"pmaddubsw %%xmm0,%%xmm1 \n"
|
||||
"pextrw $0x1,%%xmm2,%k3 \n"
|
||||
"pextrw $0x3,%%xmm2,%k4 \n"
|
||||
"psrlw $0x7,%%xmm0 \n"
|
||||
"packuswb %%xmm0,%%xmm0 \n"
|
||||
"movd %%xmm0,%k2 \n"
|
||||
"paddw %9,%%xmm1 \n" // make pixels unsigned.
|
||||
"psrlw $0x7,%%xmm1 \n"
|
||||
"packuswb %%xmm1,%%xmm1 \n"
|
||||
"movd %%xmm1,%k2 \n"
|
||||
"mov %w2," MEMACCESS(0) " \n"
|
||||
"lea " MEMLEA(0x2,0) ",%0 \n"
|
||||
"sub $0x2,%5 \n"
|
||||
"subl $0x2,%5 \n"
|
||||
"jge 2b \n"
|
||||
|
||||
LABELALIGN
|
||||
@@ -873,11 +889,14 @@ void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
|
||||
"movd %k2,%%xmm0 \n"
|
||||
"psrlw $0x9,%%xmm2 \n"
|
||||
"pshufb %%xmm5,%%xmm2 \n"
|
||||
"psubb %8,%%xmm0 \n" // make pixels signed.
|
||||
"pxor %%xmm6,%%xmm2 \n"
|
||||
"pmaddubsw %%xmm2,%%xmm0 \n"
|
||||
"psrlw $0x7,%%xmm0 \n"
|
||||
"packuswb %%xmm0,%%xmm0 \n"
|
||||
"movd %%xmm0,%k2 \n"
|
||||
"paddusb %%xmm7,%%xmm2 \n"
|
||||
"pmaddubsw %%xmm0,%%xmm2 \n"
|
||||
"paddw %9,%%xmm2 \n" // make pixels unsigned.
|
||||
"psrlw $0x7,%%xmm2 \n"
|
||||
"packuswb %%xmm2,%%xmm2 \n"
|
||||
"movd %%xmm2,%k2 \n"
|
||||
"mov %b2," MEMACCESS(0) " \n"
|
||||
"99: \n"
|
||||
: "+r"(dst_ptr), // %0
|
||||
@@ -885,11 +904,22 @@ void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
|
||||
"=&a"(temp_pixel), // %2
|
||||
"=&r"(x0), // %3
|
||||
"=&r"(x1), // %4
|
||||
#if defined(__x86_64__)
|
||||
"+rm"(dst_width) // %5
|
||||
#else
|
||||
"+m"(dst_width) // %5
|
||||
#endif
|
||||
: "rm"(x), // %6
|
||||
"rm"(dx) // %7
|
||||
"rm"(dx), // %7
|
||||
#if defined(__x86_64__)
|
||||
"x"(kFsub80), // %8
|
||||
"x"(kFadd40) // %9
|
||||
#else
|
||||
"m"(kFsub80), // %8
|
||||
"m"(kFadd40) // %9
|
||||
#endif
|
||||
: "memory", "cc", NACL_R14
|
||||
"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6"
|
||||
"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -572,6 +572,10 @@ void ScaleAddRows_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
|
||||
MEMACCESS(6) \
|
||||
"vld2.8 {d6["#n"], d7["#n"]}, [%6] \n"
|
||||
|
||||
// The NEON version mimics this formula (from row_common.cc):
|
||||
// #define BLENDER(a, b, f) (uint8)((int)(a) +
|
||||
// ((((int)((f)) * ((int)(b) - (int)(a))) + 0x8000) >> 16))
|
||||
|
||||
void ScaleFilterCols_NEON(uint8* dst_ptr, const uint8* src_ptr,
|
||||
int dst_width, int x, int dx) {
|
||||
int dx_offset[4] = {0, 1, 2, 3};
|
||||
@@ -608,8 +612,8 @@ void ScaleFilterCols_NEON(uint8* dst_ptr, const uint8* src_ptr,
|
||||
"vmovl.u16 q10, d21 \n"
|
||||
"vmul.s32 q11, q11, q13 \n"
|
||||
"vmul.s32 q12, q12, q10 \n"
|
||||
"vshrn.s32 d18, q11, #16 \n"
|
||||
"vshrn.s32 d19, q12, #16 \n"
|
||||
"vrshrn.s32 d18, q11, #16 \n"
|
||||
"vrshrn.s32 d19, q12, #16 \n"
|
||||
"vadd.s16 q8, q8, q9 \n"
|
||||
"vmovn.s16 d6, q8 \n"
|
||||
|
||||
|
||||
@@ -587,6 +587,10 @@ void ScaleAddRows_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
|
||||
MEMACCESS(6) \
|
||||
"ld2 {v4.b, v5.b}["#n"], [%6] \n"
|
||||
|
||||
// The NEON version mimics this formula (from row_common.cc):
|
||||
// #define BLENDER(a, b, f) (uint8)((int)(a) +
|
||||
// ((((int)((f)) * ((int)(b) - (int)(a))) + 0x8000) >> 16))
|
||||
|
||||
void ScaleFilterCols_NEON(uint8* dst_ptr, const uint8* src_ptr,
|
||||
int dst_width, int x, int dx) {
|
||||
int dx_offset[4] = {0, 1, 2, 3};
|
||||
@@ -626,8 +630,8 @@ void ScaleFilterCols_NEON(uint8* dst_ptr, const uint8* src_ptr,
|
||||
"ushll2 v6.4s, v6.8h, #0 \n"
|
||||
"mul v16.4s, v16.4s, v7.4s \n"
|
||||
"mul v17.4s, v17.4s, v6.4s \n"
|
||||
"shrn v6.4h, v16.4s, #16 \n"
|
||||
"shrn2 v6.8h, v17.4s, #16 \n"
|
||||
"rshrn v6.4h, v16.4s, #16 \n"
|
||||
"rshrn2 v6.8h, v17.4s, #16 \n"
|
||||
"add v4.8h, v4.8h, v6.8h \n"
|
||||
"xtn v4.8b, v4.8h \n"
|
||||
|
||||
|
||||
@@ -860,6 +860,16 @@ void ScaleAddRow_AVX2(const uint8* src_ptr, uint16* dst_ptr, int src_width) {
|
||||
}
|
||||
#endif // HAS_SCALEADDROW_AVX2
|
||||
|
||||
// Constant for making pixels signed to avoid pmaddubsw
|
||||
// saturation.
|
||||
static uvec8 kFsub80 =
|
||||
{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
|
||||
|
||||
// Constant for making pixels unsigned and adding .5 for rounding.
|
||||
static uvec16 kFadd40 =
|
||||
{ 0x4040, 0x4040, 0x4040, 0x4040, 0x4040, 0x4040, 0x4040, 0x4040 };
|
||||
|
||||
// Bilinear column filtering. SSSE3 version.
|
||||
__declspec(naked)
|
||||
void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
|
||||
@@ -877,6 +887,8 @@ void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
|
||||
movd xmm5, eax
|
||||
pcmpeqb xmm6, xmm6 // generate 0x007f for inverting fraction.
|
||||
psrlw xmm6, 9
|
||||
pcmpeqb xmm7, xmm7 // generate 0x0001
|
||||
psrlw xmm7, 15
|
||||
pextrw eax, xmm2, 1 // get x0 integer. preroll
|
||||
sub ecx, 2
|
||||
jl xloop29
|
||||
@@ -899,20 +911,22 @@ void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
|
||||
movd xmm4, ebx
|
||||
pshufb xmm1, xmm5 // 0011
|
||||
punpcklwd xmm0, xmm4
|
||||
psubb xmm0, xmmword ptr kFsub80 // make pixels signed.
|
||||
pxor xmm1, xmm6 // 0..7f and 7f..0
|
||||
pmaddubsw xmm0, xmm1 // 16 bit, 2 pixels.
|
||||
paddusb xmm1, xmm7 // +1 so 0..7f and 80..1
|
||||
pmaddubsw xmm1, xmm0 // 16 bit, 2 pixels.
|
||||
pextrw eax, xmm2, 1 // get x0 integer. next iteration.
|
||||
pextrw edx, xmm2, 3 // get x1 integer. next iteration.
|
||||
psrlw xmm0, 7 // 8.7 fixed point to low 8 bits.
|
||||
packuswb xmm0, xmm0 // 8 bits, 2 pixels.
|
||||
movd ebx, xmm0
|
||||
paddw xmm1, xmmword ptr kFadd40 // make pixels unsigned and round.
|
||||
psrlw xmm1, 7 // 8.7 fixed point to low 8 bits.
|
||||
packuswb xmm1, xmm1 // 8 bits, 2 pixels.
|
||||
movd ebx, xmm1
|
||||
mov [edi], bx
|
||||
lea edi, [edi + 2]
|
||||
sub ecx, 2 // 2 pixels
|
||||
jge xloop2
|
||||
|
||||
xloop29:
|
||||
|
||||
add ecx, 2 - 1
|
||||
jl xloop99
|
||||
|
||||
@@ -921,11 +935,14 @@ void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
|
||||
movd xmm0, ebx
|
||||
psrlw xmm2, 9 // 7 bit fractions.
|
||||
pshufb xmm2, xmm5 // 0011
|
||||
psubb xmm0, xmmword ptr kFsub80 // make pixels signed.
|
||||
pxor xmm2, xmm6 // 0..7f and 7f..0
|
||||
pmaddubsw xmm0, xmm2 // 16 bit
|
||||
psrlw xmm0, 7 // 8.7 fixed point to low 8 bits.
|
||||
packuswb xmm0, xmm0 // 8 bits
|
||||
movd ebx, xmm0
|
||||
paddusb xmm2, xmm7 // +1 so 0..7f and 80..1
|
||||
pmaddubsw xmm2, xmm0 // 16 bit
|
||||
paddw xmm2, xmmword ptr kFadd40 // make pixels unsigned and round.
|
||||
psrlw xmm2, 7 // 8.7 fixed point to low 8 bits.
|
||||
packuswb xmm2, xmm2 // 8 bits
|
||||
movd ebx, xmm2
|
||||
mov [edi], bl
|
||||
|
||||
xloop99:
|
||||
|
||||
@@ -25,6 +25,7 @@ struct FourCCAliasEntry {
|
||||
|
||||
static const struct FourCCAliasEntry kFourCCAliases[] = {
|
||||
{FOURCC_IYUV, FOURCC_I420},
|
||||
{FOURCC_YU12, FOURCC_I420},
|
||||
{FOURCC_YU16, FOURCC_I422},
|
||||
{FOURCC_YU24, FOURCC_I444},
|
||||
{FOURCC_YUYV, FOURCC_YUY2},
|
||||
|
||||
Reference in new issue
Block a user