Browse Source

Merge branch 'CR_2782_OMX_VPU_515_Som.Qin' into 'jh7110-devel'

CR 2782 OMX:VPU: Align the output data with picture width manually when stride > width

See merge request sdk/freelight-u-sdk!237
andy.hu 1 year ago
parent
commit
a6638af9a0

+ 6 - 1
omx-il/component/video/wave5/dec/SF_OMX_Vdec_decoder.c

@@ -668,7 +668,12 @@ static OMX_ERRORTYPE SF_OMX_AllocateBuffer(
                 // Alloc DMA memory first
                 if (pSfOMXComponent->memory_optimization)
                 {
-                    temp_bufferHeader->pBuffer = pSfVideoImplement->functions->AllocateFrameBuffer2(pComponentRender, nSizeBytes);
+                    OMX_U32 nLinearBufferSize, nFrameWidth, nFrameHeight;
+                    nFrameWidth = OMX_ALIGN32(pSfOMXComponent->portDefinition[1].format.video.nFrameWidth);
+                    nFrameHeight = pSfOMXComponent->portDefinition[1].format.video.nFrameHeight;
+                    nLinearBufferSize = nFrameWidth * nFrameHeight * 3 / 2;
+                    nLinearBufferSize = (nLinearBufferSize > nSizeBytes)? nLinearBufferSize : nSizeBytes;
+                    temp_bufferHeader->pBuffer = pSfVideoImplement->functions->AllocateFrameBuffer2(pComponentRender, nLinearBufferSize);
                 }
                 // DMA Memory alloc fail, goto normal alloc
                 if (temp_bufferHeader->pBuffer == NULL)

+ 2 - 0
omx-il/core/SF_OMX_Core.h

@@ -129,6 +129,8 @@ typedef struct _SF_PORT_PRIVATE
     OMX_U32 nPortnumber;
 } SF_PORT_PRIVATE;
 
+#define OMX_ALIGN32(_x)  (((_x)+0x1f)&~0x1f)
+
 #define PRINT_STUCT(a, b)                                   \
     do                                                      \
     {                                                       \

+ 37 - 7
wave511/code/sample_v2/helper/misc/cnm_video_helper.c

@@ -2104,9 +2104,11 @@ void LoadSrcYUV2(
     )
 {
     Uint32      pix_addr;
-    Uint8*      rowBufferY;
+    Uint8*      rowBuffer;
+    Uint8*      puc;
 
     Int32       baseY;
+    Int32       y;
 
     Uint8       *pY = NULL;
     Uint8       *pCb = NULL;
@@ -2139,15 +2141,43 @@ void LoadSrcYUV2(
 #endif
 
     pix_addr = fbSrc->bufY + 0xffffffff00000000;
-    rowBufferY = pY + (pix_addr - baseY);
-    VLOG(DEBUG, "%s %d ret = %d, pix_addr = %lx,  pY = %p, rowBufferY = %p pSrc = %p pSrc2 = %p\n",
-        __FUNCTION__, __LINE__, ret, pix_addr, pY, rowBufferY, pSrc, pSrc2);
+    rowBuffer = pY + (pix_addr - baseY);
+    VLOG(DEBUG, "%s %d ret = %d, pix_addr = %lx,  pY = %p, rowBuffer = %p pSrc = %p pSrc2 = %p\n",
+        __FUNCTION__, __LINE__, ret, pix_addr, pY, rowBuffer, pSrc, pSrc2);
+
+    /* pSrc and pSrc2 can not be !NULL at same time */
     if (pSrc) {
-        osal_memcpy(pSrc, rowBufferY, srcHeightY*srcWidthY*3/2);
+        puc = pSrc;
+    } else if (pSrc2) {
+        *pSrc2 = rowBuffer;
+        puc = *pSrc2;
     }
-    if (pSrc2) {
-        *pSrc2 = rowBufferY;
+
+    if (fbSrc->stride > srcWidthY) {
+        for (y = 1; y < srcHeightY; y ++) {
+            osal_memcpy(puc + srcWidthY * y, rowBuffer + fbSrc->stride * y, srcWidthY);
+        }
+
+        if (srcHeightC) {
+            puc += srcWidthY * srcHeightY;
+            rowBuffer +=  fbSrc->bufCb - fbSrc->bufY;
+            for (y = 0; y < srcHeightC; y ++) {
+                osal_memcpy(puc + srcWidthC * y, rowBuffer + chroma_stride * y, srcWidthC);
+            }
+
+            if (interLeave != TRUE) {
+                puc = puc + srcWidthC * srcHeightC;
+                rowBuffer +=  fbSrc->bufCr - fbSrc->bufCb;
+                for (y = 0; y < srcHeightC; y ++) {
+                    osal_memcpy(puc + srcWidthC * y, rowBuffer + chroma_stride * y, srcWidthC);
+                }
+            }
+        }
+    } else if (pSrc) {
+        osal_memcpy(pSrc, rowBuffer, srcHeightY*srcWidthY*3/2);
     }
+
+
     // following code store output buffers
 #if 0
     {