diff options
author | wenchangliu <wenchangliu@google.com> | 2021-09-15 21:53:40 +0800 |
---|---|---|
committer | Wen Chang Liu <wenchangliu@google.com> | 2021-09-16 09:50:18 +0000 |
commit | 313da845beaba91bee8793308923ab05dcbc60f7 (patch) | |
tree | a2a92345f7985c278fdcabb55779ccb98c9f4d4b /gralloc4/src | |
parent | 60ece62602ddceb1ab52c438cdca1d98efe24a48 (diff) | |
download | gchips-313da845beaba91bee8793308923ab05dcbc60f7.tar.gz |
Fix YV12 stride alignment issue
For some applications (TikTok, AliExpress, Shopee), the YUV layout
is not requested from GraphicBufferMapper API, causing a misalignment
if the resolution can't satisfy both 64 and 128 alignments.
To prevent luma stride misalignment with GPU stride alignment.
The luma plane will maintain the same `stride` size, and the
chroma plane will align to `stride/2`.
Bug: 199836131
Test: AliExpress/Shopee live streaming
Change-Id: Id8dd547ff60dec7be49d777f2a63081923d5a9cf
Diffstat (limited to 'gralloc4/src')
-rw-r--r-- | gralloc4/src/core/mali_gralloc_bufferallocation.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp index 53bbb6f..fe2349b 100644 --- a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp +++ b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp @@ -446,22 +446,17 @@ static void update_yv12_stride(int8_t plane, { if (plane == 0) { - /* - * Ensure luma stride is aligned to "2*lcm(hw_align, cpu_align)" so - * that chroma stride can satisfy both CPU and HW alignment - * constraints when only half luma stride (as mandated for format). - */ - *byte_stride = GRALLOC_ALIGN(luma_stride, 2 * stride_align); + *byte_stride = GRALLOC_ALIGN(luma_stride, stride_align); } else { /* * Derive chroma stride from luma and verify it is: - * 1. Aligned to lcm(hw_align, cpu_align) + * 1. Aligned to "1/2*lcm(hw_align, cpu_align)" * 2. Multiple of 16px (16 bytes) */ *byte_stride = luma_stride / 2; - assert(*byte_stride == GRALLOC_ALIGN(*byte_stride, stride_align)); + assert(*byte_stride == GRALLOC_ALIGN(*byte_stride, stride_align / 2)); assert(*byte_stride & 15 == 0); } } @@ -611,6 +606,10 @@ static void calc_allocation_size(const int width, /* * Update YV12 stride with both CPU & HW usage due to constraint of chroma stride. * Width is anyway aligned to 16px for luma and chroma (has_cpu_usage). + * + * Note: To prevent luma stride misalignment with GPU stride alignment. + * The luma plane will maintain the same `stride` size, and the chroma plane + * will align to `stride/2`. */ if (format.id == MALI_GRALLOC_FORMAT_INTERNAL_YV12 && has_hw_usage && has_cpu_usage) { |