From c2ae68114a600888e6a26d954da41cc5574825a8 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Mon, 29 Oct 2018 12:26:20 -0700 Subject: [PATCH] Fix for AVX2 crash in I420ToRGB24 I422ToRGB24 is implemented as a C wrapper for Intel, calling I422ToARGB and ARGBToRGB24. The ARGBToRGB24 for AVX2 requires 32 pixels. This CL increases the width alignment required to use I422ToRGB24_AVX2 TBR=rrwinterton0gmail.com Bug: libyuv:822, b:118386049 Change-Id: I4454f4eece33fbd5f593655f577c9ef5c00d1f63 Tested: locally tested with app that crashed using this function. Reviewed-on: https://chromium-review.googlesource.com/c/1299931 Reviewed-by: Frank Barchard Commit-Queue: Frank Barchard --- include/libyuv/row.h | 8 +++----- include/libyuv/version.h | 2 +- source/convert_from.cc | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/libyuv/row.h b/include/libyuv/row.h index cc948878f..da54f7d7a 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -284,9 +284,8 @@ extern "C" { (defined(CLANG_HAS_AVX2) || defined(GCC_HAS_AVX2)) #define HAS_ABGRTOAR30ROW_AVX2 #define HAS_ARGBTOAR30ROW_AVX2 -// Fix AVX2 b:118386049 segfault -//#define HAS_ARGBTORAWROW_AVX2 -//#define HAS_ARGBTORGB24ROW_AVX2 +#define HAS_ARGBTORAWROW_AVX2 +#define HAS_ARGBTORGB24ROW_AVX2 #define HAS_CONVERT16TO8ROW_AVX2 #define HAS_CONVERT8TO16ROW_AVX2 #define HAS_I210TOAR30ROW_AVX2 @@ -304,8 +303,7 @@ extern "C" { #if !defined(LIBYUV_DISABLE_X86) && \ (defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER))) && \ (defined(CLANG_HAS_AVX512)) -// Fix AVX2 b:118386049 segfault -//#define HAS_ARGBTORGB24ROW_AVX512VBMI +#define HAS_ARGBTORGB24ROW_AVX512VBMI #endif // The following are available on Neon platforms: diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 1a38ba7d6..666d81ae2 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 1722 +#define LIBYUV_VERSION 1723 #endif // INCLUDE_LIBYUV_VERSION_H_ diff --git a/source/convert_from.cc b/source/convert_from.cc index 706067bb2..60140cb4e 100644 --- a/source/convert_from.cc +++ b/source/convert_from.cc @@ -670,7 +670,7 @@ static int I420ToRGB24Matrix(const uint8_t* src_y, #if defined(HAS_I422TORGB24ROW_SSSE3) if (TestCpuFlag(kCpuHasSSSE3)) { I422ToRGB24Row = I422ToRGB24Row_Any_SSSE3; - if (IS_ALIGNED(width, 8)) { + if (IS_ALIGNED(width, 16)) { I422ToRGB24Row = I422ToRGB24Row_SSSE3; } } @@ -678,7 +678,7 @@ static int I420ToRGB24Matrix(const uint8_t* src_y, #if defined(HAS_I422TORGB24ROW_AVX2) if (TestCpuFlag(kCpuHasAVX2)) { I422ToRGB24Row = I422ToRGB24Row_Any_AVX2; - if (IS_ALIGNED(width, 16)) { + if (IS_ALIGNED(width, 32)) { I422ToRGB24Row = I422ToRGB24Row_AVX2; } }