From 805babf99548b5db5c577021162a12c582a10425 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Tue, 21 Jul 2026 18:18:10 -0700 Subject: [PATCH] [libyuv] Fix NV21 chroma plane ordering in ARGBToNV21Matrix Fix the chroma plane order passed to MergeUVRow in ARGBToNV21Matrix. MergeUVRow(a, b, dst, ...) writes a into byte 0 and b into byte 1. Passing (row_u, row_v) produced NV12 format (UV interleaved) instead of NV21 format (VU interleaved). Swapping to (row_v, row_u) ensures the chroma channels are correctly ordered for NV21 output. Test: libyuv_unittest --gtest_filter=*NV21* Bug: None Change-Id: I3b78246c635ce515923739298013a61203cabb72 TAG=agy CONV=5daf08a8-11bd-4d47-8c71-c5b7a882a788 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8133203 Reviewed-by: richard winterton --- source/convert_from_argb.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/convert_from_argb.cc b/source/convert_from_argb.cc index 77b3851d4..d5870a689 100644 --- a/source/convert_from_argb.cc +++ b/source/convert_from_argb.cc @@ -777,7 +777,7 @@ int ARGBToNV21Matrix(const uint8_t* src_argb, for (y = 0; y < height - 1; y += 2) { ARGBToUVMatrixRow(src_argb, src_stride_argb, row_u, row_v, width, argbconstants); - MergeUVRow(row_u, row_v, dst_vu, halfwidth); + MergeUVRow(row_v, row_u, dst_vu, halfwidth); ARGBToYMatrixRow(src_argb, dst_y, width, argbconstants); ARGBToYMatrixRow(src_argb + src_stride_argb, dst_y + dst_stride_y, width, argbconstants); @@ -787,7 +787,7 @@ int ARGBToNV21Matrix(const uint8_t* src_argb, } if (height & 1) { ARGBToUVMatrixRow(src_argb, 0, row_u, row_v, width, argbconstants); - MergeUVRow(row_u, row_v, dst_vu, halfwidth); + MergeUVRow(row_v, row_u, dst_vu, halfwidth); ARGBToYMatrixRow(src_argb, dst_y, width, argbconstants); } free_aligned_buffer_64(row_u);