This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Encode and decode both working on DM8168

hi Experts,

After acquainting with the example "capture_encode",I try to create my OMX program by modifying this example.

I add a scalar component,a decode component and delete the dei component to realize a program below:

Cap - Enc - Dec - Scaler - Display

Now, my program has been compiled successful, but when I run it on my dm8168evm, the frame rate is so low.

I using resolution = 1920×1080, framerate = 60, bitrate = 1M .

Then, I try to set the parameters to 1080p25 and 50M bitrate, framerate increased, but still dissatisfactory.

Can someone tell me the reason?

  • Can you please check the are control parameters ? I suspect that encoder might be dropping the frames due to wrong rate control parameters.

     

    Regards

    Deepak Poddar

  • I using IL_ClientSetEncodeParams() provided by capture_encode.

    Telnet to evmboard and trace m3 while running my program:

    N:VPSS P:2 #:01099 T:000000162b97616b S:Dropped Frame Count :4 Total Capture Frame Count 1270
    N:VPSS P:2 #:01100 T:0000001985e63d27 S:Dropped Frame Count :4 Total Capture Frame Count 2729
    N:Video P:1 #:00434 T:0000001b874cd091 S:OMX_TI_VIDENC_CB_ProcessDone::Line 4855::omxHandle 0x9dc1dac8::Channel 0::Frames Encoded 3600::FPS 1519
    N:Video P:1 #:00435 T:0000001b87ec4fdd S:OMX_TI_VIDDEC_CB_ProcessDone::Line 2558::omxHandle 0x9dc3da60::Channel 0::Frames Decoded 3600::FPS 1519
    N:VPSS P:2 #:01101 T:0000001ce034dc2d S:Dropped Frame Count :4 Total Capture Frame Count 4187

    OMX_ERRORTYPE IL_ClientSetEncodeParams (IL_Client *pAppData)
    {
      OMX_ERRORTYPE eError = OMX_ErrorUndefined;
      OMX_HANDLETYPE pHandle = NULL;
      OMX_VIDEO_PARAM_PROFILELEVELTYPE tProfileLevel;
      OMX_VIDEO_PARAM_ENCODER_PRESETTYPE tEncoderPreset;
      OMX_VIDEO_PARAM_BITRATETYPE tVidEncBitRate;
      OMX_VIDEO_PARAM_PORTFORMATTYPE tVideoParams;
      OMX_PARAM_PORTDEFINITIONTYPE tPortDef;

      pHandle = pAppData->pEncHandle;

      /* Number of frames to be encoded */
      pAppData->encILComp->numFrames = pAppData->nEncodedFrms;

      /* Set the profile and level for H264 */
      OMX_INIT_PARAM (&tProfileLevel);
      tProfileLevel.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

      eError = OMX_GetParameter (pHandle, OMX_IndexParamVideoProfileLevelCurrent,
                                 &tProfileLevel);

      /* set as baseline 4.2 level */

      tProfileLevel.eProfile = OMX_VIDEO_AVCProfileBaseline;
      tProfileLevel.eLevel = OMX_VIDEO_AVCLevel42;

      eError = OMX_SetParameter (pHandle, OMX_IndexParamVideoProfileLevelCurrent,
                                 &tProfileLevel);
      if (eError != OMX_ErrorNone)
        ERROR ("failed to set encoder profile \n");

      /* Encoder Preset settings */
      OMX_INIT_PARAM (&tEncoderPreset);
      tEncoderPreset.nPortIndex = OMX_VIDENC_OUTPUT_PORT;
      eError = OMX_GetParameter (pHandle, OMX_TI_IndexParamVideoEncoderPreset,
                                 &tEncoderPreset);

      tEncoderPreset.eEncodingModePreset = OMX_Video_Enc_Med_Speed_High_Quality;
      tEncoderPreset.eRateControlPreset = OMX_Video_RC_Low_Delay;

      eError = OMX_SetParameter (pHandle, OMX_TI_IndexParamVideoEncoderPreset,
                                 &tEncoderPreset);
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to Encoder Preset \n");
      }

      OMX_INIT_PARAM (&tPortDef);
      /* Get the Number of Ports */

      tPortDef.nPortIndex = OMX_VIDENC_INPUT_PORT;
      eError = OMX_GetParameter (pHandle, OMX_IndexParamPortDefinition, &tPortDef);
      /* set the actual number of buffers required */
      tPortDef.nBufferCountActual = IL_CLIENT_ENC_INPUT_BUFFER_COUNT;
      /* set the video format settings */
      tPortDef.format.video.nFrameWidth = pAppData->nWidth;
      tPortDef.format.video.nStride = pAppData->nWidth;
      tPortDef.format.video.nFrameHeight = pAppData->nHeight;
      tPortDef.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
      /* settings for OMX_IndexParamVideoPortFormat */
      tPortDef.nBufferSize = (pAppData->nWidth * pAppData->nHeight * 3) >> 1;
      eError = OMX_SetParameter (pHandle, OMX_IndexParamPortDefinition, &tPortDef);
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set Encode OMX_IndexParamPortDefinition for input \n");
      }

      OMX_INIT_PARAM (&tPortDef);

      tPortDef.nPortIndex = OMX_VIDENC_OUTPUT_PORT;
      eError = OMX_GetParameter (pHandle, OMX_IndexParamPortDefinition, &tPortDef);
      /* settings for OMX_IndexParamPortDefinition */
      /* set the actual number of buffers required */
      tPortDef.nBufferCountActual = IL_CLIENT_ENC_OUTPUT_BUFFER_COUNT;
      tPortDef.format.video.nFrameWidth = pAppData->nWidth;
      tPortDef.format.video.nFrameHeight = pAppData->nHeight;
      tPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
      tPortDef.format.video.xFramerate = (pAppData->nFrameRate << 16);
      tVideoParams.xFramerate = (pAppData->nFrameRate << 16);
      tPortDef.format.video.nBitrate = pAppData->nBitRate;
      /* settings for OMX_IndexParamVideoPortFormat */

      eError = OMX_SetParameter (pHandle, OMX_IndexParamPortDefinition, &tPortDef);
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set Encode OMX_IndexParamPortDefinition for output \n");
      }

      /* For changing bit rate following index can be used */
      OMX_INIT_PARAM (&tVidEncBitRate);

      tVidEncBitRate.nPortIndex = OMX_DirOutput;
      eError = OMX_GetParameter (pHandle, OMX_IndexParamVideoBitrate,
                                 &tVidEncBitRate);

      tVidEncBitRate.eControlRate = OMX_Video_ControlRateDisable;
      tVidEncBitRate.nTargetBitrate = pAppData->nBitRate;
      eError = OMX_SetParameter (pHandle, OMX_IndexParamVideoBitrate,
                                 &tVidEncBitRate);

      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set Encode bitrate \n");
      }

      return eError;
    }

  • Can you please try   tEncoderPreset.eRateControlPreset other than OMX_Video_RC_Low_Delay ?

    Regards

    Deepak Poddar

  • I tried these configs:

     OMX_Video_RC_Storage,
     OMX_Video_RC_Twopass,
     OMX_Video_RC_None,
     OMX_Video_RC_User_Defined,

    but still the same.

  • How you are measuring frame rate ? 

     

    Also please check the basic settings and use all default parameters, and problem still persists then please share the elementry H264 stream generated from encoder.

     

    Regards

    Deepak Poddar