diff options
author | Ankit Goyal <layog@google.com> | 2023-04-26 18:11:04 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-04-26 18:11:04 +0000 |
commit | 9d43bc7fcccd7b2729175f6a72d2726fd5bb18aa (patch) | |
tree | 524dd86a31f37966ea41c0eb1f33f4aacbea2790 | |
parent | 6f9e7ef8875b835af9c72e9b562be8639367f46d (diff) | |
parent | ff5160a15fa535809b3b513e58b59a1393a22c7b (diff) | |
download | gchips-9d43bc7fcccd7b2729175f6a72d2726fd5bb18aa.tar.gz |
gralloc4: Update YV12 alignment to conform to platform contract am: ff5160a15f
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/google/gchips/+/22693399
Change-Id: I6c6535a3404a5f6bdd11c493e934f33d76c7af65
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | gralloc4/src/core/mali_gralloc_bufferallocation.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp index 7355930..289db0b 100644 --- a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp +++ b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp @@ -450,20 +450,14 @@ static void update_yv12_stride(int8_t plane, uint32_t stride_align, uint32_t * byte_stride) { - if (plane == 0) - { - *byte_stride = GRALLOC_ALIGN(luma_stride, GRALLOC_ALIGN(stride_align, 32)); - } - else - { - /* - * Derive chroma stride from luma and verify it is: - * 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, GRALLOC_ALIGN(stride_align / 2, 16))); - assert(*byte_stride & 15 == 0); + // https://developer.android.com/reference/android/graphics/ImageFormat#YV12 + if (plane == 0) { + // stride_align has to be honored as GPU alignment still requires the format to be + // 64 bytes aligned. Though that does not break the contract as long as the + // horizontal stride for chroma is half the luma stride and aligned to 16. + *byte_stride = GRALLOC_ALIGN(luma_stride, GRALLOC_ALIGN(stride_align, 16)); + } else { + *byte_stride = GRALLOC_ALIGN(luma_stride / 2, 16); } } #endif @@ -647,10 +641,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`. + * + * 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) { |