fix size, offset, pitch of NV format 51/220551/2
authorChangyeon Lee <cyeon.lee@samsung.com>
Thu, 19 Dec 2019 10:04:57 +0000 (19:04 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Thu, 19 Dec 2019 10:54:34 +0000 (19:54 +0900)
Change-Id: I61c14567a6d47d5d4da2bab847a6058d856172ef

src/tbm_bufmgr_vc4.c

index 4333e8f..4dbd904 100644 (file)
@@ -74,15 +74,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define TBM_SURFACE_ALIGNMENT_PLANE_NV12 (4096)
 #define TBM_SURFACE_ALIGNMENT_PITCH_YUV (16)
 
-#define SZ_1M                                   0x00100000
-#define S5P_FIMV_MAX_FRAME_SIZE                 (2 * SZ_1M)
-#define S5P_FIMV_D_ALIGN_PLANE_SIZE             64
-#define S5P_FIMV_NUM_PIXELS_IN_MB_ROW           16
-#define S5P_FIMV_NUM_PIXELS_IN_MB_COL           16
-#define S5P_FIMV_DEC_BUF_ALIGN                  (8 * 1024)
-#define S5P_FIMV_NV12MT_HALIGN                  128
-#define S5P_FIMV_NV12MT_VALIGN                  64
-
 //#define VC4_TILED_FORMAT 1
 
 struct dma_buf_info {
@@ -877,59 +868,6 @@ _vc4_bo_handle(tbm_bo_vc4 bo_vc4, int device)
        return bo_handle;
 }
 
-static int
-_new_calc_plane_nv12(int width, int height)
-{
-       int mbX, mbY;
-
-       mbX = DIV_ROUND_UP(width, S5P_FIMV_NUM_PIXELS_IN_MB_ROW);
-       mbY = DIV_ROUND_UP(height, S5P_FIMV_NUM_PIXELS_IN_MB_COL);
-
-       if (width * height < S5P_FIMV_MAX_FRAME_SIZE)
-               mbY = (mbY + 1) / 2 * 2;
-
-       return ((mbX * S5P_FIMV_NUM_PIXELS_IN_MB_COL) * (mbY *
-                       S5P_FIMV_NUM_PIXELS_IN_MB_ROW));
-}
-
-static int
-_calc_yplane_nv12(int width, int height)
-{
-       int mbX, mbY;
-
-       mbX = SIZE_ALIGN(width + 24, S5P_FIMV_NV12MT_HALIGN);
-       mbY = SIZE_ALIGN(height + 16, S5P_FIMV_NV12MT_VALIGN);
-
-       return SIZE_ALIGN(mbX * mbY, S5P_FIMV_DEC_BUF_ALIGN);
-}
-
-static int
-_calc_uvplane_nv12(int width, int height)
-{
-       int mbX, mbY;
-
-       mbX = SIZE_ALIGN(width + 16, S5P_FIMV_NV12MT_HALIGN);
-       mbY = SIZE_ALIGN(height + 4, S5P_FIMV_NV12MT_VALIGN);
-
-       return SIZE_ALIGN((mbX * mbY) >> 1, S5P_FIMV_DEC_BUF_ALIGN);
-}
-
-static int
-_new_calc_yplane_nv12(int width, int height)
-{
-       return SIZE_ALIGN(_new_calc_plane_nv12(width,
-                                               height) + S5P_FIMV_D_ALIGN_PLANE_SIZE,
-                          TBM_SURFACE_ALIGNMENT_PLANE_NV12);
-}
-
-static int
-_new_calc_uvplane_nv12(int width, int height)
-{
-       return SIZE_ALIGN((_new_calc_plane_nv12(width,
-                                               height) >> 1) + S5P_FIMV_D_ALIGN_PLANE_SIZE,
-                         TBM_SURFACE_ALIGNMENT_PLANE_NV12);
-}
-
 static tbm_bufmgr_capability
 tbm_vc4_bufmgr_get_capabilities(tbm_backend_bufmgr_data *bufmgr_data, tbm_error_e *error)
 {
@@ -1229,37 +1167,25 @@ tbm_vc4_bufmgr_get_plane_data(tbm_backend_bufmgr_data *bufmgr_data,
                * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian
                */
        case TBM_FORMAT_NV12:
-               bpp = 12;
-               if (plane_idx == 0) {
-                       _offset = 0;
-                       _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
-                       _size = MAX(_calc_yplane_nv12(width, height), _new_calc_yplane_nv12(width,
-                                       height));
-                       _bo_idx = 0;
-               } 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));
-                       _bo_idx = 0;
-               }
-               break;
        case TBM_FORMAT_NV21:
                bpp = 12;
-               if (plane_idx == 0) {
+               /*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;
-               } else if (plane_idx == 1) {
-                       _offset = width * height;
-                       _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2);
+                       if (plane_idx == 0)
+                               break;
+               }
+               /*else if (plane_idx == 1)*/
+               {
+                       _offset += _size;
+                       _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
                        _size = SIZE_ALIGN(_pitch * (height / 2), TBM_SURFACE_ALIGNMENT_PLANE);
                        _bo_idx = 0;
                }
                break;
-
        case TBM_FORMAT_NV16:
        case TBM_FORMAT_NV61:
                bpp = 16;
@@ -1275,7 +1201,7 @@ tbm_vc4_bufmgr_get_plane_data(tbm_backend_bufmgr_data *bufmgr_data,
                /*else if( plane_idx ==1 )*/
                {
                        _offset += _size;
-                       _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV / 2);
+                       _pitch = SIZE_ALIGN(width, TBM_SURFACE_ALIGNMENT_PITCH_YUV);
                        _size = SIZE_ALIGN(_pitch * height, TBM_SURFACE_ALIGNMENT_PLANE);
                        _bo_idx = 0;
                }