[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 <rrwinterton@gmail.com>
This commit is contained in:
Frank Barchard 2026-07-21 18:18:10 -07:00
parent 1e06475900
commit 805babf995

View File

@ -777,7 +777,7 @@ int ARGBToNV21Matrix(const uint8_t* src_argb,
for (y = 0; y < height - 1; y += 2) { for (y = 0; y < height - 1; y += 2) {
ARGBToUVMatrixRow(src_argb, src_stride_argb, row_u, row_v, width, ARGBToUVMatrixRow(src_argb, src_stride_argb, row_u, row_v, width,
argbconstants); 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, dst_y, width, argbconstants);
ARGBToYMatrixRow(src_argb + src_stride_argb, dst_y + dst_stride_y, width, ARGBToYMatrixRow(src_argb + src_stride_argb, dst_y + dst_stride_y, width,
argbconstants); argbconstants);
@ -787,7 +787,7 @@ int ARGBToNV21Matrix(const uint8_t* src_argb,
} }
if (height & 1) { if (height & 1) {
ARGBToUVMatrixRow(src_argb, 0, row_u, row_v, width, argbconstants); 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); ARGBToYMatrixRow(src_argb, dst_y, width, argbconstants);
} }
free_aligned_buffer_64(row_u); free_aligned_buffer_64(row_u);