mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-07 17:26:49 +08:00
AVX2 version of NV12ToARGB
BUG=403 TESTED=untested R=harryjin@google.com Review URL: https://webrtc-codereview.appspot.com/40089004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@1295 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
3c11d4bf6e
commit
d96047761e
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 1294
|
||||
Version: 1295
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -187,6 +187,8 @@ extern "C" {
|
||||
#define HAS_I422TOARGBROW_AVX2
|
||||
#define HAS_I422TOBGRAROW_AVX2
|
||||
#define HAS_I422TORGBAROW_AVX2
|
||||
#define HAS_NV12TOARGBROW_AVX2
|
||||
#define HAS_NV21TOARGBROW_AVX2
|
||||
#endif
|
||||
|
||||
// The following are available on all x86 platforms, but
|
||||
@ -1044,6 +1046,14 @@ void NV21ToARGBRow_SSSE3(const uint8* src_y,
|
||||
const uint8* src_vu,
|
||||
uint8* dst_argb,
|
||||
int width);
|
||||
void NV12ToARGBRow_AVX2(const uint8* src_y,
|
||||
const uint8* src_uv,
|
||||
uint8* dst_argb,
|
||||
int width);
|
||||
void NV21ToARGBRow_AVX2(const uint8* src_y,
|
||||
const uint8* src_vu,
|
||||
uint8* dst_argb,
|
||||
int width);
|
||||
void NV12ToRGB565Row_SSSE3(const uint8* src_y,
|
||||
const uint8* src_uv,
|
||||
uint8* dst_argb,
|
||||
@ -1175,6 +1185,14 @@ void NV21ToARGBRow_Any_SSSE3(const uint8* src_y,
|
||||
const uint8* src_vu,
|
||||
uint8* dst_argb,
|
||||
int width);
|
||||
void NV12ToARGBRow_Any_AVX2(const uint8* src_y,
|
||||
const uint8* src_uv,
|
||||
uint8* dst_argb,
|
||||
int width);
|
||||
void NV21ToARGBRow_Any_AVX2(const uint8* src_y,
|
||||
const uint8* src_vu,
|
||||
uint8* dst_argb,
|
||||
int width);
|
||||
void NV12ToRGB565Row_Any_SSSE3(const uint8* src_y,
|
||||
const uint8* src_uv,
|
||||
uint8* dst_argb,
|
||||
|
||||
@ -11,6 +11,6 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 1294
|
||||
#define LIBYUV_VERSION 1295
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
|
||||
|
||||
@ -698,6 +698,14 @@ int NV12ToARGB(const uint8* src_y, int src_stride_y,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_Any_AVX2;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_Any_NEON;
|
||||
@ -747,6 +755,14 @@ int NV21ToARGB(const uint8* src_y, int src_stride_y,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV21TOARGBROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
NV21ToARGBRow = NV21ToARGBRow_Any_AVX2;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
NV21ToARGBRow = NV21ToARGBRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV21TOARGBROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
NV21ToARGBRow = NV21ToARGBRow_Any_NEON;
|
||||
@ -795,6 +811,14 @@ int M420ToARGB(const uint8* src_m420, int src_stride_m420,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_Any_AVX2;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_Any_NEON;
|
||||
|
||||
@ -121,6 +121,10 @@ YANY(I422ToUYVYRow_Any_NEON, I422ToUYVYRow_NEON, I422ToUYVYRow_C, 1, 2, 15)
|
||||
NV2NY(NV12ToARGBRow_Any_SSSE3, NV12ToARGBRow_SSSE3, NV12ToARGBRow_C, 0, 4, 7)
|
||||
NV2NY(NV21ToARGBRow_Any_SSSE3, NV21ToARGBRow_SSSE3, NV21ToARGBRow_C, 0, 4, 7)
|
||||
#endif // HAS_NV12TOARGBROW_SSSE3
|
||||
#ifdef HAS_NV12TOARGBROW_AVX2
|
||||
NV2NY(NV12ToARGBRow_Any_AVX2, NV12ToARGBRow_AVX2, NV12ToARGBRow_C, 0, 4, 15)
|
||||
NV2NY(NV21ToARGBRow_Any_AVX2, NV21ToARGBRow_AVX2, NV21ToARGBRow_C, 0, 4, 15)
|
||||
#endif // HAS_NV12TOARGBROW_AVX2
|
||||
#ifdef HAS_NV12TOARGBROW_NEON
|
||||
NV2NY(NV12ToARGBRow_Any_NEON, NV12ToARGBRow_NEON, NV12ToARGBRow_C, 0, 4, 7)
|
||||
NV2NY(NV21ToARGBRow_Any_NEON, NV21ToARGBRow_NEON, NV21ToARGBRow_C, 0, 4, 7)
|
||||
|
||||
@ -1490,6 +1490,14 @@ void RGBAToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb,
|
||||
__asm vpunpcklwd ymm0, ymm0, ymm0 /* UVUV (upsample) */ \
|
||||
}
|
||||
|
||||
// Read 8 UV from NV12, upsample to 16 UV.
|
||||
#define READNV12_AVX2 __asm { \
|
||||
__asm vmovdqu xmm0, [esi] /* UV */ \
|
||||
__asm lea esi, [esi + 16] \
|
||||
__asm vpermq ymm0, ymm0, 0xd8 \
|
||||
__asm vpunpcklwd ymm0, ymm0, ymm0 /* UVUV (upsample) */ \
|
||||
}
|
||||
|
||||
// Convert 16 pixels: 16 UV and 16 Y.
|
||||
#define YUVTORGB_AVX2(YuvConstants) __asm { \
|
||||
/* Step 1: Find 8 UV contributions to 16 R,G,B values */ \
|
||||
@ -1519,6 +1527,20 @@ void RGBAToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb,
|
||||
__asm vpackuswb ymm2, ymm2, ymm2 /* R */ \
|
||||
}
|
||||
|
||||
// Store 16 ARGB values.
|
||||
#define STOREARGB_AVX2 __asm { \
|
||||
/* Step 3: Weave into ARGB */ \
|
||||
__asm vpunpcklbw ymm0, ymm0, ymm1 /* BG */ \
|
||||
__asm vpermq ymm0, ymm0, 0xd8 \
|
||||
__asm vpunpcklbw ymm2, ymm2, ymm5 /* RA */ \
|
||||
__asm vpermq ymm2, ymm2, 0xd8 \
|
||||
__asm vpunpcklwd ymm1, ymm0, ymm2 /* BGRA first 8 pixels */ \
|
||||
__asm vpunpckhwd ymm0, ymm0, ymm2 /* BGRA next 8 pixels */ \
|
||||
__asm vmovdqu [edx], ymm1 \
|
||||
__asm vmovdqu [edx + 32], ymm0 \
|
||||
__asm lea edx, [edx + 64] \
|
||||
}
|
||||
|
||||
#ifdef HAS_I422TOARGBROW_AVX2
|
||||
// 16 pixels
|
||||
// 8 UV values upsampled to 16 UV, mixed with 16 Y producing 16 ARGB (64 bytes).
|
||||
@ -1542,17 +1564,8 @@ void I422ToARGBRow_AVX2(const uint8* y_buf,
|
||||
convertloop:
|
||||
READYUV422_AVX2
|
||||
YUVTORGB_AVX2(kYuvConstants)
|
||||
STOREARGB_AVX2
|
||||
|
||||
// Step 3: Weave into ARGB
|
||||
vpunpcklbw ymm0, ymm0, ymm1 // BG
|
||||
vpermq ymm0, ymm0, 0xd8
|
||||
vpunpcklbw ymm2, ymm2, ymm5 // RA
|
||||
vpermq ymm2, ymm2, 0xd8
|
||||
vpunpcklwd ymm1, ymm0, ymm2 // BGRA first 8 pixels
|
||||
vpunpckhwd ymm0, ymm0, ymm2 // BGRA next 8 pixels
|
||||
vmovdqu [edx], ymm1
|
||||
vmovdqu [edx + 32], ymm0
|
||||
lea edx, [edx + 64]
|
||||
sub ecx, 16
|
||||
jg convertloop
|
||||
|
||||
@ -1564,6 +1577,62 @@ void I422ToARGBRow_AVX2(const uint8* y_buf,
|
||||
}
|
||||
#endif // HAS_I422TOARGBROW_AVX2
|
||||
|
||||
// 16 pixels.
|
||||
// 8 UV values upsampled to 16 UV, mixed with 16 Y producing 16 ARGB (64 bytes).
|
||||
__declspec(naked) __declspec(align(16))
|
||||
void NV12ToARGBRow_AVX2(const uint8* y_buf,
|
||||
const uint8* uv_buf,
|
||||
uint8* dst_argb,
|
||||
int width) {
|
||||
__asm {
|
||||
push esi
|
||||
mov eax, [esp + 4 + 4] // Y
|
||||
mov esi, [esp + 4 + 8] // UV
|
||||
mov edx, [esp + 4 + 12] // argb
|
||||
mov ecx, [esp + 4 + 16] // width
|
||||
vpcmpeqb ymm5, ymm5, ymm5 // generate 0xffffffffffffffff for alpha
|
||||
|
||||
convertloop:
|
||||
READNV12_AVX2
|
||||
YUVTORGB_AVX2(kYuvConstants)
|
||||
STOREARGB_AVX2
|
||||
|
||||
sub ecx, 16
|
||||
jg convertloop
|
||||
|
||||
pop esi
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
// 16 pixels.
|
||||
// 8 VU values upsampled to 16 VU, mixed with 16 Y producing 16 ARGB (64 bytes).
|
||||
__declspec(naked) __declspec(align(16))
|
||||
void NV21ToARGBRow_AVX2(const uint8* y_buf,
|
||||
const uint8* uv_buf,
|
||||
uint8* dst_argb,
|
||||
int width) {
|
||||
__asm {
|
||||
push esi
|
||||
mov eax, [esp + 4 + 4] // Y
|
||||
mov esi, [esp + 4 + 8] // UV
|
||||
mov edx, [esp + 4 + 12] // argb
|
||||
mov ecx, [esp + 4 + 16] // width
|
||||
vpcmpeqb ymm5, ymm5, ymm5 // generate 0xffffffffffffffff for alpha
|
||||
|
||||
convertloop:
|
||||
READNV12_AVX2
|
||||
YUVTORGB_AVX2(kYvuConstants)
|
||||
STOREARGB_AVX2
|
||||
|
||||
sub ecx, 16
|
||||
jg convertloop
|
||||
|
||||
pop esi
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAS_I422TOBGRAROW_AVX2
|
||||
// 16 pixels
|
||||
// 8 UV values upsampled to 16 UV, mixed with 16 Y producing 16 BGRA (64 bytes).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user