I010ToNV12: dispatch Convert16To8Row on halfwidth

The Convert16To8Row function pointer in I010ToNV12 is only ever called
with halfwidth for the chroma planes (the Y plane goes through
Convert16To8Plane which has its own dispatch), but its SIMD variants
were selected based on the alignment of the full luma width. When width
is a multiple of 32 but halfwidth is not, the bare AVX2 kernel was
selected and over-read the chroma sources and over-wrote the temporary
row buffer. Match the MergeUVRow dispatch in the same function and key
on halfwidth.

Bug: chromium:514748734
Change-Id: I4c2a42857828cdcc6505ebaa65d5b6a95b0f7e55
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8031724
Reviewed-by: Frank Barchard <fbarchard@google.com>
Commit-Queue: Wan-Teh Chang <wtc@google.com>
This commit is contained in:
Wan-Teh Chang 2026-07-01 13:03:11 -07:00 committed by libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 8e8139a504
commit 8aeb3a9ca3

View File

@ -682,7 +682,7 @@ int I010ToNV12(const uint16_t* src_y,
#if defined(HAS_CONVERT16TO8ROW_NEON) #if defined(HAS_CONVERT16TO8ROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) { if (TestCpuFlag(kCpuHasNEON)) {
Convert16To8Row = Convert16To8Row_Any_NEON; Convert16To8Row = Convert16To8Row_Any_NEON;
if (IS_ALIGNED(width, 16)) { if (IS_ALIGNED(halfwidth, 16)) {
Convert16To8Row = Convert16To8Row_NEON; Convert16To8Row = Convert16To8Row_NEON;
} }
} }
@ -695,7 +695,7 @@ int I010ToNV12(const uint16_t* src_y,
#if defined(HAS_CONVERT16TO8ROW_SSSE3) #if defined(HAS_CONVERT16TO8ROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) { if (TestCpuFlag(kCpuHasSSSE3)) {
Convert16To8Row = Convert16To8Row_Any_SSSE3; Convert16To8Row = Convert16To8Row_Any_SSSE3;
if (IS_ALIGNED(width, 16)) { if (IS_ALIGNED(halfwidth, 16)) {
Convert16To8Row = Convert16To8Row_SSSE3; Convert16To8Row = Convert16To8Row_SSSE3;
} }
} }
@ -703,7 +703,7 @@ int I010ToNV12(const uint16_t* src_y,
#if defined(HAS_CONVERT16TO8ROW_AVX2) #if defined(HAS_CONVERT16TO8ROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) { if (TestCpuFlag(kCpuHasAVX2)) {
Convert16To8Row = Convert16To8Row_Any_AVX2; Convert16To8Row = Convert16To8Row_Any_AVX2;
if (IS_ALIGNED(width, 32)) { if (IS_ALIGNED(halfwidth, 32)) {
Convert16To8Row = Convert16To8Row_AVX2; Convert16To8Row = Convert16To8Row_AVX2;
} }
} }
@ -711,7 +711,7 @@ int I010ToNV12(const uint16_t* src_y,
#if defined(HAS_CONVERT16TO8ROW_AVX512BW) #if defined(HAS_CONVERT16TO8ROW_AVX512BW)
if (TestCpuFlag(kCpuHasAVX512BW)) { if (TestCpuFlag(kCpuHasAVX512BW)) {
Convert16To8Row = Convert16To8Row_Any_AVX512BW; Convert16To8Row = Convert16To8Row_Any_AVX512BW;
if (IS_ALIGNED(width, 64)) { if (IS_ALIGNED(halfwidth, 64)) {
Convert16To8Row = Convert16To8Row_AVX512BW; Convert16To8Row = Convert16To8Row_AVX512BW;
} }
} }