| Index: source/planar_functions.cc
|
| diff --git a/source/planar_functions.cc b/source/planar_functions.cc
|
| index 73fa7d284af31478d1f4667e8c02b572f16ce6fe..b1b1f2c830b4ec931eedcdc8036c9774416c6b1c 100644
|
| --- a/source/planar_functions.cc
|
| +++ b/source/planar_functions.cc
|
| @@ -2374,6 +2374,49 @@ int ARGBCopyAlpha(const uint8* src_argb, int src_stride_argb,
|
| return 0;
|
| }
|
|
|
| +// Extract just the alpha channel from ARGB.
|
| +LIBYUV_API
|
| +int ARGBExtractAlpha(const uint8* src_argb, int src_stride,
|
| + uint8* dst_a, int dst_stride,
|
| + int width, int height) {
|
| + if (!src_argb || !dst_a || width <= 0 || height == 0) {
|
| + return -1;
|
| + }
|
| + // Negative height means invert the image.
|
| + if (height < 0) {
|
| + height = -height;
|
| + src_argb += (height - 1) * src_stride;
|
| + src_stride = -src_stride;
|
| + }
|
| + // Coalesce rows.
|
| + if (src_stride == width * 4 && dst_stride == width) {
|
| + width *= height;
|
| + height = 1;
|
| + src_stride = dst_stride = 0;
|
| + }
|
| + void (*ARGBExtractAlphaRow)(const uint8 *src_argb, uint8 *dst_a, int width) =
|
| + ARGBExtractAlphaRow_C;
|
| +#if defined(HAS_ARGBEXTRACTALPHAROW_SSE2)
|
| + if (TestCpuFlag(kCpuHasSSE2)) {
|
| + ARGBExtractAlphaRow = IS_ALIGNED(width, 8) ? ARGBExtractAlphaRow_SSE2
|
| + : ARGBExtractAlphaRow_Any_SSE2;
|
| + }
|
| +#endif
|
| +#if defined(HAS_ARGBEXTRACTALPHAROW_NEON)
|
| + if (TestCpuFlag(kCpuHasNEON)) {
|
| + ARGBExtractAlphaRow = IS_ALIGNED(width, 8) ? ARGBExtractAlphaRow_NEON
|
| + : ARGBExtractAlphaRow_Any_NEON;
|
| + }
|
| +#endif
|
| +
|
| + for (int y = 0; y < height; ++y) {
|
| + ARGBExtractAlphaRow(src_argb, dst_a, width);
|
| + src_argb += src_stride;
|
| + dst_a += dst_stride;
|
| + }
|
| + return 0;
|
| +}
|
| +
|
| // Copy a planar Y channel to the alpha channel of a destination ARGB image.
|
| LIBYUV_API
|
| int ARGBCopyYToAlpha(const uint8* src_y, int src_stride_y,
|
|
|