| Index: source/planar_functions.cc
|
| diff --git a/source/planar_functions.cc b/source/planar_functions.cc
|
| index 33b77fafe9beaa72056899dfeab4a7087598540e..00b9287a33e916d6207bf8226d97c250a65a1b3c 100644
|
| --- a/source/planar_functions.cc
|
| +++ b/source/planar_functions.cc
|
| @@ -764,78 +764,67 @@ int ARGBSubtract(const uint8* src_argb0, int src_stride_argb0,
|
| }
|
| return 0;
|
| }
|
| -
|
| -// Convert I422 to BGRA.
|
| -LIBYUV_API
|
| -int I422ToBGRA(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_bgra, int dst_stride_bgra,
|
| - int width, int height) {
|
| +// Convert I422 to RGBA with matrix
|
| +static int I422ToRGBAMatrix(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_rgba, int dst_stride_rgba,
|
| + const struct YuvConstants* yuvconstants,
|
| + int width, int height) {
|
| int y;
|
| - void (*I422ToBGRARow)(const uint8* y_buf,
|
| + void (*I422ToRGBARow)(const uint8* y_buf,
|
| const uint8* u_buf,
|
| const uint8* v_buf,
|
| uint8* rgb_buf,
|
| const struct YuvConstants* yuvconstants,
|
| - int width) = I422ToBGRARow_C;
|
| - if (!src_y || !src_u || !src_v ||
|
| - !dst_bgra ||
|
| + int width) = I422ToRGBARow_C;
|
| + if (!src_y || !src_u || !src_v || !dst_rgba ||
|
| width <= 0 || height == 0) {
|
| return -1;
|
| }
|
| // Negative height means invert the image.
|
| if (height < 0) {
|
| height = -height;
|
| - dst_bgra = dst_bgra + (height - 1) * dst_stride_bgra;
|
| - dst_stride_bgra = -dst_stride_bgra;
|
| - }
|
| - // Coalesce rows.
|
| - if (src_stride_y == width &&
|
| - src_stride_u * 2 == width &&
|
| - src_stride_v * 2 == width &&
|
| - dst_stride_bgra == width * 4) {
|
| - width *= height;
|
| - height = 1;
|
| - src_stride_y = src_stride_u = src_stride_v = dst_stride_bgra = 0;
|
| + dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba;
|
| + dst_stride_rgba = -dst_stride_rgba;
|
| }
|
| -#if defined(HAS_I422TOBGRAROW_SSSE3)
|
| +#if defined(HAS_I422TORGBAROW_SSSE3)
|
| if (TestCpuFlag(kCpuHasSSSE3)) {
|
| - I422ToBGRARow = I422ToBGRARow_Any_SSSE3;
|
| + I422ToRGBARow = I422ToRGBARow_Any_SSSE3;
|
| if (IS_ALIGNED(width, 8)) {
|
| - I422ToBGRARow = I422ToBGRARow_SSSE3;
|
| + I422ToRGBARow = I422ToRGBARow_SSSE3;
|
| }
|
| }
|
| #endif
|
| -#if defined(HAS_I422TOBGRAROW_AVX2)
|
| +#if defined(HAS_I422TORGBAROW_AVX2)
|
| if (TestCpuFlag(kCpuHasAVX2)) {
|
| - I422ToBGRARow = I422ToBGRARow_Any_AVX2;
|
| + I422ToRGBARow = I422ToRGBARow_Any_AVX2;
|
| if (IS_ALIGNED(width, 16)) {
|
| - I422ToBGRARow = I422ToBGRARow_AVX2;
|
| + I422ToRGBARow = I422ToRGBARow_AVX2;
|
| }
|
| }
|
| #endif
|
| -#if defined(HAS_I422TOBGRAROW_NEON)
|
| +#if defined(HAS_I422TORGBAROW_NEON)
|
| if (TestCpuFlag(kCpuHasNEON)) {
|
| - I422ToBGRARow = I422ToBGRARow_Any_NEON;
|
| + I422ToRGBARow = I422ToRGBARow_Any_NEON;
|
| if (IS_ALIGNED(width, 8)) {
|
| - I422ToBGRARow = I422ToBGRARow_NEON;
|
| + I422ToRGBARow = I422ToRGBARow_NEON;
|
| }
|
| }
|
| #endif
|
| -#if defined(HAS_I422TOBGRAROW_MIPS_DSPR2)
|
| +#if defined(HAS_I422TORGBAROW_MIPS_DSPR2)
|
| if (TestCpuFlag(kCpuHasMIPS_DSPR2) && IS_ALIGNED(width, 4) &&
|
| IS_ALIGNED(src_y, 4) && IS_ALIGNED(src_stride_y, 4) &&
|
| IS_ALIGNED(src_u, 2) && IS_ALIGNED(src_stride_u, 2) &&
|
| IS_ALIGNED(src_v, 2) && IS_ALIGNED(src_stride_v, 2) &&
|
| - IS_ALIGNED(dst_bgra, 4) && IS_ALIGNED(dst_stride_bgra, 4)) {
|
| - I422ToBGRARow = I422ToBGRARow_MIPS_DSPR2;
|
| + IS_ALIGNED(dst_rgba, 4) && IS_ALIGNED(dst_stride_rgba, 4)) {
|
| + I422ToRGBARow = I422ToRGBARow_MIPS_DSPR2;
|
| }
|
| #endif
|
|
|
| for (y = 0; y < height; ++y) {
|
| - I422ToBGRARow(src_y, src_u, src_v, dst_bgra, &kYuvIConstants, width);
|
| - dst_bgra += dst_stride_bgra;
|
| + I422ToRGBARow(src_y, src_u, src_v, dst_rgba, yuvconstants, width);
|
| + dst_rgba += dst_stride_rgba;
|
| src_y += src_stride_y;
|
| src_u += src_stride_u;
|
| src_v += src_stride_v;
|
| @@ -850,66 +839,27 @@ int I422ToRGBA(const uint8* src_y, int src_stride_y,
|
| const uint8* src_v, int src_stride_v,
|
| uint8* dst_rgba, int dst_stride_rgba,
|
| int width, int height) {
|
| - int y;
|
| - void (*I422ToRGBARow)(const uint8* y_buf,
|
| - const uint8* u_buf,
|
| - const uint8* v_buf,
|
| - uint8* rgb_buf,
|
| - const struct YuvConstants* yuvconstants,
|
| - int width) = I422ToRGBARow_C;
|
| - if (!src_y || !src_u || !src_v ||
|
| - !dst_rgba ||
|
| - width <= 0 || height == 0) {
|
| - return -1;
|
| - }
|
| - // Negative height means invert the image.
|
| - if (height < 0) {
|
| - height = -height;
|
| - dst_rgba = dst_rgba + (height - 1) * dst_stride_rgba;
|
| - dst_stride_rgba = -dst_stride_rgba;
|
| - }
|
| - // Coalesce rows.
|
| - if (src_stride_y == width &&
|
| - src_stride_u * 2 == width &&
|
| - src_stride_v * 2 == width &&
|
| - dst_stride_rgba == width * 4) {
|
| - width *= height;
|
| - height = 1;
|
| - src_stride_y = src_stride_u = src_stride_v = dst_stride_rgba = 0;
|
| - }
|
| -#if defined(HAS_I422TORGBAROW_NEON)
|
| - if (TestCpuFlag(kCpuHasNEON) && width >= 8) {
|
| - I422ToRGBARow = I422ToRGBARow_Any_NEON;
|
| - if (IS_ALIGNED(width, 8)) {
|
| - I422ToRGBARow = I422ToRGBARow_NEON;
|
| - }
|
| - }
|
| -#endif
|
| -#if defined(HAS_I422TORGBAROW_SSSE3)
|
| - if (TestCpuFlag(kCpuHasSSSE3)) {
|
| - I422ToRGBARow = I422ToRGBARow_Any_SSSE3;
|
| - if (IS_ALIGNED(width, 8)) {
|
| - I422ToRGBARow = I422ToRGBARow_SSSE3;
|
| - }
|
| - }
|
| -#endif
|
| -#if defined(HAS_I422TORGBAROW_AVX2)
|
| - if (TestCpuFlag(kCpuHasAVX2)) {
|
| - I422ToRGBARow = I422ToRGBARow_Any_AVX2;
|
| - if (IS_ALIGNED(width, 16)) {
|
| - I422ToRGBARow = I422ToRGBARow_AVX2;
|
| - }
|
| - }
|
| -#endif
|
| + return I422ToRGBAMatrix(src_y, src_stride_y,
|
| + src_u, src_stride_u,
|
| + src_v, src_stride_v,
|
| + dst_rgba, dst_stride_rgba,
|
| + &kYuvIConstants,
|
| + width, height);
|
| +}
|
|
|
| - for (y = 0; y < height; ++y) {
|
| - I422ToRGBARow(src_y, src_u, src_v, dst_rgba, &kYuvIConstants, width);
|
| - dst_rgba += dst_stride_rgba;
|
| - src_y += src_stride_y;
|
| - src_u += src_stride_u;
|
| - src_v += src_stride_v;
|
| - }
|
| - return 0;
|
| +// Convert I422 to BGRA.
|
| +LIBYUV_API
|
| +int I422ToBGRA(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_bgra, int dst_stride_bgra,
|
| + int width, int height) {
|
| + return I422ToRGBAMatrix(src_y, src_stride_y,
|
| + src_v, src_stride_v, // Swap U and V
|
| + src_u, src_stride_u,
|
| + dst_bgra, dst_stride_bgra,
|
| + &kYvuIConstants, // Use Yvu matrix
|
| + width, height);
|
| }
|
|
|
| // Convert NV12 to RGB565.
|
|
|