Browse Source

OMX: vidoe decoder: Fix yuv channel alignment issues in some resolution.

Signed-off-by: Som Qin <som.qin@starfivetech.com>
Som Qin 5 months ago
parent
commit
b4b871706c

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

@@ -267,14 +267,14 @@ static void OnEventArrived(Component com, unsigned long event, void *data, void
         {
             pSfOMXComponent->portDefinition[1].format.video.nFrameWidth = testConfig->scaleDownWidth;
             pSfOMXComponent->portDefinition[1].format.video.nFrameHeight = testConfig->scaleDownHeight;
-            pSfOMXComponent->portDefinition[1].format.video.nStride = testConfig->scaleDownWidth;
+            pSfOMXComponent->portDefinition[1].format.video.nStride = OMX_ALIGN32(testConfig->scaleDownWidth);
             pSfOMXComponent->portDefinition[1].format.video.nSliceHeight = testConfig->scaleDownHeight;
         }
         else
         {
             pSfOMXComponent->portDefinition[1].format.video.nFrameWidth = pInfo->picCropRect.right;
             pSfOMXComponent->portDefinition[1].format.video.nFrameHeight = pInfo->picCropRect.bottom;
-            pSfOMXComponent->portDefinition[1].format.video.nStride = pInfo->picWidth;
+            pSfOMXComponent->portDefinition[1].format.video.nStride = OMX_ALIGN32(pInfo->picWidth);
             pSfOMXComponent->portDefinition[1].format.video.nSliceHeight = pInfo->picHeight;
         }
         LOG(SF_LOG_INFO, "Get Output width = %d, height = %d\r\n", pSfOMXComponent->portDefinition[1].format.video.nFrameWidth,
@@ -1034,7 +1034,7 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
 
             pOutputPort->format.video.nFrameWidth = width;
             pOutputPort->format.video.nFrameHeight = height;
-            pOutputPort->format.video.nStride = width;
+            pOutputPort->format.video.nStride = OMX_ALIGN32(width);
             if (pSfOMXComponent->portDefinition[0].format.video.eCompressionFormat == OMX_VIDEO_CodingAVC)
                 pOutputPort->format.video.nSliceHeight = OMX_ALIGN16(height);
             else
@@ -1089,7 +1089,7 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
             }
             pOutputPort->format.video.nFrameWidth = width;
             pOutputPort->format.video.nFrameHeight = height;
-            pOutputPort->format.video.nStride = width;
+            pOutputPort->format.video.nStride = OMX_ALIGN32(width);
             if (pSfOMXComponent->portDefinition[0].format.video.eCompressionFormat == OMX_VIDEO_CodingAVC)
                 pOutputPort->format.video.nSliceHeight = OMX_ALIGN16(height);
             else
@@ -1099,7 +1099,7 @@ static OMX_ERRORTYPE SF_OMX_SetParameter(
             {
                 pTestDecConfig->scaleDownWidth = OMX_ALIGN2(width);
                 pTestDecConfig->scaleDownHeight = OMX_ALIGN2(height);
-                pOutputPort->format.video.nStride = testConfig->scaleDownWidth;
+                pOutputPort->format.video.nStride = OMX_ALIGN32(testConfig->scaleDownWidth);
                 pOutputPort->format.video.nSliceHeight = testConfig->scaleDownHeight;
                 LOG(SF_LOG_INFO, "Set scale = %d, %d\r\n", pTestDecConfig->scaleDownWidth , pTestDecConfig->scaleDownHeight);
             }

+ 3 - 2
omx-il/tests/dec_test.c

@@ -85,7 +85,8 @@ static OMX_ERRORTYPE event_handler(
         printf("enable output port and alloc buffer\n");
 
         printf("======================================\r\n");
-        printf("out put resolution [%dx%d]\r\n", pOutputPortDefinition.format.video.nFrameWidth, pOutputPortDefinition.format.video.nFrameHeight);
+        printf("out put resolution [%dx%d] stride [%dx%d]\r\n", pOutputPortDefinition.format.video.nFrameWidth, pOutputPortDefinition.format.video.nFrameHeight,
+                                                                pOutputPortDefinition.format.video.nStride, pOutputPortDefinition.format.video.nSliceHeight);
         printf("======================================\r\n");
 
         pDecodeTestContext->OutputWidth = pOutputPortDefinition.format.video.nFrameWidth;
@@ -306,7 +307,7 @@ static OMX_S32 WriteOutputBuffer(DecodeTestContext *decodeTestContext, OMX_BUFFE
     {
         if (srcStride[i] > srcWidth[i])
         {
-            for (j = 0; j < srcHeight[i]; i++)
+            for (j = 0; j < srcHeight[i]; j++)
             fwrite(pBuffer + j * srcStride[i], 1, srcWidth[i], fb);
 
         }

+ 1 - 29
wave511/code/sample_v2/helper/misc/cnm_video_helper.c

@@ -2106,10 +2106,8 @@ void LoadSrcYUV2(
 {
     Uint32      pix_addr;
     Uint8*      rowBuffer;
-    Uint8*      puc;
 
     Int32       baseY;
-    Int32       y;
 
     Uint8       *pY = NULL;
     Uint8       *pCb = NULL;
@@ -2148,37 +2146,11 @@ void LoadSrcYUV2(
 
     /* pSrc and pSrc2 can not be !NULL at same time */
     if (pSrc) {
-        puc = pSrc;
+        osal_memcpy(pSrc, rowBuffer, fbSrc->size);
     } else if (pSrc2) {
         *pSrc2 = rowBuffer;
-        puc = *pSrc2;
     }
 
-    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
     {