From 4abd096548fb718759763ca277c0b5bac2d19e0c Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Mon, 12 Oct 2015 12:02:54 -0700 Subject: [PATCH] fix for yuv to rgb on arm64. fill in aarch64 yuv constants to match how the code expects them. TBR=harryjin@google.com BUG=libyuv:502 Review URL: https://codereview.chromium.org/1396253004 . --- README.chromium | 2 +- include/libyuv/row.h | 17 ++++++++++++----- include/libyuv/version.h | 2 +- source/row_common.cc | 30 +++++++++++++++++++----------- source/row_neon64.cc | 4 ++-- 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/README.chromium b/README.chromium index a8bfc228a..d9be77b08 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1506 +Version: 1507 License: BSD License File: LICENSE diff --git a/include/libyuv/row.h b/include/libyuv/row.h index 43a2de1b8..0754c44f4 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -417,18 +417,25 @@ typedef uint32 ulvec32[8]; typedef uint8 ulvec8[32]; #endif -#if defined(__arm__) || defined(__aarch64__) - -// This struct is for Arm color conversion. +#if defined(__aarch64__) +// This struct is for Arm64 color conversion. +struct YuvConstants { + uvec16 kUVToRB; + uvec16 kUVToRB2; + uvec16 kUVToG; + uvec16 kUVToG2; + vec16 kUVBiasBGR; + vec32 kYToRgb; +}; +#elif defined(__arm__) +// This struct is for ArmV7 color conversion. struct YuvConstants { uvec8 kUVToRB; uvec8 kUVToG; vec16 kUVBiasBGR; vec32 kYToRgb; }; - #else - // This struct is for Intel color conversion. struct YuvConstants { lvec8 kUVToB; diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 69006a268..220c368f9 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 1506 +#define LIBYUV_VERSION 1507 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/row_common.cc b/source/row_common.cc index 7ca85c973..8c1a8027e 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -1017,13 +1017,17 @@ void J400ToARGBRow_C(const uint8* src_y, uint8* dst_argb, int width) { // BT.601 constants for YUV to RGB. // TODO(fbarchard): Unify these structures to be platform independent. // TODO(fbarchard): Generate SIMD structures from float matrix. + +// BT601 constants for YUV to RGB. #if defined(__aarch64__) const YuvConstants SIMD_ALIGNED(kYuvIConstants) = { - { -UB, 0, -UB, 0, -UB, 0, -UB, 0, -VR, 0, -VR, 0, -VR, 0, -VR, 0 }, - { UG, 0, UG, 0, UG, 0, UG, 0, VG, 0, VG, 0, VG, 0, VG, 0 }, + { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, + { -UB, -VR, -UB, -VR, -UB, -VR, -UB, -VR }, + { UG, VG, UG, VG, UG, VG, UG, VG }, + { UG, VG, UG, VG, UG, VG, UG, VG }, { BB, BG, BR, 0, 0, 0, 0, 0 }, { 0x0101 * YG, 0, 0, 0 } - }; +}; #elif defined(__arm__) const YuvConstants SIMD_ALIGNED(kYuvIConstants) = { @@ -1072,8 +1076,8 @@ static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, #if defined(__aarch64__) int UB = -yuvconstants->kUVToRB[0]; int UG = yuvconstants->kUVToG[0]; - int VG = yuvconstants->kUVToG[8]; - int VR = -yuvconstants->kUVToRB[8]; + int VG = yuvconstants->kUVToG[1]; + int VR = -yuvconstants->kUVToRB[1]; int BB = yuvconstants->kUVBiasBGR[0]; int BG = yuvconstants->kUVBiasBGR[1]; int BR = yuvconstants->kUVBiasBGR[2]; @@ -1126,11 +1130,13 @@ static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, // JPEG constants for YUV to RGB. #if defined(__aarch64__) const YuvConstants SIMD_ALIGNED(kYuvJConstants) = { - { -UBJ, 0, -UBJ, 0, -UBJ, 0, -UBJ, 0, -VRJ, 0, -VRJ, 0, -VRJ, 0, -VRJ, 0 }, - { UGJ, 0, UGJ, 0, UGJ, 0, UGJ, 0, VGJ, 0, VGJ, 0, VGJ, 0, VGJ, 0 }, + { -UBJ, -VRJ, -UBJ, -VRJ, -UBJ, -VRJ, -UBJ, -VRJ }, + { -UBJ, -VRJ, -UBJ, -VRJ, -UBJ, -VRJ, -UBJ, -VRJ }, + { UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ }, + { UGJ, VGJ, UGJ, VGJ, UGJ, VGJ, UGJ, VGJ }, { BBJ, BGJ, BRJ, 0, 0, 0, 0, 0 }, { 0x0101 * YGJ, 0, 0, 0 } - }; +}; #elif defined(__arm__) const YuvConstants SIMD_ALIGNED(kYuvJConstants) = { @@ -1194,11 +1200,13 @@ const YuvConstants SIMD_ALIGNED(kYuvJConstants) = { // BT.709 constants for YUV to RGB. #if defined(__aarch64__) const YuvConstants SIMD_ALIGNED(kYuvHConstants) = { - { -UBH, 0, -UBH, 0, -UBH, 0, -UBH, 0, -VRH, 0, -VRH, 0, -VRH, 0, -VRH, 0 }, - { UGH, 0, UGH, 0, UGH, 0, UGH, 0, VGH, 0, VGH, 0, VGH, 0, VGH, 0 }, + { -UBH, -VRH, -UBH, -VRH, -UBH, -VRH, -UBH, -VRH }, + { -UBH, -VRH, -UBH, -VRH, -UBH, -VRH, -UBH, -VRH }, + { UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH }, + { UGH, VGH, UGH, VGH, UGH, VGH, UGH, VGH }, { BBH, BGH, BRH, 0, 0, 0, 0, 0 }, { 0x0101 * YGH, 0, 0, 0 } - }; +}; #elif defined(__arm__) const YuvConstants SIMD_ALIGNED(kYuvHConstants) = { diff --git a/source/row_neon64.cc b/source/row_neon64.cc index f9e264ce2..fdc3cbb89 100644 --- a/source/row_neon64.cc +++ b/source/row_neon64.cc @@ -96,8 +96,8 @@ extern "C" { "ld1r {v25.8h}, [%[kUVBiasBGR]], #2 \n" \ "ld1r {v26.8h}, [%[kUVBiasBGR]] \n" \ "ld1r {v31.4s}, [%[kYToRgb]] \n" \ - "ld1 {v27.8h, v28.8h}, [%[kUVToRB]] \n" \ - "ld1 {v29.8h, v30.8h}, [%[kUVToG]] \n" + "ld2 {v27.8h, v28.8h}, [%[kUVToRB]] \n" \ + "ld2 {v29.8h, v30.8h}, [%[kUVToG]] \n" #define YUVTORGB(vR, vG, vB) \ "uxtl v0.8h, v0.8b \n" /* Extract Y */ \