diff options
Diffstat (limited to 'chromium/third_party/libyuv/source/rotate_argb.cc')
-rw-r--r-- | chromium/third_party/libyuv/source/rotate_argb.cc | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/chromium/third_party/libyuv/source/rotate_argb.cc b/chromium/third_party/libyuv/source/rotate_argb.cc index b95512783a0..ab0f9ce0707 100644 --- a/chromium/third_party/libyuv/source/rotate_argb.cc +++ b/chromium/third_party/libyuv/source/rotate_argb.cc @@ -45,6 +45,7 @@ void ScaleARGBRowDownEven_C(const uint8* src_ptr, int, static void ARGBTranspose(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width, int height) { + int i; int src_pixel_step = src_stride >> 2; void (*ScaleARGBRowDownEven)(const uint8* src_ptr, int src_stride, int src_step, uint8* dst_ptr, int dst_width) = ScaleARGBRowDownEven_C; @@ -60,7 +61,7 @@ static void ARGBTranspose(const uint8* src, int src_stride, } #endif - for (int i = 0; i < width; ++i) { // column of source to row of dest. + for (i = 0; i < width; ++i) { // column of source to row of dest. ScaleARGBRowDownEven(src, 0, src_pixel_step, dst, height); dst += dst_stride; src += 4; @@ -89,12 +90,18 @@ void ARGBRotate270(const uint8* src, int src_stride, ARGBTranspose(src, src_stride, dst, dst_stride, width, height); } -SAFEBUFFERS void ARGBRotate180(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width, int height) { + // Swap first and last row and mirror the content. Uses a temporary row. + align_buffer_64(row, width * 4); + const uint8* src_bot = src + src_stride * (height - 1); + uint8* dst_bot = dst + dst_stride * (height - 1); + int half_height = (height + 1) >> 1; + int y; void (*ARGBMirrorRow)(const uint8* src, uint8* dst, int width) = ARGBMirrorRow_C; + void (*CopyRow)(const uint8* src, uint8* dst, int width) = CopyRow_C; #if defined(HAS_ARGBMIRRORROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 4) && IS_ALIGNED(src, 16) && IS_ALIGNED(src_stride, 16) && @@ -112,7 +119,6 @@ void ARGBRotate180(const uint8* src, int src_stride, ARGBMirrorRow = ARGBMirrorRow_NEON; } #endif - void (*CopyRow)(const uint8* src, uint8* dst, int width) = CopyRow_C; #if defined(HAS_COPYROW_NEON) if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width * 4, 32)) { CopyRow = CopyRow_NEON; @@ -140,37 +146,25 @@ void ARGBRotate180(const uint8* src, int src_stride, CopyRow = CopyRow_MIPS; } #endif - bool direct = width * 4 > kMaxStride; - // Swap first and last row and mirror the content. Uses a temporary row. - SIMD_ALIGNED(uint8 row[kMaxStride]); - const uint8* src_bot = src + src_stride * (height - 1); - uint8* dst_bot = dst + dst_stride * (height - 1); - int half_height = (height + 1) >> 1; // Odd height will harmlessly mirror the middle row twice. - for (int y = 0; y < half_height; ++y) { - if (direct) { - ARGBMirrorRow(src, dst_bot, width); // Mirror first row into a buffer - if (src != src_bot) { - ARGBMirrorRow(src_bot, dst, width); // Mirror last row into first row - } - } else { - ARGBMirrorRow(src, row, width); // Mirror first row into a buffer - ARGBMirrorRow(src_bot, dst, width); // Mirror last row into first row - CopyRow(row, dst_bot, width * 4); // Copy first mirrored row into last - } + for (y = 0; y < half_height; ++y) { + ARGBMirrorRow(src, row, width); // Mirror first row into a buffer + ARGBMirrorRow(src_bot, dst, width); // Mirror last row into first row + CopyRow(row, dst_bot, width * 4); // Copy first mirrored row into last src += src_stride; dst += dst_stride; src_bot -= src_stride; dst_bot -= dst_stride; } + free_aligned_buffer_64(row); } LIBYUV_API int ARGBRotate(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height, - RotationMode mode) { + enum RotationMode mode) { if (!src_argb || width <= 0 || height == 0 || !dst_argb) { return -1; } |