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.

ezsdk502 D1 capture

Other Parts Discussed in Thread: TVP5158

hi all

my hardware = evm8168 + vs daughter card

ezsdk = ti-ezsdk_dm816x-evm_5_02_01_59

frist question >

       Does openmax support  SD video capture from VS daughter card (TVP5158) in the ezsdk ?

second question >

       this is my source of  VFCC comp confiigure to capture one channel  PAL D1 video to il client.

      but  it stop semp_pend (pAppData->capILComp->done_sem);

       is it wrong to my VFCC & CTRLTVP configure ?

..................................................................................................................................

/* Main IL Client application to create , intiate and connect components */
int Capture_Encode_Example (IL_ARGS *args)
{
  IL_Client *pAppData = NULL; 
  OMX_U32 i, j;
  OMX_S32 ret_value;
  IL_CLIENT_PIPE_MSG pipeMsg;
  IL_CLIENT_OUTPORT_PARAMS *outPortParamsPtr = NULL;
  OMX_ERRORTYPE eError = OMX_ErrorNone;
  char FileNamebuf [OMX_MAX_STRINGNAME_SIZE];
  OMX_STRING outFileName = "channel";
  /* Initialize application specific data structures and buffer management data */
  IL_ClientInit (&pAppData, args->mode, args->frame_rate, args->bit_rate, args->num_frames);

  printf (" openeing file \n");
  // Open the file of data to be rendered. 
  for (j = 0; j < pAppData->capILComp->numOutport; j++)
  {
 memset ( FileNamebuf, 0x0, sizeof ( FileNamebuf ) ); 
 snprintf ( FileNamebuf, (sizeof(FileNamebuf)-1), "%s_%d", outFileName,  j);
 pAppData->fOut[j] = fopen (FileNamebuf, "wb");
 printf ("open the file %s_%d for writing \n",outFileName, j );
 if (pAppData->fOut[j] == NULL)
   {
      printf ("Error: failed to open the file %s_%d for writing \n", outFileName, j );
      goto EXIT;
   }
  }
 
  /* Initialize application / IL Client callback functions */
  /* Callbacks are passed during getHandle call to component, component uses
     these callabacks to communicate with IL Client */
  /* event handler is to handle the state changes , omx commands and any message for IL client */
  pAppData->pCb.EventHandler = IL_ClientCbEventHandler;

  /* Empty buffer done is data callback at the input port, where component let
     the application know that buffer has been consumed, this is not applicabel
     if there is no input port in the component */
  pAppData->pCb.EmptyBufferDone = IL_ClientCbEmptyBufferDone;

  /* fill buffer done is callback at the output port, where component lets the
     application know that an output buffer is available with the processed data */
  pAppData->pCb.FillBufferDone = IL_ClientCbFillBufferDone;

/******************************************************************************/
  /* Create the capture Component, component handle would be returned component
     name is unique and fixed for a componnet, callback are passed to
     component in this function. component would be in loaded state post this call */
  eError = OMX_GetHandle (&pAppData->pCapHandle, (OMX_STRING) "OMX.TI.VPSSM3.VFCC", pAppData->capILComp, &pAppData->pCb);
  printf (" capture compoenent is created \n");
  if ((eError != OMX_ErrorNone) || (pAppData->pCapHandle == NULL))
  {
    printf ("Error in Get Handle function : %s \n", IL_ClientErrorToStr (eError));
    goto EXIT;
  }

  pAppData->capILComp->handle = pAppData->pCapHandle;
  /* This is control component, without ports. It is implemented as OMXcomponent */
  eError = OMX_GetHandle (&pAppData->pTvpHandle, (OMX_STRING) "OMX.TI.VPSSM3.CTRL.TVP", pAppData->capILComp, &pAppData->pCb);
  printf (" control TVP compoenent is created \n");
  if ((eError != OMX_ErrorNone) || (pAppData->pTvpHandle == NULL))
  {
    printf ("Error in Get Handle function : %s \n", IL_ClientErrorToStr (eError));
    goto EXIT;
  }
  /* Configute the capture componet *//* calling OMX_Setparam in this function */
  IL_ClientSetCaptureParams (pAppData);

  printf ("enable capture output port \n");
  for (j = 0; j < pAppData->capILComp->numOutport; j++)
  {
 OMX_SendCommand (pAppData->pCapHandle, OMX_CommandPortEnable, OMX_VFCC_OUTPUT_PORT_START_INDEX + j, NULL);
   semp_pend (pAppData->capILComp->port_sem);
  }
/******************************************************************************/

  /* OMX_SendCommand expecting OMX_StateIdle, after this command component will
     wait for all buffers to be allocated as per omx buffers are created during
     loaded to Idle transition IF ports are enabled ) */
  eError = OMX_SendCommand (pAppData->pTvpHandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
  if (eError != OMX_ErrorNone)
  {
    printf ("Error in SendCommand()-OMX_StateIdle State set : %s \n", IL_ClientErrorToStr (eError));
    goto EXIT;
  }
  semp_pend (pAppData->capILComp->done_sem);

  eError = OMX_SendCommand (pAppData->pCapHandle, OMX_CommandStateSet, OMX_StateIdle, NULL);
  if (eError != OMX_ErrorNone)
  {
    printf ("Error in SendCommand()-OMX_StateIdle State set : %s \n", IL_ClientErrorToStr (eError));
    goto EXIT;
  }
  /* Allocate I/O Buffers; componnet would allocated buffers and would return the buffer header containing the pointer to buffer */
  for (j = 0; j < pAppData->capILComp->numOutport; j++)
  {
    outPortParamsPtr = pAppData->capILComp->outPortParams + j; /* buffer alloaction for output port */
    for (i = 0; i < outPortParamsPtr->nBufferCountActual; i++)
    {
      eError = OMX_AllocateBuffer (pAppData->pCapHandle, &outPortParamsPtr->pOutBuff[i], OMX_VFCC_OUTPUT_PORT_START_INDEX + j,
       pAppData, outPortParamsPtr->nBufferSize);
      if (eError != OMX_ErrorNone)
      {
        printf("Error in OMX_AllocateBuffer()-Output Port State set : %s \n", IL_ClientErrorToStr (eError));
        goto EXIT;
      }//end if
    }//end for i
  }//end for j
  printf (" Capture outport buffers allocated \n ");
  semp_pend (pAppData->capILComp->done_sem);
  printf (" Capture is in IDLE state \n");
/******************************************************************************/
  /* change state to execute so that buffers processing can start */
  eError = OMX_SendCommand (pAppData->pCapHandle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
  if (eError != OMX_ErrorNone)
  {
    printf ("Error from SendCommand-Executing State set :%s \n", IL_ClientErrorToStr (eError));
    goto EXIT;
  }
  semp_pend (pAppData->capILComp->done_sem);
  printf (" capture state execute \n ");
  eError = OMX_SendCommand (pAppData->pTvpHandle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
  if (eError != OMX_ErrorNone)
  {
    printf ("Error from SendCommand-Executing State set :%s \n", IL_ClientErrorToStr (eError));
    goto EXIT;
  }
  semp_pend (pAppData->capILComp->done_sem);
  printf (" capture control ( TVP ) state execute \n ");
/******************************************************************************/
  /* Create thread for writing bitstream and passing the buffers to encoder component */
  pthread_attr_init (&pAppData->capILComp->ThreadAttr);
  if (0 != pthread_create (&pAppData->capILComp->outDataStrmThrdId, &pAppData->capILComp->ThreadAttr, IL_ClientOutputBitStreamWriteTask, pAppData))
  {
    printf ("Create_Task failed !");
    goto EXIT;
  }
  printf (" file write thread created \n ");
  printf (" executing the application now!! \n");

/******************************************************************************/

void IL_ClientInit (IL_Client **pAppData, char *mode, int frameRate,
                    int bitRate, int numFrames)
{
  int i ;
  IL_Client *pAppDataPtr;
  IL_CLIENT_INPORT_PARAMS *inPortParamsPtr;
  IL_CLIENT_OUTPORT_PARAMS *outPortParamsPtr;

  /* Allocating data structure for IL client structure / buffer management */

  pAppDataPtr = (IL_Client *) malloc (sizeof (IL_Client));
  memset (pAppDataPtr, 0x0, sizeof (IL_Client));

  /* update the user provided parameters */
  pAppDataPtr->nFrameRate = 60;
  //pAppDataPtr->nBitRate = bitRate;
  pAppDataPtr->nEncodedFrms = 100;
  pAppDataPtr->nWidth =  720;
  pAppDataPtr->nHeight = 288; 

  /* alloacte data structure for each component used in this IL Client */
  pAppDataPtr->capILComp = (IL_CLIENT_COMP_PRIVATE *) malloc (sizeof (IL_CLIENT_COMP_PRIVATE));
  memset (pAppDataPtr->capILComp, 0x0, sizeof (IL_CLIENT_COMP_PRIVATE));

  /* these semaphores are used for tracking the callbacks received from
     component */
  pAppDataPtr->capILComp->eos = malloc (sizeof (semp_t));
  semp_init (pAppDataPtr->capILComp->eos, 0);

  pAppDataPtr->capILComp->done_sem = malloc (sizeof (semp_t));
  semp_init (pAppDataPtr->capILComp->done_sem, 0);

  pAppDataPtr->capILComp->port_sem = malloc (sizeof (semp_t));
  semp_init (pAppDataPtr->capILComp->port_sem, 0);

  /* number of ports for each component, which this IL client will handle, this
     will be equal to number of ports supported by component or less */
  pAppDataPtr->capILComp->numInport = 0;
  /* capture does not has i/p ports */
  pAppDataPtr->capILComp->numOutport = 16;
  pAppDataPtr->capILComp->startOutportIndex = 0;
  pAppDataPtr->capILComp->numFrames = 100;
  /* allocate data structure for input and output port params of IL client
     component, It is for maintaining data structure in IL Client only.
     Components will have its own data structure inside omx components */

  pAppDataPtr->capILComp->outPortParams = malloc (sizeof (IL_CLIENT_OUTPORT_PARAMS) * pAppDataPtr->capILComp->numOutport);
  memset (pAppDataPtr->capILComp->outPortParams, 0x0, sizeof (IL_CLIENT_OUTPORT_PARAMS) * pAppDataPtr->capILComp->numOutport);

  /* specify some of the parameters, that will be used for initializing OMX
     component parameters */
  for (i = 0; i < pAppDataPtr->capILComp->numOutport; i++)
  {
    outPortParamsPtr = pAppDataPtr->capILComp->outPortParams + i;
    outPortParamsPtr->nBufferCountActual = IL_CLIENT_CAPTURE_OUTPUT_BUFFER_COUNT;
    outPortParamsPtr->nBufferSize = (pAppDataPtr->nHeight * pAppDataPtr->nWidth * 2) ;
    /* this pipe will be used in this application, as capture does not read / write into file */
    pipe (outPortParamsPtr->opBufPipe);
  }
  /* each componet will have local pipe to take buffers from other component or
     its own consumed buffer, so that it can be passed to other connected components */
  pipe (pAppDataPtr->capILComp->localPipe);
   /* populate the pointer for allocated data structure */
  *pAppData = pAppDataPtr;
}

---------------------------------------------------------------------------------------------------------------------------------------

/* ========================================================================== */
/**
* IL_ClientSetDeiParams() : Function to fill the port definition
* structures and call the Set_Parameter function on to the Capture
* Component
*
* @param pAppData   : Pointer to the application data
*
*  @return     
*  OMX_ErrorNone = Successful
*
*  Other_value = Failed (Error code is returned)
*
*/
/* ========================================================================== */

OMX_ERRORTYPE IL_ClientSetCaptureParams (IL_Client *pAppData)
{

  int i ;

  OMX_PARAM_VFCC_HWPORT_PROPERTIES sHwPortParam;

  OMX_PARAM_VFCC_HWPORT_ID sHwPortId;

  OMX_CONFIG_VFCC_FRAMESKIP_INFO sCapSkipFrames;

  OMX_PARAM_CTRL_VIDDECODER_INFO sVidDecParam;

  OMX_PARAM_BUFFER_MEMORYTYPE memTypeCfg;

  OMX_PARAM_PORTDEFINITIONTYPE paramPort;

  OMX_CONFIG_CHANNELNAME sChannelName;

  OMX_STRING   szchannelName = "channel" ;

  char channelName [OMX_MAX_STRINGNAME_SIZE + 1];

  OMX_ERRORTYPE eError = OMX_ErrorNone;

  OMX_INIT_PARAM (&paramPort);

// set OMX_PARAM_PORTDEFINITIONTYPE output height/width and color format
  {
   for( i=0; i<pAppData->capILComp->numOutport; i++ )
   {
    paramPort.nPortIndex = OMX_VFCC_OUTPUT_PORT_START_INDEX + i ;
    OMX_GetParameter (pAppData->pCapHandle, OMX_IndexParamPortDefinition,&paramPort);
    paramPort.nPortIndex = OMX_VFCC_OUTPUT_PORT_START_INDEX + i ;
    paramPort.format.video.nFrameWidth = pAppData->nWidth;
    paramPort.format.video.nFrameHeight = pAppData->nHeight;
    paramPort.format.video.nStride = pAppData->nWidth * 2 ;
    paramPort.nBufferCountActual = IL_CLIENT_CAPTURE_OUTPUT_BUFFER_COUNT;
    paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
    /* Capture output in 422 format */
    paramPort.format.video.eColorFormat = OMX_COLOR_FormatYCbYCr;
    paramPort.nBufferSize = (paramPort.format.video.nStride * pAppData->nHeight ) ;
    printf ("Buffer Size computed: %d\n", paramPort.nBufferSize);
    printf ("set output port params (width = %d, height = %d)", pAppData->nWidth, pAppData->nHeight);
    OMX_SetParameter (pAppData->pCapHandle, OMX_IndexParamPortDefinition, & paramPort); 
    /* Setting Memory type at output port to Raw Memory */
    OMX_INIT_PARAM (&memTypeCfg);
    memTypeCfg.nPortIndex = OMX_VFCC_OUTPUT_PORT_START_INDEX + i ;
    memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT;
    eError = OMX_SetParameter (pAppData->pCapHandle, OMX_TI_IndexParamBuffMemType, & memTypeCfg);
    if (eError != OMX_ErrorNone)
       ERROR ("failed to set memory Type at output port\n");
  //Create Channel Name 
  memset ( channelName, 0x0, sizeof ( channelName ) );
  OMX_INIT_PARAM (&sChannelName);
  snprintf ( channelName, OMX_MAX_STRINGNAME_SIZE, "%s_%d", szchannelName,  i);
  channelName[OMX_MAX_STRINGNAME_SIZE] = '\0';
  // Configure the Channel Name                                           
  sChannelName.nPortIndex =  OMX_VFCC_OUTPUT_PORT_START_INDEX + i ;
  OMX_UTL_Strncpy ( ( char * ) sChannelName.cChannelName, channelName, sizeof ( sChannelName.cChannelName ) );
  eError = OMX_SetConfig ( pAppData->pCapHandle, ( OMX_INDEXTYPE ) OMX_TI_IndexConfigChannelName, &sChannelName );
  if (eError != OMX_ErrorNone)
   ERROR ("failed to set Capture channel \n");
   }//end for
  }

// set OMX_VIDEO_CaptureHWPortALL_PORTS
  {
   OMX_INIT_PARAM (&sHwPortId);
   /* capture on EIO card is component input at VIP1 port */
   sHwPortId.eHwPortId = OMX_VIDEO_CaptureHWPortALL_PORTS;
   eError = OMX_SetParameter (pAppData->pCapHandle, (OMX_INDEXTYPE) OMX_TI_IndexParamVFCCHwPortID, (OMX_PTR) & sHwPortId);
  }
// set OMX_PARAM_VFCC_HWPORT_PROPERTIES
  {
   OMX_INIT_PARAM (&sHwPortParam);
   sHwPortParam.eCaptMode = OMX_VIDEO_CaptureModeMC_PEL_MUX;
   sHwPortParam.eVifMode = OMX_VIDEO_CaptureVifMode_08BIT;
   sHwPortParam.eInColorFormat = OMX_COLOR_FormatYCbYCr;
   sHwPortParam.eScanType = OMX_VIDEO_CaptureScanTypeInterlaced;
   sHwPortParam.nMaxHeight = pAppData->nHeight;
   sHwPortParam.nMaxWidth = pAppData->nWidth;
   sHwPortParam.nMaxChnlsPerHwPort = 4;
   eError = OMX_SetParameter (pAppData->pCapHandle, (OMX_INDEXTYPE)OMX_TI_IndexParamVFCCHwPortProperties, (OMX_PTR) & sHwPortParam);
  }
// set OMX_CONFIG_VFCC_FRAMESKIP_INFO
  {
   if (pAppData->nFrameRate == 30)
   {
     OMX_INIT_PARAM (&sCapSkipFrames);
     printf (" applying skip mask \n");
     sCapSkipFrames.frameSkipMask = 0x2AAAAAAA;
     eError = OMX_SetConfig (pAppData->pCapHandle,(OMX_INDEXTYPE) OMX_TI_IndexConfigVFCCFrameSkip,(OMX_PTR) & sCapSkipFrames);
   }//end if
  }

/*-----------Set parameters for TVP controller-----------------*/

// set OMX_VIDEO_CaptureHWPortALL_PORTS
  {
   OMX_INIT_PARAM (&sHwPortId);
   /* capture on EIO card is component input at VIP1 port */
   sHwPortId.eHwPortId = OMX_VIDEO_CaptureHWPortALL_PORTS;
   eError = OMX_SetParameter (pAppData->pTvpHandle,(OMX_INDEXTYPE) OMX_TI_IndexParamVFCCHwPortID,(OMX_PTR) & sHwPortId);
  }
// set OMX_PARAM_VFCC_HWPORT_PROPERTIES
  {
   OMX_INIT_PARAM (&sHwPortParam);
   sHwPortParam.eCaptMode = OMX_VIDEO_CaptureModeMC_PEL_MUX;
   sHwPortParam.eVifMode = OMX_VIDEO_CaptureVifMode_08BIT;
   sHwPortParam.eInColorFormat = OMX_COLOR_FormatYCbYCr;
   sHwPortParam.eScanType = OMX_VIDEO_CaptureScanTypeInterlaced;
   sHwPortParam.nMaxHeight = pAppData->nHeight;
   sHwPortParam.nMaxWidth = pAppData->nWidth;
   sHwPortParam.nMaxChnlsPerHwPort = 4;
   eError = OMX_SetParameter (pAppData->pTvpHandle, (OMX_INDEXTYPE) OMX_TI_IndexParamVFCCHwPortProperties, (OMX_PTR) & sHwPortParam);
  }
// set OMX_PARAM_CTRL_VIDDECODER_INFO
  {
   OMX_INIT_PARAM (&sVidDecParam);
   /* set the mode based on capture/display device */
   sVidDecParam.videoStandard = OMX_VIDEO_DECODER_STD_MUX_4CH_D1 ;
   /* setting TVP5158  input */
   sVidDecParam.videoDecoderId = OMX_VID_DEC_TVP5158_DRV;
   sVidDecParam.videoSystemId = OMX_VIDEO_DECODER_VIDEO_SYSTEM_PAL;
   eError = OMX_SetParameter (pAppData->pTvpHandle, (OMX_INDEXTYPE) OMX_TI_IndexParamCTRLVidDecInfo, (OMX_PTR) & sVidDecParam);
   if (eError != OMX_ErrorNone)
    ERROR ("failed to set Ctrl Vid dec info \n");
  }
}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------


/* ========================================================================== */
/**
* IL_ClientEncUseInitialOutputResources() :  This function gives initially all
*                                         output buffers to a component.
*                                         after consuming component would keep
*                                         in local pipe for connect thread use.
*
* @param pAppdata   : application data structure
*
*  @return     
*  String conversion of the OMX_ERRORTYPE
*
*/
/* ========================================================================== */

OMX_ERRORTYPE IL_ClientEncUseInitialOutputResources (IL_CLIENT_COMP_PRIVATE
                                                       *thisComp)
{
  IL_CLIENT_OUTPORT_PARAMS *outPortParamsPtr = NULL;
  OMX_ERRORTYPE err = OMX_ErrorNone;
  unsigned int i, j ;
  for (j = 0; j < thisComp->numOutport; j++)
  {
   outPortParamsPtr = thisComp->outPortParams + j;
 for (i = 0; i < outPortParamsPtr->nBufferCountActual; i++)
 {
    /* Pass the output buffer to the component */
    err = OMX_FillThisBuffer (thisComp->handle, outPortParamsPtr->pOutBuff[i]);
 }
  }
  return err;
}

 

thank you for any help

  • hi all 

     does openmax in the ezsdk502 support NTSC/PAL D1 capture ?

    thank you for any help 

  • Hi,

       EZSDK 5_02_01_59 version was not tested with VS daughter card. We support only Catalog daughter cad and VC daughter card with this release. We are not supporting VS applications any more with EZSDK, we need to move to a new multichannel frame work called RDK.

    regards,

    Venkat

     

  • Hi Venkat,

    I am trying to capture second video stream using OPENMAX by J2,J3,J4 interface in the EZSDK EVM 816x board. Though the current EZSDK only support one video stream capture, I think it is possible to reprogram its program to capture the second one or multichannel. Of course the RDK is good stuff. Do you have any plan to add program to the EZSDK for multiple video capture?

     

    Thanks.

    George

  • Hi Jim,

     

    Based on some information I read, I think, right now EZSDK502 software can only support one channel 1080p or 720p HD capture.

     

     

    George 

  • jim,

    is it right?

     

     sHwPortId.eHwPortId = OMX_VIDEO_CaptureHWPortALL_PORTS;

    cause the values usually are OMX_VIDEO_CaptureHWPortVIP1_PORTA or OMX_VIDEO_CaptureHWPortVIP2_PORTA. Do you any further progress, want to share.

     

    thanks.

     

    George

  • Hi Jim,

    I'm also trying to do Multi-channel NTSC capture from TVP5158 through ezsdk_dm814x-evm_5_05_01_04 OMX  with below settings

    paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar
    sHwPortId.eHwPortId = OMX_VIDEO_CaptureHWPortVIP1_PORTA
    sHwPortParam.eCaptMode = OMX_VIDEO_CaptureModeMC_LINE_MUX;
    sHwPortParam.eInColorFormat = OMX_COLOR_FormatYCbYCr;
    sHwPortParam.eVifMode = OMX_VIDEO_CaptureVifMode_08BIT;
    sHwPortParam.eScanType = OMX_VIDEO_CaptureScanTypeInterlaced;
    sVidDecParam.videoDecoderId = OMX_VID_DEC_TVP5158_DRV;
    sVidDecParam.videoSystemId = OMX_VIDEO_DECODER_VIDEO_SYSTEM_NTSC;

    but it is failing I'm debugging further ...If you have any update on this issue please let me know...

    Thanks & Regards,

    Rajshekar