From d9fe02d49a5b8385195c36214651cc21921ebc4e Mon Sep 17 00:00:00 2001 From: Jiajia Cong Date: Thu, 3 Aug 2023 09:40:30 +0530 Subject: [PATCH] video: driver: fix roi metadata size calculation lcu_size shouldn't be changed by shift op, it is still needed in alignment calculation. Change-Id: I3c0ebfaee84389926ba3e191d901006065598182 Signed-off-by: Jiajia Cong --- driver/variant/iris2/inc/hfi_buffer_iris2.h | 7 ++++--- driver/variant/iris3/inc/hfi_buffer_iris3.h | 7 ++++--- driver/variant/iris33/inc/hfi_buffer_iris33.h | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/driver/variant/iris2/inc/hfi_buffer_iris2.h b/driver/variant/iris2/inc/hfi_buffer_iris2.h index 40199ebe60..5be5f720f7 100644 --- a/driver/variant/iris2/inc/hfi_buffer_iris2.h +++ b/driver/variant/iris2/inc/hfi_buffer_iris2.h @@ -892,10 +892,11 @@ _yuv_bufcount_min, is_opb, num_vpp_pipes) \ #define SIZE_ROI_METADATA_ENC(size_roi, frame_width, frame_height, lcu_size)\ do { \ HFI_U32 width_in_lcus = 0, height_in_lcus = 0, n_shift = 0; \ - while (lcu_size && !(lcu_size & 0x1)) { \ + HFI_U32 n_lcu_size = lcu_size; \ + while (n_lcu_size && !(n_lcu_size & 0x1)) { \ n_shift++; \ - lcu_size = lcu_size >> 1; \ - } \ + n_lcu_size = n_lcu_size >> 1; \ + } \ width_in_lcus = (frame_width + (lcu_size - 1)) >> n_shift; \ height_in_lcus = (frame_height + (lcu_size - 1)) >> n_shift; \ size_roi = (((width_in_lcus + 7) >> 3) << 3) * \ diff --git a/driver/variant/iris3/inc/hfi_buffer_iris3.h b/driver/variant/iris3/inc/hfi_buffer_iris3.h index 2aa5068fab..7137b6e23e 100644 --- a/driver/variant/iris3/inc/hfi_buffer_iris3.h +++ b/driver/variant/iris3/inc/hfi_buffer_iris3.h @@ -1222,10 +1222,11 @@ _yuv_bufcount_min, is_opb, num_vpp_pipes) \ #define SIZE_ROI_METADATA_ENC(size_roi, frame_width, frame_height, lcu_size)\ do { \ HFI_U32 width_in_lcus = 0, height_in_lcus = 0, n_shift = 0; \ - while (lcu_size && !(lcu_size & 0x1)) { \ + HFI_U32 n_lcu_size = lcu_size; \ + while (n_lcu_size && !(n_lcu_size & 0x1)) { \ n_shift++; \ - lcu_size = lcu_size >> 1; \ - } \ + n_lcu_size = n_lcu_size >> 1; \ + } \ width_in_lcus = (frame_width + (lcu_size - 1)) >> n_shift; \ height_in_lcus = (frame_height + (lcu_size - 1)) >> n_shift; \ size_roi = (((width_in_lcus + 7) >> 3) << 3) * \ diff --git a/driver/variant/iris33/inc/hfi_buffer_iris33.h b/driver/variant/iris33/inc/hfi_buffer_iris33.h index 6c13410961..1e20d701a7 100644 --- a/driver/variant/iris33/inc/hfi_buffer_iris33.h +++ b/driver/variant/iris33/inc/hfi_buffer_iris33.h @@ -1222,10 +1222,11 @@ _yuv_bufcount_min, is_opb, num_vpp_pipes) \ #define SIZE_ROI_METADATA_ENC(size_roi, frame_width, frame_height, lcu_size)\ do { \ HFI_U32 width_in_lcus = 0, height_in_lcus = 0, n_shift = 0; \ - while (lcu_size && !(lcu_size & 0x1)) { \ + HFI_U32 n_lcu_size = lcu_size; \ + while (n_lcu_size && !(n_lcu_size & 0x1)) { \ n_shift++; \ - lcu_size = lcu_size >> 1; \ - } \ + n_lcu_size = n_lcu_size >> 1; \ + } \ width_in_lcus = (frame_width + (lcu_size - 1)) >> n_shift; \ height_in_lcus = (frame_height + (lcu_size - 1)) >> n_shift; \ size_roi = (((width_in_lcus + 7) >> 3) << 3) * \