Commit ecb3f4cc authored by fbarchard@google.com's avatar fbarchard@google.com

Reorder functions for consistency when doing RGB functions. Order should now be…

Reorder functions for consistency when doing RGB functions.  Order should now be ARGB, BGRA, ABGR, RGB24, RAW, RGB565, ARGB1555, ARGB4444
BUG=none
TEST=none
Review URL: https://webrtc-codereview.appspot.com/352013

git-svn-id: http://libyuv.googlecode.com/svn/trunk@136 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 44477b26
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 135
Version: 136
License: BSD
License File: LICENSE
......
......@@ -1621,69 +1621,8 @@ int I420ToABGR(const uint8* src_y, int src_stride_y,
return 0;
}
// Convert NV12 to RGB565.
int NV12ToRGB565(const uint8* src_y, int src_stride_y,
const uint8* src_uv, int src_stride_uv,
uint8* dst_rgb, int dst_stride_rgb,
int width, int height) {
// Negative height means invert the image.
if (height < 0) {
height = -height;
dst_rgb = dst_rgb + (height - 1) * dst_stride_rgb;
dst_stride_rgb = -dst_stride_rgb;
}
void (*FastConvertYUVToRGB565Row)(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
int width);
#if defined(HAS_FASTCONVERTYUVTORGB565ROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) {
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_NEON;
} else
#elif defined(HAS_FASTCONVERTYUVTORGB565ROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) &&
IS_ALIGNED(width, 8) &&
IS_ALIGNED(dst_rgb, 16) && IS_ALIGNED(dst_stride_rgb, 16)) {
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_SSSE3;
} else
#endif
{
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_C;
}
int halfwidth = (width + 1) >> 1;
void (*SplitUV)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix);
#if defined(HAS_SPLITUV_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(halfwidth, 16)) {
SplitUV = SplitUV_NEON;
} else
#elif defined(HAS_SPLITUV_SSE2)
if (TestCpuFlag(kCpuHasSSE2) &&
IS_ALIGNED(halfwidth, 16) &&
IS_ALIGNED(src_uv, 16) && IS_ALIGNED(src_stride_uv, 16)) {
SplitUV = SplitUV_SSE2;
} else
#endif
{
SplitUV = SplitUV_C;
}
SIMD_ALIGNED(uint8 row[kMaxStride * 2]);
for (int y = 0; y < height; ++y) {
if ((y & 1) == 0) {
// Copy a row of UV.
SplitUV(src_uv, row, row + kMaxStride, halfwidth);
src_uv += src_stride_uv;
}
FastConvertYUVToRGB565Row(src_y, row, row + kMaxStride, dst_rgb, width);
dst_rgb += dst_stride_rgb;
src_y += src_stride_y;
}
return 0;
}
// Convert I420 to RGB565.
int I420ToRGB565(const uint8* src_y, int src_stride_y,
// Convert I420 to RGB24.
int I420ToRGB24(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
......@@ -1694,27 +1633,27 @@ int I420ToRGB565(const uint8* src_y, int src_stride_y,
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
void (*FastConvertYUVToRGB565Row)(const uint8* y_buf,
void (*FastConvertYUVToRGB24Row)(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
int width);
#if defined(HAS_FASTCONVERTYUVTORGB565ROW_NEON)
#if defined(HAS_FASTCONVERTYUVTORGB24ROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) {
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_NEON;
FastConvertYUVToRGB24Row = FastConvertYUVToRGB24Row_NEON;
} else
#elif defined(HAS_FASTCONVERTYUVTORGB565ROW_SSSE3)
#elif defined(HAS_FASTCONVERTYUVTORGB24ROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) &&
IS_ALIGNED(width, 8) &&
IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) {
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_SSSE3;
FastConvertYUVToRGB24Row = FastConvertYUVToRGB24Row_SSSE3;
} else
#endif
{
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_C;
FastConvertYUVToRGB24Row = FastConvertYUVToRGB24Row_C;
}
for (int y = 0; y < height; ++y) {
FastConvertYUVToRGB565Row(src_y, src_u, src_v, dst_argb, width);
FastConvertYUVToRGB24Row(src_y, src_u, src_v, dst_argb, width);
dst_argb += dst_stride_argb;
src_y += src_stride_y;
if (y & 1) {
......@@ -1725,8 +1664,8 @@ int I420ToRGB565(const uint8* src_y, int src_stride_y,
return 0;
}
// Convert I420 to ARGB1555.
int I420ToARGB1555(const uint8* src_y, int src_stride_y,
// Convert I420 to RAW.
int I420ToRAW(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
......@@ -1737,27 +1676,27 @@ int I420ToARGB1555(const uint8* src_y, int src_stride_y,
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
void (*FastConvertYUVToARGB1555Row)(const uint8* y_buf,
void (*FastConvertYUVToRAWRow)(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
int width);
#if defined(HAS_FASTCONVERTYUVTOARGB1555ROW_NEON)
#if defined(HAS_FASTCONVERTYUVTORAWROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) {
FastConvertYUVToARGB1555Row = FastConvertYUVToARGB1555Row_NEON;
FastConvertYUVToRAWRow = FastConvertYUVToRAWRow_NEON;
} else
#elif defined(HAS_FASTCONVERTYUVTOARGB1555ROW_SSSE3)
#elif defined(HAS_FASTCONVERTYUVTORAWROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) &&
IS_ALIGNED(width, 8) &&
IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) {
FastConvertYUVToARGB1555Row = FastConvertYUVToARGB1555Row_SSSE3;
FastConvertYUVToRAWRow = FastConvertYUVToRAWRow_SSSE3;
} else
#endif
{
FastConvertYUVToARGB1555Row = FastConvertYUVToARGB1555Row_C;
FastConvertYUVToRAWRow = FastConvertYUVToRAWRow_C;
}
for (int y = 0; y < height; ++y) {
FastConvertYUVToARGB1555Row(src_y, src_u, src_v, dst_argb, width);
FastConvertYUVToRAWRow(src_y, src_u, src_v, dst_argb, width);
dst_argb += dst_stride_argb;
src_y += src_stride_y;
if (y & 1) {
......@@ -1767,8 +1706,9 @@ int I420ToARGB1555(const uint8* src_y, int src_stride_y,
}
return 0;
}
// Convert I420 to ARGB4444.
int I420ToARGB4444(const uint8* src_y, int src_stride_y,
// Convert I420 to RGB565.
int I420ToRGB565(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
......@@ -1779,27 +1719,27 @@ int I420ToARGB4444(const uint8* src_y, int src_stride_y,
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
void (*FastConvertYUVToARGB4444Row)(const uint8* y_buf,
void (*FastConvertYUVToRGB565Row)(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
int width);
#if defined(HAS_FASTCONVERTYUVTOARGB4444ROW_NEON)
#if defined(HAS_FASTCONVERTYUVTORGB565ROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) {
FastConvertYUVToARGB4444Row = FastConvertYUVToARGB4444Row_NEON;
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_NEON;
} else
#elif defined(HAS_FASTCONVERTYUVTOARGB4444ROW_SSSE3)
#elif defined(HAS_FASTCONVERTYUVTORGB565ROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) &&
IS_ALIGNED(width, 8) &&
IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) {
FastConvertYUVToARGB4444Row = FastConvertYUVToARGB4444Row_SSSE3;
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_SSSE3;
} else
#endif
{
FastConvertYUVToARGB4444Row = FastConvertYUVToARGB4444Row_C;
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_C;
}
for (int y = 0; y < height; ++y) {
FastConvertYUVToARGB4444Row(src_y, src_u, src_v, dst_argb, width);
FastConvertYUVToRGB565Row(src_y, src_u, src_v, dst_argb, width);
dst_argb += dst_stride_argb;
src_y += src_stride_y;
if (y & 1) {
......@@ -1809,8 +1749,9 @@ int I420ToARGB4444(const uint8* src_y, int src_stride_y,
}
return 0;
}
// Convert I420 to RGB24.
int I420ToRGB24(const uint8* src_y, int src_stride_y,
// Convert I420 to ARGB1555.
int I420ToARGB1555(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
......@@ -1821,27 +1762,27 @@ int I420ToRGB24(const uint8* src_y, int src_stride_y,
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
void (*FastConvertYUVToRGB24Row)(const uint8* y_buf,
void (*FastConvertYUVToARGB1555Row)(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
int width);
#if defined(HAS_FASTCONVERTYUVTORGB24ROW_NEON)
#if defined(HAS_FASTCONVERTYUVTOARGB1555ROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) {
FastConvertYUVToRGB24Row = FastConvertYUVToRGB24Row_NEON;
FastConvertYUVToARGB1555Row = FastConvertYUVToARGB1555Row_NEON;
} else
#elif defined(HAS_FASTCONVERTYUVTORGB24ROW_SSSE3)
#elif defined(HAS_FASTCONVERTYUVTOARGB1555ROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) &&
IS_ALIGNED(width, 8) &&
IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) {
FastConvertYUVToRGB24Row = FastConvertYUVToRGB24Row_SSSE3;
FastConvertYUVToARGB1555Row = FastConvertYUVToARGB1555Row_SSSE3;
} else
#endif
{
FastConvertYUVToRGB24Row = FastConvertYUVToRGB24Row_C;
FastConvertYUVToARGB1555Row = FastConvertYUVToARGB1555Row_C;
}
for (int y = 0; y < height; ++y) {
FastConvertYUVToRGB24Row(src_y, src_u, src_v, dst_argb, width);
FastConvertYUVToARGB1555Row(src_y, src_u, src_v, dst_argb, width);
dst_argb += dst_stride_argb;
src_y += src_stride_y;
if (y & 1) {
......@@ -1851,8 +1792,8 @@ int I420ToRGB24(const uint8* src_y, int src_stride_y,
}
return 0;
}
// Convert I420 to RAW.
int I420ToRAW(const uint8* src_y, int src_stride_y,
// Convert I420 to ARGB4444.
int I420ToARGB4444(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_argb, int dst_stride_argb,
......@@ -1863,27 +1804,27 @@ int I420ToRAW(const uint8* src_y, int src_stride_y,
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
void (*FastConvertYUVToRAWRow)(const uint8* y_buf,
void (*FastConvertYUVToARGB4444Row)(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
int width);
#if defined(HAS_FASTCONVERTYUVTORAWROW_NEON)
#if defined(HAS_FASTCONVERTYUVTOARGB4444ROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) {
FastConvertYUVToRAWRow = FastConvertYUVToRAWRow_NEON;
FastConvertYUVToARGB4444Row = FastConvertYUVToARGB4444Row_NEON;
} else
#elif defined(HAS_FASTCONVERTYUVTORAWROW_SSSE3)
#elif defined(HAS_FASTCONVERTYUVTOARGB4444ROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) &&
IS_ALIGNED(width, 8) &&
IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride_argb, 16)) {
FastConvertYUVToRAWRow = FastConvertYUVToRAWRow_SSSE3;
FastConvertYUVToARGB4444Row = FastConvertYUVToARGB4444Row_SSSE3;
} else
#endif
{
FastConvertYUVToRAWRow = FastConvertYUVToRAWRow_C;
FastConvertYUVToARGB4444Row = FastConvertYUVToARGB4444Row_C;
}
for (int y = 0; y < height; ++y) {
FastConvertYUVToRAWRow(src_y, src_u, src_v, dst_argb, width);
FastConvertYUVToARGB4444Row(src_y, src_u, src_v, dst_argb, width);
dst_argb += dst_stride_argb;
src_y += src_stride_y;
if (y & 1) {
......@@ -2179,6 +2120,67 @@ int BG24ToARGB(const uint8* src_rgb24, int src_stride_rgb24,
}
// Convert NV12 to RGB565.
int NV12ToRGB565(const uint8* src_y, int src_stride_y,
const uint8* src_uv, int src_stride_uv,
uint8* dst_rgb, int dst_stride_rgb,
int width, int height) {
// Negative height means invert the image.
if (height < 0) {
height = -height;
dst_rgb = dst_rgb + (height - 1) * dst_stride_rgb;
dst_stride_rgb = -dst_stride_rgb;
}
void (*FastConvertYUVToRGB565Row)(const uint8* y_buf,
const uint8* u_buf,
const uint8* v_buf,
uint8* rgb_buf,
int width);
#if defined(HAS_FASTCONVERTYUVTORGB565ROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) {
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_NEON;
} else
#elif defined(HAS_FASTCONVERTYUVTORGB565ROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) &&
IS_ALIGNED(width, 8) &&
IS_ALIGNED(dst_rgb, 16) && IS_ALIGNED(dst_stride_rgb, 16)) {
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_SSSE3;
} else
#endif
{
FastConvertYUVToRGB565Row = FastConvertYUVToRGB565Row_C;
}
int halfwidth = (width + 1) >> 1;
void (*SplitUV)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix);
#if defined(HAS_SPLITUV_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(halfwidth, 16)) {
SplitUV = SplitUV_NEON;
} else
#elif defined(HAS_SPLITUV_SSE2)
if (TestCpuFlag(kCpuHasSSE2) &&
IS_ALIGNED(halfwidth, 16) &&
IS_ALIGNED(src_uv, 16) && IS_ALIGNED(src_stride_uv, 16)) {
SplitUV = SplitUV_SSE2;
} else
#endif
{
SplitUV = SplitUV_C;
}
SIMD_ALIGNED(uint8 row[kMaxStride * 2]);
for (int y = 0; y < height; ++y) {
if ((y & 1) == 0) {
// Copy a row of UV.
SplitUV(src_uv, row, row + kMaxStride, halfwidth);
src_uv += src_stride_uv;
}
FastConvertYUVToRGB565Row(src_y, row, row + kMaxStride, dst_rgb, width);
dst_rgb += dst_stride_rgb;
src_y += src_stride_y;
}
return 0;
}
// SetRow8 writes 'count' bytes using a 32 bit value repeated
// SetRow32 writes 'count' words using a 32 bit value repeated
......
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