Commit 013080f2 authored by Frank Barchard's avatar Frank Barchard

Pass yuvconstants to YUV conversions for neon 64 bit

SETUP provided by zhongwei.yao@linaro.org

Previously the 64 bit Neon code had hard coded constants in the setup macro
for YUV conversion, while 32 bit Neon code supported the yuvconstants
parameter.

This change accepts the constants passed to the YUV conversion row function,
allowing different color spaces to be respected - naming JPEG and BT.709.
As well as the existing BT.601.

TBR=harryjin@google.com
BUG=libyuv:472

Review URL: https://codereview.chromium.org/1384323002 .
parent 914a9856
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 1501 Version: 1502
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -458,7 +458,6 @@ struct YuvConstants { ...@@ -458,7 +458,6 @@ struct YuvConstants {
#endif #endif
extern struct YuvConstants kYuvConstants; extern struct YuvConstants kYuvConstants;
extern struct YuvConstants kYvuConstants;
extern struct YuvConstants kYuvJConstants; extern struct YuvConstants kYuvJConstants;
extern struct YuvConstants kYuvHConstants; extern struct YuvConstants kYuvHConstants;
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1501 #define LIBYUV_VERSION 1502
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -1014,21 +1014,21 @@ void J400ToARGBRow_C(const uint8* src_y, uint8* dst_argb, int width) { ...@@ -1014,21 +1014,21 @@ void J400ToARGBRow_C(const uint8* src_y, uint8* dst_argb, int width) {
#define BG (UG * 128 + VG * 128 + YGB) #define BG (UG * 128 + VG * 128 + YGB)
#define BR (VR * 128 + YGB) #define BR (VR * 128 + YGB)
#if defined(__arm__) || defined(__aarch64__) #if defined(__aarch64__)
YuvConstants SIMD_ALIGNED(kYuvConstants) = { YuvConstants SIMD_ALIGNED(kYuvConstants) = {
{ -UB, -UB, -UB, -UB, -VR, -VR, -VR, -VR, 0, 0, 0, 0, 0, 0, 0, 0 }, { -UB, 0, -UB, 0, -UB, 0, -UB, 0, -VR, 0, -VR, 0, -VR, 0, -VR, 0 },
{ UG, UG, UG, UG, VG, VG, VG, VG, 0, 0, 0, 0, 0, 0, 0, 0 }, { UG, 0, UG, 0, UG, 0, UG, 0, VG, 0, VG, 0, VG, 0, VG, 0 },
{ BB, BG, BR, 0, 0, 0, 0, 0 }, { BB, BG, BR, 0, 0, 0, 0, 0 },
{ 0x0101 * YG, 0, 0, 0 } { 0x0101 * YG, 0, 0, 0 }
}; };
YuvConstants SIMD_ALIGNED(kYvuConstants) = { #elif defined(__arm__)
{ -VR, -VR, -VR, -VR, -UB, -UB, -UB, -UB, 0, 0, 0, 0, 0, 0, 0, 0 }, YuvConstants SIMD_ALIGNED(kYuvConstants) = {
{ VG, VG, VG, VG, UG, UG, UG, UG, 0, 0, 0, 0, 0, 0, 0, 0 }, { -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 }, { BB, BG, BR, 0, 0, 0, 0, 0 },
{ 0x0101 * YG, 0, 0, 0 } { 0x0101 * YG, 0, 0, 0 }
}; };
#else #else
// BT601 constants for YUV to RGB. // BT601 constants for YUV to RGB.
YuvConstants SIMD_ALIGNED(kYuvConstants) = { YuvConstants SIMD_ALIGNED(kYuvConstants) = {
...@@ -1081,13 +1081,19 @@ static __inline void YPixel(uint8 y, uint8* b, uint8* g, uint8* r) { ...@@ -1081,13 +1081,19 @@ static __inline void YPixel(uint8 y, uint8* b, uint8* g, uint8* r) {
static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, static __inline void YuvPixel(uint8 y, uint8 u, uint8 v,
uint8* b, uint8* g, uint8* r, uint8* b, uint8* g, uint8* r,
struct YuvConstants* yuvconstants) { struct YuvConstants* yuvconstants) {
#if defined(__arm__) || defined(__aarch64__) #if defined(__aarch64__)
int UB = -yuvconstants->kUVToRB[0];
int UG = yuvconstants->kUVToG[0];
int VG = yuvconstants->kUVToG[8];
int VR = -yuvconstants->kUVToRB[8];
int BB = yuvconstants->kUVBiasBGR[0];
int BG = yuvconstants->kUVBiasBGR[1];
int BR = yuvconstants->kUVBiasBGR[2];
int YG = yuvconstants->kYToRgb[0];
#elif defined(__arm__)
int UB = -yuvconstants->kUVToRB[0]; int UB = -yuvconstants->kUVToRB[0];
int VB = 0;
int UG = yuvconstants->kUVToG[0]; int UG = yuvconstants->kUVToG[0];
int VG = yuvconstants->kUVToG[4]; int VG = yuvconstants->kUVToG[4];
int UR = 0;
int VR = -yuvconstants->kUVToRB[4]; int VR = -yuvconstants->kUVToRB[4];
int BB = yuvconstants->kUVBiasBGR[0]; int BB = yuvconstants->kUVBiasBGR[0];
int BG = yuvconstants->kUVBiasBGR[1]; int BG = yuvconstants->kUVBiasBGR[1];
...@@ -1095,10 +1101,8 @@ static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, ...@@ -1095,10 +1101,8 @@ static __inline void YuvPixel(uint8 y, uint8 u, uint8 v,
int YG = yuvconstants->kYToRgb[0]; int YG = yuvconstants->kYToRgb[0];
#else #else
int UB = yuvconstants->kUVToB[0]; int UB = yuvconstants->kUVToB[0];
int VB = yuvconstants->kUVToB[1]; // usually 0
int UG = yuvconstants->kUVToG[0]; int UG = yuvconstants->kUVToG[0];
int VG = yuvconstants->kUVToG[1]; int VG = yuvconstants->kUVToG[1];
int UR = yuvconstants->kUVToR[0]; // usually 0
int VR = yuvconstants->kUVToR[1]; int VR = yuvconstants->kUVToR[1];
int BB = yuvconstants->kUVBiasB[0]; int BB = yuvconstants->kUVBiasB[0];
int BG = yuvconstants->kUVBiasG[0]; int BG = yuvconstants->kUVBiasG[0];
...@@ -1106,9 +1110,9 @@ static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, ...@@ -1106,9 +1110,9 @@ static __inline void YuvPixel(uint8 y, uint8 u, uint8 v,
int YG = yuvconstants->kYToRgb[0]; int YG = yuvconstants->kYToRgb[0];
#endif #endif
uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16;
*b = Clamp((int32)(-(u * UB + v * VB) + y1 + BB) >> 6); *b = Clamp((int32)(-(u * UB ) + y1 + BB) >> 6);
*g = Clamp((int32)(-(u * UG + v * VG) + y1 + BG) >> 6); *g = Clamp((int32)(-(u * UG + v * VG) + y1 + BG) >> 6);
*r = Clamp((int32)(-(u * UR + v * VR) + y1 + BR) >> 6); *r = Clamp((int32)(-( v * VR) + y1 + BR) >> 6);
} }
// JPEG YUV to RGB reference // JPEG YUV to RGB reference
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment