Browse Source

sf-omx-il: Add scale support for codaj12

Sodaj12 only support scale down 1/2, 1/4 or 1/8.

Signed-off-by: Som Qin <som.qin@starfivetech.com>
Som Qin 2 years ago
parent
commit
6a0dfc5a82

+ 57 - 0
soft_3rdpart/omx-il/component/image/dec/SF_OMX_Mjpeg_decoder.c

@@ -611,6 +611,25 @@ static OMX_ERRORTYPE SF_OMX_GetConfig(
         break;
     }
 
+    case OMX_IndexConfigCommonScale:
+    {
+        OMX_CONFIG_SCALEFACTORTYPE *scaleParam = (OMX_CONFIG_SCALEFACTORTYPE *)pComponentConfigStructure;
+        DecConfigParam *decConfig = pSfMjpegImplement->config;
+        if(scaleParam->nPortIndex == (OMX_U32)(OMX_OUTPUT_PORT_INDEX))
+        {
+            /* In Q16 format */
+            scaleParam->xWidth = (1 << 16) >> decConfig->iHorScaleMode;
+            scaleParam->xHeight = (1 << 16) >> decConfig->iVerScaleMode;
+            LOG(SF_LOG_INFO, "Get scale  %d(Q16),%d(Q16) \r\n", scaleParam->xWidth, scaleParam->xHeight);
+        }
+        else
+        {
+            LOG(SF_LOG_WARN, "Only output port support Scale config\r\n");
+            ret = OMX_ErrorBadParameter;
+        }
+        break;
+    }
+
     default:
         break;
     }
@@ -703,6 +722,44 @@ static OMX_ERRORTYPE SF_OMX_SetConfig(
         break;
     }
 
+    case OMX_IndexConfigCommonScale:
+    {
+        OMX_CONFIG_SCALEFACTORTYPE *scaleParam = (OMX_CONFIG_SCALEFACTORTYPE *)pComponentConfigStructure;
+        DecConfigParam *decConfig = pSfMjpegImplement->config;
+        OMX_U32 x;
+        if(scaleParam->nPortIndex == (OMX_U32)(OMX_OUTPUT_PORT_INDEX))
+        {
+            /* In Q16 format */
+            x = (1 << 16) / (scaleParam->xWidth);
+            if(x >= 8)
+                decConfig->iHorScaleMode = 3;
+            else if(x >= 4)
+                decConfig->iHorScaleMode = 2;
+            else if(x >= 2)
+                decConfig->iHorScaleMode = 1;
+            else
+                decConfig->iHorScaleMode = 0;
+
+            x = (1 << 16) / (scaleParam->xHeight);
+            if(x >= 8)
+                decConfig->iVerScaleMode = 3;
+            else if(x >= 4)
+                decConfig->iVerScaleMode = 2;
+            else if(x >= 2)
+                decConfig->iVerScaleMode = 1;
+            else
+                decConfig->iVerScaleMode = 0;
+
+            LOG(SF_LOG_INFO, "Set scale H 1/%d, V 1/%d \r\n", 1 << decConfig->iHorScaleMode, 1 << scaleParam->xHeight);
+        }
+        else
+        {
+            LOG(SF_LOG_WARN, "Only output port support Scale config\r\n");
+            ret = OMX_ErrorBadParameter;
+        }
+        break;
+    }
+
     default:
         break;
     }

+ 23 - 0
soft_3rdpart/omx-il/tests/mjpeg_dec_test.c

@@ -49,6 +49,8 @@ typedef struct DecodeTestContext
     OMX_U32 RoiHeight;
     OMX_U32 Rotation;
     OMX_U32 Mirror;
+    OMX_U32 ScaleFactorH;
+    OMX_U32 ScaleFactorV;
 } DecodeTestContext;
 DecodeTestContext *decodeTestContext;
 static OMX_S32 FillInputBuffer(DecodeTestContext *decodeTestContext, OMX_BUFFERHEADERTYPE *pInputBuffer);
@@ -211,6 +213,8 @@ int main(int argc, char **argv)
         {"roi", required_argument, NULL, 'c'},
         {"rotation", required_argument, NULL, 'r'},
         {"mirror", required_argument, NULL, 'm'},
+        {"scaleH", required_argument, NULL, 'H'},
+        {"scaleV", required_argument, NULL, 'V'},
         {NULL, no_argument, NULL, 0},
     };
     char *shortOpt = "i:o:f:c:r:m:";
@@ -288,6 +292,12 @@ int main(int argc, char **argv)
         case 'm':
             decodeTestContext->Mirror = atoi(optarg);
             break;
+        case 'H':
+            decodeTestContext->ScaleFactorH = atoi(optarg);
+            break;
+        case 'V':
+            decodeTestContext->ScaleFactorV = atoi(optarg);
+            break;
         case 'h':
         default:
             help();
@@ -433,6 +443,19 @@ int main(int argc, char **argv)
         OMX_SetConfig(hComponentDecoder, OMX_IndexConfigCommonMirror, &MirrorConfig);
     }
 
+    /* Set Scale config setting*/
+    if(decodeTestContext->ScaleFactorH || decodeTestContext->ScaleFactorV)
+    {
+        OMX_CONFIG_SCALEFACTORTYPE ScaleConfig;
+        OMX_INIT_STRUCTURE(ScaleConfig);
+        ScaleConfig.nPortIndex = 1;
+        OMX_GetConfig(hComponentDecoder, OMX_IndexConfigCommonScale, &ScaleConfig);
+        /* in Q16 format */
+        ScaleConfig.xWidth = (1 << 16) >> (decodeTestContext->ScaleFactorH & 0x3);
+        ScaleConfig.xHeight = (1 << 16) >> (decodeTestContext->ScaleFactorV & 0x3);
+        OMX_SetConfig(hComponentDecoder, OMX_IndexConfigCommonScale, &ScaleConfig);
+    }
+
     OMX_SendCommand(hComponentDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
 
     OMX_PARAM_PORTDEFINITIONTYPE pInputPortDefinition;