| /* |
| * Copyright 2011 The LibYuv Project Authors. All rights reserved. |
| * |
| * Use of this source code is governed by a BSD-style license |
| * that can be found in the LICENSE file in the root of the source |
| * tree. An additional intellectual property rights grant can be found |
| * in the file PATENTS. All contributing project authors may |
| * be found in the AUTHORS file in the root of the source tree. |
| */ |
| |
| #include "libyuv/convert_argb.h" |
| |
| #include <assert.h> |
| |
| #include "libyuv/convert_from_argb.h" |
| #include "libyuv/cpu_id.h" |
| #include "libyuv/planar_functions.h" // For CopyPlane and ARGBShuffle. |
| #include "libyuv/rotate_argb.h" |
| #include "libyuv/row.h" |
| #include "libyuv/scale_row.h" // For ScaleRowUp2_Linear and ScaleRowUp2_Bilinear |
| #include "libyuv/video_common.h" |
| |
| #ifdef __cplusplus |
| namespace libyuv { |
| extern "C" { |
| #endif |
| |
| // Copy ARGB with optional flipping |
| LIBYUV_API |
| int ARGBCopy(const uint8_t* src_argb, |
| int src_stride_argb, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| if (!src_argb || !dst_argb || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| src_argb = src_argb + (height - 1) * src_stride_argb; |
| src_stride_argb = -src_stride_argb; |
| } |
| |
| CopyPlane(src_argb, src_stride_argb, dst_argb, dst_stride_argb, width * 4, |
| height); |
| return 0; |
| } |
| |
| // Convert I420 to ARGB with matrix. |
| LIBYUV_API |
| int I420ToARGBMatrix(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I422ToARGBRow)(const uint8_t* y_buf, const uint8_t* u_buf, |
| const uint8_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I422ToARGBRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_argb || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_I422TOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I422ToARGBRow = I422ToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I422ToARGBRow = I422ToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I422ToARGBRow = I422ToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I422ToARGBRow = I422ToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_AVX512BW) |
| if (TestCpuFlag(kCpuHasAVX512BW | kCpuHasAVX512VL) == |
| (kCpuHasAVX512BW | kCpuHasAVX512VL)) { |
| I422ToARGBRow = I422ToARGBRow_Any_AVX512BW; |
| if (IS_ALIGNED(width, 32)) { |
| I422ToARGBRow = I422ToARGBRow_AVX512BW; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I422ToARGBRow = I422ToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I422ToARGBRow = I422ToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_SVE2) |
| if (TestCpuFlag(kCpuHasSVE2)) { |
| I422ToARGBRow = I422ToARGBRow_SVE2; |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| I422ToARGBRow = I422ToARGBRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| I422ToARGBRow = I422ToARGBRow_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_LSX) |
| if (TestCpuFlag(kCpuHasLSX)) { |
| I422ToARGBRow = I422ToARGBRow_Any_LSX; |
| if (IS_ALIGNED(width, 16)) { |
| I422ToARGBRow = I422ToARGBRow_LSX; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_LASX) |
| if (TestCpuFlag(kCpuHasLASX)) { |
| I422ToARGBRow = I422ToARGBRow_Any_LASX; |
| if (IS_ALIGNED(width, 32)) { |
| I422ToARGBRow = I422ToARGBRow_LASX; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| I422ToARGBRow = I422ToARGBRow_RVV; |
| } |
| #endif |
| |
| for (y = 0; y < height; ++y) { |
| I422ToARGBRow(src_y, src_u, src_v, dst_argb, yuvconstants, width); |
| dst_argb += dst_stride_argb; |
| src_y += src_stride_y; |
| if (y & 1) { |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| } |
| return 0; |
| } |
| |
| // Convert I420 to ARGB. |
| LIBYUV_API |
| int I420ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I420ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvI601Constants, width, height); |
| } |
| |
| // Convert I420 to ABGR. |
| LIBYUV_API |
| int I420ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I420ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuI601Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert J420 to ARGB. |
| LIBYUV_API |
| int J420ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I420ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvJPEGConstants, width, height); |
| } |
| |
| // Convert J420 to ABGR. |
| LIBYUV_API |
| int J420ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I420ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuJPEGConstants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert H420 to ARGB. |
| LIBYUV_API |
| int H420ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I420ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvH709Constants, width, height); |
| } |
| |
| // Convert H420 to ABGR. |
| LIBYUV_API |
| int H420ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I420ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuH709Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert U420 to ARGB. |
| LIBYUV_API |
| int U420ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I420ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuv2020Constants, width, height); |
| } |
| |
| // Convert U420 to ABGR. |
| LIBYUV_API |
| int U420ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I420ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvu2020Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert I422 to ARGB with matrix. |
| LIBYUV_API |
| int I422ToARGBMatrix(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I422ToARGBRow)(const uint8_t* y_buf, const uint8_t* u_buf, |
| const uint8_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I422ToARGBRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_argb || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| // Coalesce rows. |
| if (src_stride_y == width && src_stride_u * 2 == width && |
| src_stride_v * 2 == width && dst_stride_argb == width * 4) { |
| width *= height; |
| height = 1; |
| src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0; |
| } |
| #if defined(HAS_I422TOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I422ToARGBRow = I422ToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I422ToARGBRow = I422ToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I422ToARGBRow = I422ToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I422ToARGBRow = I422ToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_AVX512BW) |
| if (TestCpuFlag(kCpuHasAVX512BW | kCpuHasAVX512VL) == |
| (kCpuHasAVX512BW | kCpuHasAVX512VL)) { |
| I422ToARGBRow = I422ToARGBRow_Any_AVX512BW; |
| if (IS_ALIGNED(width, 32)) { |
| I422ToARGBRow = I422ToARGBRow_AVX512BW; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I422ToARGBRow = I422ToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I422ToARGBRow = I422ToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_SVE2) |
| if (TestCpuFlag(kCpuHasSVE2)) { |
| I422ToARGBRow = I422ToARGBRow_SVE2; |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| I422ToARGBRow = I422ToARGBRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| I422ToARGBRow = I422ToARGBRow_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_LSX) |
| if (TestCpuFlag(kCpuHasLSX)) { |
| I422ToARGBRow = I422ToARGBRow_Any_LSX; |
| if (IS_ALIGNED(width, 16)) { |
| I422ToARGBRow = I422ToARGBRow_LSX; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_LASX) |
| if (TestCpuFlag(kCpuHasLASX)) { |
| I422ToARGBRow = I422ToARGBRow_Any_LASX; |
| if (IS_ALIGNED(width, 32)) { |
| I422ToARGBRow = I422ToARGBRow_LASX; |
| } |
| } |
| #endif |
| #if defined(HAS_I422TOARGBROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| I422ToARGBRow = I422ToARGBRow_RVV; |
| } |
| #endif |
| |
| for (y = 0; y < height; ++y) { |
| I422ToARGBRow(src_y, src_u, src_v, dst_argb, yuvconstants, width); |
| dst_argb += dst_stride_argb; |
| src_y += src_stride_y; |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| return 0; |
| } |
| |
| // Convert I422 to ARGB. |
| LIBYUV_API |
| int I422ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I422ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvI601Constants, width, height); |
| } |
| |
| // Convert I422 to ABGR. |
| LIBYUV_API |
| int I422ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I422ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuI601Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert J422 to ARGB. |
| LIBYUV_API |
| int J422ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I422ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvJPEGConstants, width, height); |
| } |
| |
| // Convert J422 to ABGR. |
| LIBYUV_API |
| int J422ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I422ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuJPEGConstants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert H422 to ARGB. |
| LIBYUV_API |
| int H422ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I422ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvH709Constants, width, height); |
| } |
| |
| // Convert H422 to ABGR. |
| LIBYUV_API |
| int H422ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I422ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuH709Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert U422 to ARGB. |
| LIBYUV_API |
| int U422ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I422ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuv2020Constants, width, height); |
| } |
| |
| // Convert U422 to ABGR. |
| LIBYUV_API |
| int U422ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I422ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvu2020Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert I444 to ARGB with matrix. |
| LIBYUV_API |
| int I444ToARGBMatrix(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I444ToARGBRow)(const uint8_t* y_buf, const uint8_t* u_buf, |
| const uint8_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I444ToARGBRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_argb || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| // Coalesce rows. |
| if (src_stride_y == width && src_stride_u == width && src_stride_v == width && |
| dst_stride_argb == width * 4) { |
| width *= height; |
| height = 1; |
| src_stride_y = src_stride_u = src_stride_v = dst_stride_argb = 0; |
| } |
| #if defined(HAS_I444TOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I444ToARGBRow = I444ToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I444ToARGBRow = I444ToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I444TOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I444ToARGBRow = I444ToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I444ToARGBRow = I444ToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_I444TOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I444ToARGBRow = I444ToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I444ToARGBRow = I444ToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I444TOARGBROW_SVE2) |
| if (TestCpuFlag(kCpuHasSVE2)) { |
| I444ToARGBRow = I444ToARGBRow_SVE2; |
| } |
| #endif |
| #if defined(HAS_I444TOARGBROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| I444ToARGBRow = I444ToARGBRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| I444ToARGBRow = I444ToARGBRow_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_I444TOARGBROW_LSX) |
| if (TestCpuFlag(kCpuHasLSX)) { |
| I444ToARGBRow = I444ToARGBRow_Any_LSX; |
| if (IS_ALIGNED(width, 16)) { |
| I444ToARGBRow = I444ToARGBRow_LSX; |
| } |
| } |
| #endif |
| #if defined(HAS_I444TOARGBROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| I444ToARGBRow = I444ToARGBRow_RVV; |
| } |
| #endif |
| |
| for (y = 0; y < height; ++y) { |
| I444ToARGBRow(src_y, src_u, src_v, dst_argb, yuvconstants, width); |
| dst_argb += dst_stride_argb; |
| src_y += src_stride_y; |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| return 0; |
| } |
| |
| // Convert I444 to ARGB. |
| LIBYUV_API |
| int I444ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I444ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvI601Constants, width, height); |
| } |
| |
| // Convert I444 to ABGR. |
| LIBYUV_API |
| int I444ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I444ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuI601Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert J444 to ARGB. |
| LIBYUV_API |
| int J444ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I444ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvJPEGConstants, width, height); |
| } |
| |
| // Convert J444 to ABGR. |
| LIBYUV_API |
| int J444ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I444ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuJPEGConstants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert H444 to ARGB. |
| LIBYUV_API |
| int H444ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I444ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvH709Constants, width, height); |
| } |
| |
| // Convert H444 to ABGR. |
| LIBYUV_API |
| int H444ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I444ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuH709Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert U444 to ARGB. |
| LIBYUV_API |
| int U444ToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I444ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuv2020Constants, width, height); |
| } |
| |
| // Convert U444 to ABGR. |
| LIBYUV_API |
| int U444ToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I444ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvu2020Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert I444 to RGB24 with matrix. |
| LIBYUV_API |
| int I444ToRGB24Matrix(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_rgb24, |
| int dst_stride_rgb24, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I444ToRGB24Row)(const uint8_t* y_buf, const uint8_t* u_buf, |
| const uint8_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I444ToRGB24Row_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_rgb24 || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_rgb24 = dst_rgb24 + (height - 1) * dst_stride_rgb24; |
| dst_stride_rgb24 = -dst_stride_rgb24; |
| } |
| // Coalesce rows. |
| if (src_stride_y == width && src_stride_u == width && src_stride_v == width && |
| dst_stride_rgb24 == width * 3) { |
| width *= height; |
| height = 1; |
| src_stride_y = src_stride_u = src_stride_v = dst_stride_rgb24 = 0; |
| } |
| #if defined(HAS_I444TORGB24ROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I444ToRGB24Row = I444ToRGB24Row_Any_SSSE3; |
| if (IS_ALIGNED(width, 16)) { |
| I444ToRGB24Row = I444ToRGB24Row_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I444TORGB24ROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I444ToRGB24Row = I444ToRGB24Row_Any_AVX2; |
| if (IS_ALIGNED(width, 32)) { |
| I444ToRGB24Row = I444ToRGB24Row_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_I444TORGB24ROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I444ToRGB24Row = I444ToRGB24Row_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I444ToRGB24Row = I444ToRGB24Row_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I444TORGB24ROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| I444ToRGB24Row = I444ToRGB24Row_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| I444ToRGB24Row = I444ToRGB24Row_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_I444TORGB24ROW_LSX) |
| if (TestCpuFlag(kCpuHasLSX)) { |
| I444ToRGB24Row = I444ToRGB24Row_Any_LSX; |
| if (IS_ALIGNED(width, 16)) { |
| I444ToRGB24Row = I444ToRGB24Row_LSX; |
| } |
| } |
| #endif |
| #if defined(HAS_I444TORGB24ROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| I444ToRGB24Row = I444ToRGB24Row_RVV; |
| } |
| #endif |
| |
| for (y = 0; y < height; ++y) { |
| I444ToRGB24Row(src_y, src_u, src_v, dst_rgb24, yuvconstants, width); |
| dst_rgb24 += dst_stride_rgb24; |
| src_y += src_stride_y; |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| return 0; |
| } |
| |
| // Convert I444 to RGB24. |
| LIBYUV_API |
| int I444ToRGB24(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_rgb24, |
| int dst_stride_rgb24, |
| int width, |
| int height) { |
| return I444ToRGB24Matrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_rgb24, dst_stride_rgb24, |
| &kYuvI601Constants, width, height); |
| } |
| |
| // Convert I444 to RAW. |
| LIBYUV_API |
| int I444ToRAW(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_raw, |
| int dst_stride_raw, |
| int width, |
| int height) { |
| return I444ToRGB24Matrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_raw, dst_stride_raw, |
| &kYvuI601Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert 10 bit YUV to ARGB with matrix. |
| // TODO(fbarchard): Consider passing scale multiplier to I210ToARGB to |
| // multiply 10 bit yuv into high bits to allow any number of bits. |
| LIBYUV_API |
| int I010ToAR30Matrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I210ToAR30Row)(const uint16_t* y_buf, const uint16_t* u_buf, |
| const uint16_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I210ToAR30Row_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_ar30 || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_ar30 = dst_ar30 + (height - 1) * dst_stride_ar30; |
| dst_stride_ar30 = -dst_stride_ar30; |
| } |
| #if defined(HAS_I210TOAR30ROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I210ToAR30Row = I210ToAR30Row_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I210ToAR30Row = I210ToAR30Row_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I210TOAR30ROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I210ToAR30Row = I210ToAR30Row_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I210ToAR30Row = I210ToAR30Row_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I210TOAR30ROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I210ToAR30Row = I210ToAR30Row_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I210ToAR30Row = I210ToAR30Row_AVX2; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| I210ToAR30Row(src_y, src_u, src_v, dst_ar30, yuvconstants, width); |
| dst_ar30 += dst_stride_ar30; |
| src_y += src_stride_y; |
| if (y & 1) { |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| } |
| return 0; |
| } |
| |
| // Convert I010 to AR30. |
| LIBYUV_API |
| int I010ToAR30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| int width, |
| int height) { |
| return I010ToAR30Matrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_ar30, dst_stride_ar30, |
| &kYuvI601Constants, width, height); |
| } |
| |
| // Convert H010 to AR30. |
| LIBYUV_API |
| int H010ToAR30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| int width, |
| int height) { |
| return I010ToAR30Matrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_ar30, dst_stride_ar30, |
| &kYuvH709Constants, width, height); |
| } |
| |
| // Convert U010 to AR30. |
| LIBYUV_API |
| int U010ToAR30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| int width, |
| int height) { |
| return I010ToAR30Matrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_ar30, dst_stride_ar30, |
| &kYuv2020Constants, width, height); |
| } |
| |
| // Convert I010 to AB30. |
| LIBYUV_API |
| int I010ToAB30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ab30, |
| int dst_stride_ab30, |
| int width, |
| int height) { |
| return I010ToAR30Matrix(src_y, src_stride_y, src_v, src_stride_v, src_u, |
| src_stride_u, dst_ab30, dst_stride_ab30, |
| &kYvuI601Constants, width, height); |
| } |
| |
| // Convert H010 to AB30. |
| LIBYUV_API |
| int H010ToAB30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ab30, |
| int dst_stride_ab30, |
| int width, |
| int height) { |
| return I010ToAR30Matrix(src_y, src_stride_y, src_v, src_stride_v, src_u, |
| src_stride_u, dst_ab30, dst_stride_ab30, |
| &kYvuH709Constants, width, height); |
| } |
| |
| // Convert U010 to AB30. |
| LIBYUV_API |
| int U010ToAB30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ab30, |
| int dst_stride_ab30, |
| int width, |
| int height) { |
| return I010ToAR30Matrix(src_y, src_stride_y, src_v, src_stride_v, src_u, |
| src_stride_u, dst_ab30, dst_stride_ab30, |
| &kYuv2020Constants, width, height); |
| } |
| |
| // Convert 12 bit YUV to ARGB with matrix. |
| // TODO(fbarchard): Consider passing scale multiplier to I212ToARGB to |
| // multiply 12 bit yuv into high bits to allow any number of bits. |
| LIBYUV_API |
| int I012ToAR30Matrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I212ToAR30Row)(const uint16_t* y_buf, const uint16_t* u_buf, |
| const uint16_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I212ToAR30Row_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_ar30 || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_ar30 = dst_ar30 + (height - 1) * dst_stride_ar30; |
| dst_stride_ar30 = -dst_stride_ar30; |
| } |
| #if defined(HAS_I212TOAR30ROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I212ToAR30Row = I212ToAR30Row_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I212ToAR30Row = I212ToAR30Row_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I212TOAR30ROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I212ToAR30Row = I212ToAR30Row_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I212ToAR30Row = I212ToAR30Row_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_I212TOAR30ROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I212ToAR30Row = I212ToAR30Row_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I212ToAR30Row = I212ToAR30Row_NEON; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| I212ToAR30Row(src_y, src_u, src_v, dst_ar30, yuvconstants, width); |
| dst_ar30 += dst_stride_ar30; |
| src_y += src_stride_y; |
| if (y & 1) { |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| } |
| return 0; |
| } |
| |
| // Convert 10 bit YUV to ARGB with matrix. |
| // TODO(fbarchard): Consider passing scale multiplier to I210ToARGB to |
| // multiply 10 bit yuv into high bits to allow any number of bits. |
| LIBYUV_API |
| int I210ToAR30Matrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I210ToAR30Row)(const uint16_t* y_buf, const uint16_t* u_buf, |
| const uint16_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I210ToAR30Row_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_ar30 || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_ar30 = dst_ar30 + (height - 1) * dst_stride_ar30; |
| dst_stride_ar30 = -dst_stride_ar30; |
| } |
| #if defined(HAS_I210TOAR30ROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I210ToAR30Row = I210ToAR30Row_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I210ToAR30Row = I210ToAR30Row_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I210TOAR30ROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I210ToAR30Row = I210ToAR30Row_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I210ToAR30Row = I210ToAR30Row_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I210TOAR30ROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I210ToAR30Row = I210ToAR30Row_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I210ToAR30Row = I210ToAR30Row_AVX2; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| I210ToAR30Row(src_y, src_u, src_v, dst_ar30, yuvconstants, width); |
| dst_ar30 += dst_stride_ar30; |
| src_y += src_stride_y; |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| return 0; |
| } |
| |
| // Convert I210 to AR30. |
| LIBYUV_API |
| int I210ToAR30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| int width, |
| int height) { |
| return I210ToAR30Matrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_ar30, dst_stride_ar30, |
| &kYuvI601Constants, width, height); |
| } |
| |
| // Convert H210 to AR30. |
| LIBYUV_API |
| int H210ToAR30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| int width, |
| int height) { |
| return I210ToAR30Matrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_ar30, dst_stride_ar30, |
| &kYuvH709Constants, width, height); |
| } |
| |
| // Convert U210 to AR30. |
| LIBYUV_API |
| int U210ToAR30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| int width, |
| int height) { |
| return I210ToAR30Matrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_ar30, dst_stride_ar30, |
| &kYuv2020Constants, width, height); |
| } |
| |
| // Convert I210 to AB30. |
| LIBYUV_API |
| int I210ToAB30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ab30, |
| int dst_stride_ab30, |
| int width, |
| int height) { |
| return I210ToAR30Matrix(src_y, src_stride_y, src_v, src_stride_v, src_u, |
| src_stride_u, dst_ab30, dst_stride_ab30, |
| &kYvuI601Constants, width, height); |
| } |
| |
| // Convert H210 to AB30. |
| LIBYUV_API |
| int H210ToAB30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ab30, |
| int dst_stride_ab30, |
| int width, |
| int height) { |
| return I210ToAR30Matrix(src_y, src_stride_y, src_v, src_stride_v, src_u, |
| src_stride_u, dst_ab30, dst_stride_ab30, |
| &kYvuH709Constants, width, height); |
| } |
| |
| // Convert U210 to AB30. |
| LIBYUV_API |
| int U210ToAB30(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ab30, |
| int dst_stride_ab30, |
| int width, |
| int height) { |
| return I210ToAR30Matrix(src_y, src_stride_y, src_v, src_stride_v, src_u, |
| src_stride_u, dst_ab30, dst_stride_ab30, |
| &kYuv2020Constants, width, height); |
| } |
| |
| LIBYUV_API |
| int I410ToAR30Matrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I410ToAR30Row)(const uint16_t* y_buf, const uint16_t* u_buf, |
| const uint16_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I410ToAR30Row_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_ar30 || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_ar30 = dst_ar30 + (height - 1) * dst_stride_ar30; |
| dst_stride_ar30 = -dst_stride_ar30; |
| } |
| #if defined(HAS_I410TOAR30ROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I410ToAR30Row = I410ToAR30Row_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I410ToAR30Row = I410ToAR30Row_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I410TOAR30ROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I410ToAR30Row = I410ToAR30Row_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I410ToAR30Row = I410ToAR30Row_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I410TOAR30ROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I410ToAR30Row = I410ToAR30Row_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I410ToAR30Row = I410ToAR30Row_AVX2; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| I410ToAR30Row(src_y, src_u, src_v, dst_ar30, yuvconstants, width); |
| dst_ar30 += dst_stride_ar30; |
| src_y += src_stride_y; |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| return 0; |
| } |
| |
| // Convert 10 bit YUV to ARGB with matrix. |
| LIBYUV_API |
| int I010ToARGBMatrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I210ToARGBRow)(const uint16_t* y_buf, const uint16_t* u_buf, |
| const uint16_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I210ToARGBRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_argb || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_I210TOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I210ToARGBRow = I210ToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I210ToARGBRow = I210ToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I210TOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I210ToARGBRow = I210ToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I210ToARGBRow = I210ToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I210TOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I210ToARGBRow = I210ToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I210ToARGBRow = I210ToARGBRow_AVX2; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| I210ToARGBRow(src_y, src_u, src_v, dst_argb, yuvconstants, width); |
| dst_argb += dst_stride_argb; |
| src_y += src_stride_y; |
| if (y & 1) { |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| } |
| return 0; |
| } |
| |
| // Convert I010 to ARGB. |
| LIBYUV_API |
| int I010ToARGB(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I010ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvI601Constants, width, height); |
| } |
| |
| // Convert I010 to ABGR. |
| LIBYUV_API |
| int I010ToABGR(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I010ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuI601Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert H010 to ARGB. |
| LIBYUV_API |
| int H010ToARGB(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I010ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvH709Constants, width, height); |
| } |
| |
| // Convert H010 to ABGR. |
| LIBYUV_API |
| int H010ToABGR(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I010ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuH709Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert U010 to ARGB. |
| LIBYUV_API |
| int U010ToARGB(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I010ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuv2020Constants, width, height); |
| } |
| |
| // Convert U010 to ABGR. |
| LIBYUV_API |
| int U010ToABGR(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I010ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvu2020Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert 12 bit YUV to ARGB with matrix. |
| LIBYUV_API |
| int I012ToARGBMatrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I212ToARGBRow)(const uint16_t* y_buf, const uint16_t* u_buf, |
| const uint16_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I212ToARGBRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_argb || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_I212TOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I212ToARGBRow = I212ToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I212ToARGBRow = I212ToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I212TOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I212ToARGBRow = I212ToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I212ToARGBRow = I212ToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_I212TOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I212ToARGBRow = I212ToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I212ToARGBRow = I212ToARGBRow_NEON; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| I212ToARGBRow(src_y, src_u, src_v, dst_argb, yuvconstants, width); |
| dst_argb += dst_stride_argb; |
| src_y += src_stride_y; |
| if (y & 1) { |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| } |
| return 0; |
| } |
| |
| // Convert 10 bit 422 YUV to ARGB with matrix. |
| LIBYUV_API |
| int I210ToARGBMatrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I210ToARGBRow)(const uint16_t* y_buf, const uint16_t* u_buf, |
| const uint16_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I210ToARGBRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_argb || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_I210TOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I210ToARGBRow = I210ToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I210ToARGBRow = I210ToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I210TOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I210ToARGBRow = I210ToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I210ToARGBRow = I210ToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I210TOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I210ToARGBRow = I210ToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I210ToARGBRow = I210ToARGBRow_AVX2; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| I210ToARGBRow(src_y, src_u, src_v, dst_argb, yuvconstants, width); |
| dst_argb += dst_stride_argb; |
| src_y += src_stride_y; |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| return 0; |
| } |
| |
| // Convert I210 to ARGB. |
| LIBYUV_API |
| int I210ToARGB(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I210ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvI601Constants, width, height); |
| } |
| |
| // Convert I210 to ABGR. |
| LIBYUV_API |
| int I210ToABGR(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I210ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuI601Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert H210 to ARGB. |
| LIBYUV_API |
| int H210ToARGB(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I210ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuvH709Constants, width, height); |
| } |
| |
| // Convert H210 to ABGR. |
| LIBYUV_API |
| int H210ToABGR(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I210ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvuH709Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| // Convert U210 to ARGB. |
| LIBYUV_API |
| int U210ToARGB(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height) { |
| return I210ToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, dst_argb, dst_stride_argb, |
| &kYuv2020Constants, width, height); |
| } |
| |
| // Convert U210 to ABGR. |
| LIBYUV_API |
| int U210ToABGR(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height) { |
| return I210ToARGBMatrix(src_y, src_stride_y, src_v, |
| src_stride_v, // Swap U and V |
| src_u, src_stride_u, dst_abgr, dst_stride_abgr, |
| &kYvu2020Constants, // Use Yvu matrix |
| width, height); |
| } |
| |
| LIBYUV_API |
| int I410ToARGBMatrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*I410ToARGBRow)(const uint16_t* y_buf, const uint16_t* u_buf, |
| const uint16_t* v_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = |
| I410ToARGBRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !dst_argb || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_I410TOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I410ToARGBRow = I410ToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I410ToARGBRow = I410ToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I410TOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I410ToARGBRow = I410ToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I410ToARGBRow = I410ToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I410TOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I410ToARGBRow = I410ToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I410ToARGBRow = I410ToARGBRow_AVX2; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| I410ToARGBRow(src_y, src_u, src_v, dst_argb, yuvconstants, width); |
| dst_argb += dst_stride_argb; |
| src_y += src_stride_y; |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| return 0; |
| } |
| |
| LIBYUV_API |
| int P010ToARGBMatrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_uv, |
| int src_stride_uv, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*P210ToARGBRow)( |
| const uint16_t* y_buf, const uint16_t* uv_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = P210ToARGBRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_uv || !dst_argb || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_P210TOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| P210ToARGBRow = P210ToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| P210ToARGBRow = P210ToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_P210TOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| P210ToARGBRow = P210ToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| P210ToARGBRow = P210ToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_P210TOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| P210ToARGBRow = P210ToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| P210ToARGBRow = P210ToARGBRow_NEON; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| P210ToARGBRow(src_y, src_uv, dst_argb, yuvconstants, width); |
| dst_argb += dst_stride_argb; |
| src_y += src_stride_y; |
| if (y & 1) { |
| src_uv += src_stride_uv; |
| } |
| } |
| return 0; |
| } |
| |
| LIBYUV_API |
| int P210ToARGBMatrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_uv, |
| int src_stride_uv, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*P210ToARGBRow)( |
| const uint16_t* y_buf, const uint16_t* uv_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = P210ToARGBRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_uv || !dst_argb || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_P210TOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| P210ToARGBRow = P210ToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| P210ToARGBRow = P210ToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_P210TOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| P210ToARGBRow = P210ToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| P210ToARGBRow = P210ToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_P210TOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| P210ToARGBRow = P210ToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| P210ToARGBRow = P210ToARGBRow_NEON; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| P210ToARGBRow(src_y, src_uv, dst_argb, yuvconstants, width); |
| dst_argb += dst_stride_argb; |
| src_y += src_stride_y; |
| src_uv += src_stride_uv; |
| } |
| return 0; |
| } |
| |
| LIBYUV_API |
| int P010ToAR30Matrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_uv, |
| int src_stride_uv, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*P210ToAR30Row)( |
| const uint16_t* y_buf, const uint16_t* uv_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = P210ToAR30Row_C; |
| assert(yuvconstants); |
| if (!src_y || !src_uv || !dst_ar30 || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_ar30 = dst_ar30 + (height - 1) * dst_stride_ar30; |
| dst_stride_ar30 = -dst_stride_ar30; |
| } |
| #if defined(HAS_P210TOAR30ROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| P210ToAR30Row = P210ToAR30Row_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| P210ToAR30Row = P210ToAR30Row_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_P210TOAR30ROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| P210ToAR30Row = P210ToAR30Row_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| P210ToAR30Row = P210ToAR30Row_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_P210TOAR30ROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| P210ToAR30Row = P210ToAR30Row_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| P210ToAR30Row = P210ToAR30Row_NEON; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| P210ToAR30Row(src_y, src_uv, dst_ar30, yuvconstants, width); |
| dst_ar30 += dst_stride_ar30; |
| src_y += src_stride_y; |
| if (y & 1) { |
| src_uv += src_stride_uv; |
| } |
| } |
| return 0; |
| } |
| |
| LIBYUV_API |
| int P210ToAR30Matrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_uv, |
| int src_stride_uv, |
| uint8_t* dst_ar30, |
| int dst_stride_ar30, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height) { |
| int y; |
| void (*P210ToAR30Row)( |
| const uint16_t* y_buf, const uint16_t* uv_buf, uint8_t* rgb_buf, |
| const struct YuvConstants* yuvconstants, int width) = P210ToAR30Row_C; |
| assert(yuvconstants); |
| if (!src_y || !src_uv || !dst_ar30 || width <= 0 || height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_ar30 = dst_ar30 + (height - 1) * dst_stride_ar30; |
| dst_stride_ar30 = -dst_stride_ar30; |
| } |
| #if defined(HAS_P210TOAR30ROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| P210ToAR30Row = P210ToAR30Row_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| P210ToAR30Row = P210ToAR30Row_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_P210TOAR30ROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| P210ToAR30Row = P210ToAR30Row_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| P210ToAR30Row = P210ToAR30Row_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_P210TOAR30ROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| P210ToAR30Row = P210ToAR30Row_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| P210ToAR30Row = P210ToAR30Row_NEON; |
| } |
| } |
| #endif |
| for (y = 0; y < height; ++y) { |
| P210ToAR30Row(src_y, src_uv, dst_ar30, yuvconstants, width); |
| dst_ar30 += dst_stride_ar30; |
| src_y += src_stride_y; |
| src_uv += src_stride_uv; |
| } |
| return 0; |
| } |
| |
| // Convert I420 with Alpha to preattenuated ARGB with matrix. |
| LIBYUV_API |
| int I420AlphaToARGBMatrix(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| const uint8_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height, |
| int attenuate) { |
| int y; |
| void (*I422AlphaToARGBRow)(const uint8_t* y_buf, const uint8_t* u_buf, |
| const uint8_t* v_buf, const uint8_t* a_buf, |
| uint8_t* dst_argb, |
| const struct YuvConstants* yuvconstants, |
| int width) = I422AlphaToARGBRow_C; |
| void (*ARGBAttenuateRow)(const uint8_t* src_argb, uint8_t* dst_argb, |
| int width) = ARGBAttenuateRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !src_a || !dst_argb || width <= 0 || |
| height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_I422ALPHATOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_SVE2) |
| if (TestCpuFlag(kCpuHasSVE2)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_SVE2; |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_LSX) |
| if (TestCpuFlag(kCpuHasLSX)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_LSX; |
| if (IS_ALIGNED(width, 16)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_LSX; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_LASX) |
| if (TestCpuFlag(kCpuHasLASX)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_LASX; |
| if (IS_ALIGNED(width, 16)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_LASX; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_RVV; |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 4)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_AVX2; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_RVV; |
| } |
| #endif |
| |
| for (y = 0; y < height; ++y) { |
| I422AlphaToARGBRow(src_y, src_u, src_v, src_a, dst_argb, yuvconstants, |
| width); |
| if (attenuate) { |
| ARGBAttenuateRow(dst_argb, dst_argb, width); |
| } |
| dst_argb += dst_stride_argb; |
| src_a += src_stride_a; |
| src_y += src_stride_y; |
| if (y & 1) { |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| } |
| return 0; |
| } |
| |
| // Convert I422 with Alpha to preattenuated ARGB with matrix. |
| LIBYUV_API |
| int I422AlphaToARGBMatrix(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| const uint8_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height, |
| int attenuate) { |
| int y; |
| void (*I422AlphaToARGBRow)(const uint8_t* y_buf, const uint8_t* u_buf, |
| const uint8_t* v_buf, const uint8_t* a_buf, |
| uint8_t* dst_argb, |
| const struct YuvConstants* yuvconstants, |
| int width) = I422AlphaToARGBRow_C; |
| void (*ARGBAttenuateRow)(const uint8_t* src_argb, uint8_t* dst_argb, |
| int width) = ARGBAttenuateRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !src_a || !dst_argb || width <= 0 || |
| height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_I422ALPHATOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_SVE2) |
| if (TestCpuFlag(kCpuHasSVE2)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_SVE2; |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_LSX) |
| if (TestCpuFlag(kCpuHasLSX)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_LSX; |
| if (IS_ALIGNED(width, 16)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_LSX; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_LASX) |
| if (TestCpuFlag(kCpuHasLASX)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_Any_LASX; |
| if (IS_ALIGNED(width, 16)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_LASX; |
| } |
| } |
| #endif |
| #if defined(HAS_I422ALPHATOARGBROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| I422AlphaToARGBRow = I422AlphaToARGBRow_RVV; |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 4)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_AVX2; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_RVV; |
| } |
| #endif |
| |
| for (y = 0; y < height; ++y) { |
| I422AlphaToARGBRow(src_y, src_u, src_v, src_a, dst_argb, yuvconstants, |
| width); |
| if (attenuate) { |
| ARGBAttenuateRow(dst_argb, dst_argb, width); |
| } |
| dst_argb += dst_stride_argb; |
| src_a += src_stride_a; |
| src_y += src_stride_y; |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| return 0; |
| } |
| |
| // Convert I444 with Alpha to preattenuated ARGB with matrix. |
| LIBYUV_API |
| int I444AlphaToARGBMatrix(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| const uint8_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height, |
| int attenuate) { |
| int y; |
| void (*I444AlphaToARGBRow)(const uint8_t* y_buf, const uint8_t* u_buf, |
| const uint8_t* v_buf, const uint8_t* a_buf, |
| uint8_t* dst_argb, |
| const struct YuvConstants* yuvconstants, |
| int width) = I444AlphaToARGBRow_C; |
| void (*ARGBAttenuateRow)(const uint8_t* src_argb, uint8_t* dst_argb, |
| int width) = ARGBAttenuateRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !src_a || !dst_argb || width <= 0 || |
| height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_I444ALPHATOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I444AlphaToARGBRow = I444AlphaToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I444AlphaToARGBRow = I444AlphaToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I444ALPHATOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I444AlphaToARGBRow = I444AlphaToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I444AlphaToARGBRow = I444AlphaToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_I444ALPHATOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I444AlphaToARGBRow = I444AlphaToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I444AlphaToARGBRow = I444AlphaToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I444ALPHATOARGBROW_SVE2) |
| if (TestCpuFlag(kCpuHasSVE2)) { |
| I444AlphaToARGBRow = I444AlphaToARGBRow_SVE2; |
| } |
| #endif |
| #if defined(HAS_I444ALPHATOARGBROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| I444AlphaToARGBRow = I444AlphaToARGBRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| I444AlphaToARGBRow = I444AlphaToARGBRow_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_I444ALPHATOARGBROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| I444AlphaToARGBRow = I444AlphaToARGBRow_RVV; |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 4)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_AVX2; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_RVV; |
| } |
| #endif |
| |
| for (y = 0; y < height; ++y) { |
| I444AlphaToARGBRow(src_y, src_u, src_v, src_a, dst_argb, yuvconstants, |
| width); |
| if (attenuate) { |
| ARGBAttenuateRow(dst_argb, dst_argb, width); |
| } |
| dst_argb += dst_stride_argb; |
| src_a += src_stride_a; |
| src_y += src_stride_y; |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| return 0; |
| } |
| |
| // Convert I420 with Alpha to ARGB. |
| LIBYUV_API |
| int I420AlphaToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| const uint8_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height, |
| int attenuate) { |
| return I420AlphaToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, src_a, src_stride_a, dst_argb, |
| dst_stride_argb, &kYuvI601Constants, width, |
| height, attenuate); |
| } |
| |
| // Convert I420 with Alpha to ABGR. |
| LIBYUV_API |
| int I420AlphaToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| const uint8_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height, |
| int attenuate) { |
| return I420AlphaToARGBMatrix( |
| src_y, src_stride_y, src_v, src_stride_v, // Swap U and V |
| src_u, src_stride_u, src_a, src_stride_a, dst_abgr, dst_stride_abgr, |
| &kYvuI601Constants, // Use Yvu matrix |
| width, height, attenuate); |
| } |
| |
| // Convert I422 with Alpha to ARGB. |
| LIBYUV_API |
| int I422AlphaToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| const uint8_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height, |
| int attenuate) { |
| return I422AlphaToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, src_a, src_stride_a, dst_argb, |
| dst_stride_argb, &kYuvI601Constants, width, |
| height, attenuate); |
| } |
| |
| // Convert I422 with Alpha to ABGR. |
| LIBYUV_API |
| int I422AlphaToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| const uint8_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height, |
| int attenuate) { |
| return I422AlphaToARGBMatrix( |
| src_y, src_stride_y, src_v, src_stride_v, // Swap U and V |
| src_u, src_stride_u, src_a, src_stride_a, dst_abgr, dst_stride_abgr, |
| &kYvuI601Constants, // Use Yvu matrix |
| width, height, attenuate); |
| } |
| |
| // Convert I444 with Alpha to ARGB. |
| LIBYUV_API |
| int I444AlphaToARGB(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| const uint8_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| int width, |
| int height, |
| int attenuate) { |
| return I444AlphaToARGBMatrix(src_y, src_stride_y, src_u, src_stride_u, src_v, |
| src_stride_v, src_a, src_stride_a, dst_argb, |
| dst_stride_argb, &kYuvI601Constants, width, |
| height, attenuate); |
| } |
| |
| // Convert I444 with Alpha to ABGR. |
| LIBYUV_API |
| int I444AlphaToABGR(const uint8_t* src_y, |
| int src_stride_y, |
| const uint8_t* src_u, |
| int src_stride_u, |
| const uint8_t* src_v, |
| int src_stride_v, |
| const uint8_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_abgr, |
| int dst_stride_abgr, |
| int width, |
| int height, |
| int attenuate) { |
| return I444AlphaToARGBMatrix( |
| src_y, src_stride_y, src_v, src_stride_v, // Swap U and V |
| src_u, src_stride_u, src_a, src_stride_a, dst_abgr, dst_stride_abgr, |
| &kYvuI601Constants, // Use Yvu matrix |
| width, height, attenuate); |
| } |
| |
| // Convert I010 with Alpha to preattenuated ARGB with matrix. |
| LIBYUV_API |
| int I010AlphaToARGBMatrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| const uint16_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height, |
| int attenuate) { |
| int y; |
| void (*I210AlphaToARGBRow)(const uint16_t* y_buf, const uint16_t* u_buf, |
| const uint16_t* v_buf, const uint16_t* a_buf, |
| uint8_t* dst_argb, |
| const struct YuvConstants* yuvconstants, |
| int width) = I210AlphaToARGBRow_C; |
| void (*ARGBAttenuateRow)(const uint8_t* src_argb, uint8_t* dst_argb, |
| int width) = ARGBAttenuateRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !src_a || !dst_argb || width <= 0 || |
| height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_I210ALPHATOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I210ALPHATOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I210ALPHATOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 4)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_AVX2; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_RVV; |
| } |
| #endif |
| |
| for (y = 0; y < height; ++y) { |
| I210AlphaToARGBRow(src_y, src_u, src_v, src_a, dst_argb, yuvconstants, |
| width); |
| if (attenuate) { |
| ARGBAttenuateRow(dst_argb, dst_argb, width); |
| } |
| dst_argb += dst_stride_argb; |
| src_a += src_stride_a; |
| src_y += src_stride_y; |
| if (y & 1) { |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| } |
| return 0; |
| } |
| |
| // Convert I210 with Alpha to preattenuated ARGB with matrix. |
| LIBYUV_API |
| int I210AlphaToARGBMatrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| const uint16_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height, |
| int attenuate) { |
| int y; |
| void (*I210AlphaToARGBRow)(const uint16_t* y_buf, const uint16_t* u_buf, |
| const uint16_t* v_buf, const uint16_t* a_buf, |
| uint8_t* dst_argb, |
| const struct YuvConstants* yuvconstants, |
| int width) = I210AlphaToARGBRow_C; |
| void (*ARGBAttenuateRow)(const uint8_t* src_argb, uint8_t* dst_argb, |
| int width) = ARGBAttenuateRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !src_a || !dst_argb || width <= 0 || |
| height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_I210ALPHATOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I210ALPHATOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I210ALPHATOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I210AlphaToARGBRow = I210AlphaToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 4)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_AVX2; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_MSA; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_RVV) |
| if (TestCpuFlag(kCpuHasRVV)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_RVV; |
| } |
| #endif |
| |
| for (y = 0; y < height; ++y) { |
| I210AlphaToARGBRow(src_y, src_u, src_v, src_a, dst_argb, yuvconstants, |
| width); |
| if (attenuate) { |
| ARGBAttenuateRow(dst_argb, dst_argb, width); |
| } |
| dst_argb += dst_stride_argb; |
| src_a += src_stride_a; |
| src_y += src_stride_y; |
| src_u += src_stride_u; |
| src_v += src_stride_v; |
| } |
| return 0; |
| } |
| |
| // Convert I410 with Alpha to preattenuated ARGB with matrix. |
| LIBYUV_API |
| int I410AlphaToARGBMatrix(const uint16_t* src_y, |
| int src_stride_y, |
| const uint16_t* src_u, |
| int src_stride_u, |
| const uint16_t* src_v, |
| int src_stride_v, |
| const uint16_t* src_a, |
| int src_stride_a, |
| uint8_t* dst_argb, |
| int dst_stride_argb, |
| const struct YuvConstants* yuvconstants, |
| int width, |
| int height, |
| int attenuate) { |
| int y; |
| void (*I410AlphaToARGBRow)(const uint16_t* y_buf, const uint16_t* u_buf, |
| const uint16_t* v_buf, const uint16_t* a_buf, |
| uint8_t* dst_argb, |
| const struct YuvConstants* yuvconstants, |
| int width) = I410AlphaToARGBRow_C; |
| void (*ARGBAttenuateRow)(const uint8_t* src_argb, uint8_t* dst_argb, |
| int width) = ARGBAttenuateRow_C; |
| assert(yuvconstants); |
| if (!src_y || !src_u || !src_v || !src_a || !dst_argb || width <= 0 || |
| height == 0) { |
| return -1; |
| } |
| // Negative height means invert the image. |
| if (height < 0) { |
| height = -height; |
| dst_argb = dst_argb + (height - 1) * dst_stride_argb; |
| dst_stride_argb = -dst_stride_argb; |
| } |
| #if defined(HAS_I410ALPHATOARGBROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| I410AlphaToARGBRow = I410AlphaToARGBRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| I410AlphaToARGBRow = I410AlphaToARGBRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_I410ALPHATOARGBROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| I410AlphaToARGBRow = I410AlphaToARGBRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 8)) { |
| I410AlphaToARGBRow = I410AlphaToARGBRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_I410ALPHATOARGBROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| I410AlphaToARGBRow = I410AlphaToARGBRow_Any_AVX2; |
| if (IS_ALIGNED(width, 16)) { |
| I410AlphaToARGBRow = I410AlphaToARGBRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_SSSE3) |
| if (TestCpuFlag(kCpuHasSSSE3)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_SSSE3; |
| if (IS_ALIGNED(width, 4)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_SSSE3; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_AVX2) |
| if (TestCpuFlag(kCpuHasAVX2)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_AVX2; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_AVX2; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_NEON) |
| if (TestCpuFlag(kCpuHasNEON)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON; |
| if (IS_ALIGNED(width, 8)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_NEON; |
| } |
| } |
| #endif |
| #if defined(HAS_ARGBATTENUATEROW_MSA) |
| if (TestCpuFlag(kCpuHasMSA)) { |
| ARGBAttenuateRow = ARGBAttenuateRow_Any_MSA; |
| if (IS_ALIGNED(width, 8)) {<
|