Fix NV12 offset calculation routines 69/202769/1
authorYoungJun Cho <yj44.cho@samsung.com>
Thu, 4 Apr 2019 13:04:26 +0000 (22:04 +0900)
committerYoungJun Cho <yj44.cho@samsung.com>
Thu, 4 Apr 2019 13:04:26 +0000 (22:04 +0900)
This patch fixes NV12 offset calculation routines.

Change-Id: Ida9e4a7c51d4397ee77ecf2826a040a07a8b484d
Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
src/tbm_bufmgr_exynos.c

index 7ee6bf021b4d63bc807a554de4f1357be1bf4e78..d2bfea29600b11dba8d5cd6dac1cb1fde7cb8cdb 100644 (file)
@@ -918,7 +918,6 @@ _exynos_bo_handle(tbm_bo_exynos bo_exynos, int device)
        return bo_handle;
 }
 
-#if 0
 static int
 _new_calc_plane_nv12(int width, int height)
 {
@@ -971,7 +970,6 @@ _new_calc_uvplane_nv12(int width, int height)
                                                height) >> 1) + S5P_FIMV_D_ALIGN_PLANE_SIZE,
                          TBM_SURFACE_ALIGNMENT_PLANE_NV12);
 }
-#endif
 
 static tbm_bufmgr_capability
 tbm_exynos_bufmgr_get_capabilities(tbm_backend_bufmgr_data *bufmgr_data, tbm_error_e *error)
@@ -1113,40 +1111,31 @@ tbm_exynos_bufmgr_get_plane_data(tbm_backend_bufmgr_data *bufmgr_data,
                */
        case TBM_FORMAT_NV12:
                bpp = 12;
-               /*if (plane_idx == 0)*/
-               {
-                       _offset = 0;
-                       _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-                       _size = SIZE_ALIGN((SIZE_ALIGN(width, 16) * SIZE_ALIGN(height, 16) * 3) / 2, 512);
-                       _bo_idx = 0;
-                       if (plane_idx == 0)
-                               break;
-               }
-               /*else if (plane_idx == 1)*/
-               {
+               _bo_idx = 0;
+               if (plane_idx == 0) {
                        _offset = 0;
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-                       _size = SIZE_ALIGN((SIZE_ALIGN(width, 16) * SIZE_ALIGN(height, 16) * 3) / 2, 512);
-                       _bo_idx = 1;
+                       _size = MAX(_calc_yplane_nv12(width, height),
+                                       _new_calc_yplane_nv12(width, height));
+               } else if (plane_idx == 1) {
+                       _offset = MAX(_calc_yplane_nv12(width, height),
+                                       _new_calc_yplane_nv12(width, height));
+                       _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2);
+                       _size = MAX(_calc_uvplane_nv12(width, height),
+                                       _new_calc_uvplane_nv12(width, height));
                }
                break;
        case TBM_FORMAT_NV21:
                bpp = 12;
-               /*if (plane_idx == 0)*/
-               {
+               _bo_idx = 0;
+               _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
+               if (plane_idx == 0) {
                        _offset = 0;
-                       _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
                        _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
-                       _bo_idx = 0;
-                       if (plane_idx == 0)
-                               break;
-               }
-               /*else if (plane_idx == 1)*/
-               {
-                       _offset += _size;
+               } else if (plane_idx == 1) {
+                       _offset = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
                        _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2);
                        _size = SIZE_ALIGN(_pitch * (height / 2), TBM_SURFACE_ALIGNMENT_PLANE);
-                       _bo_idx = 0;
                }
                break;