summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaiyi Li <kaiyili@google.com>2022-04-21 13:09:53 -0700
committerJason Macnak <natsu@google.com>2023-05-17 12:33:56 -0700
commit57aebe297981bfcd8ebcc5a9c100d6df6a6198cb (patch)
treedaa0be5c4092d899eda25390775236ac8b5a6d45
parent4aa28a5fe9a1f48bd2c3ac319a12b04fd17a2f93 (diff)
downloadvulkan-cereal-57aebe297981bfcd8ebcc5a9c100d6df6a6198cb.tar.gz
YUVConverter: fix offset calculation
For NV21, NV12, YV12 formats, the cb/cr plane width should always be half of the width of the Y plane. Cherry-pick of aosp/2072607 which appears to be have been lost during the revert ag/20281548 Bug: 283013305 Test: cvd start --gpu_mode=gfxstream Test: open Youtube video Test: open Youtube short video Test: open Camera Change-Id: I89b4bfcad1c36ec9fa6d0dbdef719d18486bc521 Merged-In: I571655e44e81456fe2378e78e3c0c6adb5a51623
-rw-r--r--stream-servers/YUVConverter.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/stream-servers/YUVConverter.cpp b/stream-servers/YUVConverter.cpp
index 10e97c50..084f5d0c 100644
--- a/stream-servers/YUVConverter.cpp
+++ b/stream-servers/YUVConverter.cpp
@@ -318,7 +318,7 @@ static void getYUVOffsets(int width,
// Luma stride is 32 bytes aligned.
yStride = alignToPower2(width, 32);
// Chroma stride is 16 bytes aligned.
- cStride = alignToPower2(yStride, 16);
+ cStride = alignToPower2(yStride / 2, 16);
cHeight = height / 2;
cSize = cStride * cHeight;
*yOffset = 0;
@@ -330,13 +330,13 @@ static void getYUVOffsets(int width,
case FRAMEWORK_FORMAT_YUV_420_888:
if (feature_is_enabled(kFeature_YUV420888toNV21)) {
yStride = width;
- cStride = yStride;
+ cStride = yStride / 2;
cHeight = height / 2;
*yOffset = 0;
*vOffset = yStride * height;
*uOffset = (*vOffset) + 1;
*yWidth = yStride;
- *cWidth = cStride / 2;
+ *cWidth = cStride;
} else {
yStride = width;
cStride = yStride / 2;
@@ -351,14 +351,14 @@ static void getYUVOffsets(int width,
break;
case FRAMEWORK_FORMAT_NV12:
yStride = width;
- cStride = yStride;
+ cStride = yStride / 2;
cHeight = height / 2;
cSize = cStride * cHeight;
*yOffset = 0;
*uOffset = yStride * height;
*vOffset = (*uOffset) + 1;
*yWidth = yStride;
- *cWidth = cStride / 2;
+ *cWidth = cStride;
break;
case FRAMEWORK_FORMAT_P010:
*yWidth = width;