Browse Source

sf-omx-il: Add rotation support for codaj12

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

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

@@ -577,6 +577,23 @@ static OMX_ERRORTYPE SF_OMX_GetConfig(
         break;
     }
 
+    case OMX_IndexConfigCommonRotate:
+    {
+        OMX_CONFIG_ROTATIONTYPE *rotatParam = (OMX_CONFIG_ROTATIONTYPE *)pComponentConfigStructure;
+        DecConfigParam *decConfig = pSfMjpegImplement->config;
+        if(rotatParam->nPortIndex == (OMX_U32)(OMX_OUTPUT_PORT_INDEX))
+        {
+            rotatParam->nRotation = decConfig->rotation;
+            LOG(SF_LOG_INFO, "Get Rotation %d \r\n", decConfig->rotation);
+        }
+        else
+        {
+            LOG(SF_LOG_WARN, "Only output port support Rotation config\r\n");
+            ret = OMX_ErrorBadParameter;
+        }
+        break;
+    }
+
     default:
         break;
     }
@@ -635,6 +652,23 @@ static OMX_ERRORTYPE SF_OMX_SetConfig(
         break;
     }
 
+    case OMX_IndexConfigCommonRotate:
+    {
+        OMX_CONFIG_ROTATIONTYPE *rotatParam = (OMX_CONFIG_ROTATIONTYPE *)pComponentConfigStructure;
+        DecConfigParam *decConfig = pSfMjpegImplement->config;
+        if(rotatParam->nPortIndex == (OMX_U32)(OMX_OUTPUT_PORT_INDEX))
+        {
+            decConfig->rotation = rotatParam->nRotation;
+            LOG(SF_LOG_INFO, "Set Rotation %d to output port\r\n", decConfig->rotation);
+        }
+        else
+        {
+            LOG(SF_LOG_WARN, "Only support set Rotation config to output port\r\n");
+            ret = OMX_ErrorBadParameter;
+        }
+        break;
+    }
+
     default:
         break;
     }

+ 29 - 10
soft_3rdpart/omx-il/tests/mjpeg_dec_test.c

@@ -47,6 +47,7 @@ typedef struct DecodeTestContext
     OMX_S32 RoiTop;
     OMX_U32 RoiWidth;
     OMX_U32 RoiHeight;
+    OMX_U32 Rotation;
 } DecodeTestContext;
 DecodeTestContext *decodeTestContext;
 static OMX_S32 FillInputBuffer(DecodeTestContext *decodeTestContext, OMX_BUFFERHEADERTYPE *pInputBuffer);
@@ -207,9 +208,10 @@ int main(int argc, char **argv)
         {"input", required_argument, NULL, 'i'},
         {"format", required_argument, NULL, 'f'},
         {"roi", required_argument, NULL, 'c'},
+        {"rotation", required_argument, NULL, 'r'},
         {NULL, no_argument, NULL, 0},
     };
-    char *shortOpt = "i:o:f:c:";
+    char *shortOpt = "i:o:f:c:r:";
     OMX_U32 c;
     OMX_S32 l;
     OMX_STRING val;
@@ -278,6 +280,9 @@ int main(int argc, char **argv)
                 decodeTestContext->RoiHeight = atoi(val);
             }
             break;
+        case 'r':
+            decodeTestContext->Rotation = atoi(optarg);
+            break;
         case 'h':
         default:
             help();
@@ -388,15 +393,29 @@ int main(int argc, char **argv)
     OMX_SetParameter(hComponentDecoder, OMX_IndexParamPortDefinition, &pOutputPortDefinition);
 
     /* Set Roi config setting*/
-    OMX_CONFIG_RECTTYPE RectConfig;
-    OMX_INIT_STRUCTURE(RectConfig);
-    RectConfig.nPortIndex = 1;
-    OMX_GetConfig(hComponentDecoder, OMX_IndexConfigCommonOutputCrop, &RectConfig);
-    RectConfig.nLeft = decodeTestContext->RoiLeft;
-    RectConfig.nTop = decodeTestContext->RoiTop;
-    RectConfig.nWidth = decodeTestContext->RoiWidth;
-    RectConfig.nHeight = decodeTestContext->RoiHeight;
-    OMX_SetConfig(hComponentDecoder, OMX_IndexConfigCommonOutputCrop, &RectConfig);
+    if(decodeTestContext->RoiWidth && decodeTestContext->RoiHeight)
+    {
+        OMX_CONFIG_RECTTYPE RectConfig;
+        OMX_INIT_STRUCTURE(RectConfig);
+        RectConfig.nPortIndex = 1;
+        OMX_GetConfig(hComponentDecoder, OMX_IndexConfigCommonOutputCrop, &RectConfig);
+        RectConfig.nLeft = decodeTestContext->RoiLeft;
+        RectConfig.nTop = decodeTestContext->RoiTop;
+        RectConfig.nWidth = decodeTestContext->RoiWidth;
+        RectConfig.nHeight = decodeTestContext->RoiHeight;
+        OMX_SetConfig(hComponentDecoder, OMX_IndexConfigCommonOutputCrop, &RectConfig);
+    }
+
+    /* Set Rotation config setting*/
+    if(decodeTestContext->Rotation)
+    {
+        OMX_CONFIG_ROTATIONTYPE RotatConfig;
+        OMX_INIT_STRUCTURE(RotatConfig);
+        RotatConfig.nPortIndex = 1;
+        OMX_GetConfig(hComponentDecoder, OMX_IndexConfigCommonRotate, &RotatConfig);
+        RotatConfig.nRotation = decodeTestContext->Rotation;
+        OMX_SetConfig(hComponentDecoder, OMX_IndexConfigCommonRotate, &RotatConfig);
+    }
 
     OMX_SendCommand(hComponentDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);