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.

SD Display Support in EZSDk 5.04

Hi ,

I am working on DM8148 EVM board .I am using latest EZSDK 5.04 .

As per the OMX Release notes ,its mentioned that SD display is supported  . I am using the OMX capture_encode application to capture 1080P component video ,scale it down to SD resolution NTSC (720 x 480 ) and display the composite video .

I am scaling the component video 1080P to SD (720 x480) using DEI component and giving it to the VFDC component .

In the SetDisplayParams() function ,I have made the changes

driverId.nDrvInstID = OMX_VIDEO_DISPLAY_ID_SD0;
 driverId.eDispVencMode = OMX_DC_MODE_NTSC;

I have gone through the OMX display example and made relevant changes for SD display .

The problem  is that ,composite display is not proper ,color component is missing . Its a monochrome display filled with lot of noise at the edges .

It seems to be the video is not scaled to the resolution 720x480 ,DEI component can do the scaling ,but in this case i don't see the video scaled .

Can anyone help me for SD display in EZSDK 5_04 ?am I missing out any step ?any help is appreciated .

Thanks,

Siva .

  • Hi ,

    I have tried SD display with the OMX display example too .Still I cant see the display clearly .Colors are missing .

    I am providing a raw YUV file (NTSC resolution yuv420sp format ) as a input file to the OMX display example .

    Is the SD display is supported in EZSDK 5.04 ?why the colors are missing ?what's the pixel format thats supported by SD display ? i have tried both YUV422I and YUV420SP .

    Has anyone tried SD display ?any help is appreciated .

    Thanks,

    Siva .

  • Are you using the composite or S-Video output?  By default, the board is set up for S-Video output.  If you're using the composite output with it configured for S-Video, that might explain why you're seeing only the luma data.

    If this seems to be the issue, try the following before running the demo:

    root@dm814x-evm:~# echo 0 > /sys/devices/platform/vpss/display2/enabled
    root@dm814x-evm:~# echo "composite" > /sys/devices/platform/vpss/display2/output
    root@dm814x-evm:~# echo 1 > /sys/devices/platform/vpss/display2/enabled

    Unfortunately, I'm not sure about the scalar issue.  I'm currently having issues getting a 480x480 video centered on the SD output (or anything other than 720x480 for that matter).  As far as I can tell the display frame & buffer size is only set in the following lines.  If you get your setup working, mind trying to scale/crop your video to 480x480 or 320x320 and letting me know if it works?

        paramPort.format.video.nFrameWidth = SD_WIDTH;
        paramPort.format.video.nFrameHeight = SD_HEIGHT;
        paramPort.format.video.nStride = SD_WIDTH;   

        ...

       if (2 == pAppData->displayId)
       {
        /* The SD display accepts 420SP buffers at input port*/
        paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
        paramPort.nBufferSize = ((paramPort.format.video.nStride *
                                 paramPort.format.video.nFrameHeight) * 3 ) >> 1;
       }

    Regards,

    Jon


  • Hi Jon ,

    Thanks for the reply . Now I can see the colors on the composite display ,as you said I changed the display2 output to "composite" .

    As I mentioned in the above posts ,using capture_encode OMX example ,I still don't see the SD display clearly . The SD display is not scaled to NTSC resolution (720 x 486) and I see the broad lines on the video .I am not seeing the actual colors  .

    Have you tried SD display (720 x 486) using capture_encode example ? if not ,Can you try it out and tell me whether SD display is proper or not .

    Also ,Can you please try with OMX display example and tell me whether SD display is proper or not .

    Thanks,

    Siva .

  • Hi Siva,

    Would you mind sending your OMX Display Demo input test file (the YUV420 input) and Capture-Encode modifications (for SD display) my way?

    My schedule is a bit tight this week, so having something to quickly work would help me test those items and report back in a more timely manner.  I only have an NTSC television (not widescreen), so my results likely will vary a bit...

    Regards,

    Jon

  • Hi Jon,

    I am attaching the capture_encode OMX example modified for SD display .

    I can't attach the raw yuv420 file ,as its of 180MB size . If possible ,can you test the OMX  display example with the yuv files you got .

    Thanks,

    Siva .

    4101.capture_encode.tar.gz

  • Hi Siva,

    Thanks for the modified demo. I'll try to get this up and running later this week and at least report back by next Monday (hopefully much earlier).  Sorry for the delay -- currently debugging another set of issues on the device. ;)

    Regarding the  YUV420SP file -- did you generate some sort of test pattern?  I just have a little program to generate some vertical bars and increment the chroma values on successive frames....will try that again later.

    Regards,

    Jon

  • Hi Jon,

    I have downloaded the YUV422 file and converted that to YUV420SP format using ffmpeg . Do you have any web links where I can download YUV420SP files ?

    I suspect the ffmpeg tool is not converting properly YUV422 file to YUV420SP format .

    Can you please test the capture_encode example for SD display asap? Its kind of urgent requirement for me .

    Thanks,

  • Siva,

    I tried running the Capture-Encode demo you attached, but wasn't having any luck with it  -- I was receiving an OMX_ErrorUndefined event, indicating that something was misconfigured for my setup. (I changed it to 720p input).  Also note that the mosaic layout is not supported for the SD output. (Although, I'm not sure if there are consequences to making those calls.)  I'm afraid I won't be able to look into that error further this week...hopefully someone from TI might comment on the status of SD display output.

    As far as the YUV420SP input, I was just generating my own.  (If I understand correctly, it's just a  plane of luma, then subsampled CbCr).  However, I'm not seeing anything being displayed correctly with the Display demo, so either something's wrong with my SD setup or my test pattern generator...I have yet to determine this. 

    As I mentioned earlier, my TV is 640x480 (I think...), so I'm wondering if I need to reconfigure display timings in the following sysfs entry:

    root@dm814x-evm:~# cat /sys/devices/platform/vpss/display2/timings
    54000,720/12/68/64,480/5/41/5,0


    Regards,

    Jon

    [UPDATE] I just noticed that your DEI inputs are pulling frame sizes from pAppData->nWidth/nHeight.  It looks like you're scaling in the VFCC (since I see the use of SD_WIDTH/HEIGHT here), so make sure the dimensions of your VFCC output and your DEI input match...that could certainly cause some problems.

  • Jon,

    I checked the SetCapture Params ,I am not scaling in VFCC component  . I am doing scaling at the output of DEI Port 0 ,which is connected to VFDC  component . Please check it again .

    Can you try to do changes in your own code for SD display and check for SD display .

    Thanks,

    Siva .

  • Siva,


    My apologies, you're right. I had been skimming too quickly.  I looked again more carefully, and everything you changed makes sense to me. The only other changes I made were to set  driverId.eDispVencMode to  OMX_DC_MODE_NTSC  when running in 720p mode.  (I didn't realize you could even do 1080p over component video...my DVD player supports only up to 720p on component).

    I am now able to run your code. (For the record, the issue was that I had the i2c mode set to 0 instead of 1 in my load_hd_firmware.sh. If anyone happens to run into this, the symptom you'll see is an OMX_ErrorUndefined in the event callback when attempting to put the TVP component in the IDLE state).

    Here's a rundown of what I see...it looks like I'm having some issues similar to those that you described in your first two posts...

    • As far as I can tell on my non-widescreen TV, the luma looks correct.
    • I think it is scaled OK...but again, my TV can only really show < 640 of the 720 width.
    • I do not see the chroma data, despite having set /sys/devices/platform/vpss/display2/output to "composite"
    • I see a lot of noise (red, green, and blue...pretty sure this is not my chroma data though)

    Perhaps someone from TI might be able to give us a few clues on this.

    [UPDATE]  So I was able to get access to a widescreen TV with S-Video input, so I tested Siva's code with this setup as well.  I seem to only get half the width of the scaled image, and it looks like there's vertical lines of some other data.  Does this sound like an output format issue to anyone else?  Has anyone else gotten YUV420SP out of the first DEI output successfully?

    I guess a good next step would be to save off a frame coming out of the DEI or into the SD display and inspect it offline to double check whether it's actually YUV420SP. 

    Siva -- if you get around to saving off one of those frames before I do later this week, would you mind posting it here (with the height and width noted).

  • Hi,

    we have figured out a limitation in sdk 5411, where It can support only 720x480 display for SD output. For other resolution, it would try to read data as 720x480, and display would not be fine. we will resolve this issue in next release. It requires change in firmware. 

    Regards

    Vimal

  • Vimal,

    Do you see any issues with the code Siva posted? That should be scaling its input to 720x480 YUV420SP, using the first output.  Is YUV420SP known to work on that first DEI output (output index 0)?

    Attached are my changes to Siva's modifications to the demo, which configures the SD display when run with -m 720p, and removes the mosaic display calls for the SD display. 

    /*
     *  Copyright (c) 2010-2011, Texas Instruments Incorporated
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *  *  Redistributions of source code must retain the above copyright
     *     notice, this list of conditions and the following disclaimer.
     *
     *  *  Redistributions in binary form must reproduce the above copyright
     *     notice, this list of conditions and the following disclaimer in the
     *     documentation and/or other materials provided with the distribution.
     *
     *  *  Neither the name of Texas Instruments Incorporated nor the names of
     *     its contributors may be used to endorse or promote products derived
     *     from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *  Contact information for paper mail:
     *  Texas Instruments
     *  Post Office Box 655303
     *  Dallas, Texas 75265
     *  Contact information:
     *  http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
     *  DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
     *  ============================================================================
     *
     */
    
    #include <stdlib.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <xdc/std.h>
    #include <memory.h>
    #include <getopt.h>
    
    /*-------------------------program files -------------------------------------*/
    #include "ti/omx/interfaces/openMaxv11/OMX_Core.h"
    #include "ti/omx/interfaces/openMaxv11/OMX_Component.h"
    #include "OMX_TI_Common.h"
    #include "OMX_Video.h"
    #include "OMX_TI_Video.h"
    #include "ilclient.h"
    #include "ilclient_utils.h"
    #include "platform_utils.h"
    #include <omx_venc.h>
    #include <omx_vfpc.h>
    #include <omx_vfdc.h>
    #include <omx_ctrl.h>
    #include <omx_vfcc.h>
    #include <OMX_TI_Index.h>
    
    #define SD_WIDTH 720
    #define SD_HEIGHT 486
    
    
    /*---------------------- function prototypes ---------------------------------*/
    /* None */
    
    void usage (IL_ARGS *argsp)
    {
      printf
        ("capture_encode -f <frame_rate> -m <mode>"
         "-b <bit_rate> -o <output_file> -n <num_frames> -d <0/1>\n\n"
         "-o | --output          output filename \n"
         "-m | --mode            1080p / 720p capture/On-chip HDMI display mode \n"
         "-f | --framerate       encode frame rate \n"
         "-b | --bitrate         encode bit rate \n"
         "-n | --numframes       encode number of frames \n"
         "-d | --display_id      0 - for on-chip HDMI, 1 for Secondary display \n");
    
      printf(" example -    ./capture_encode_a8host_debug.xv5T -o sample.h264 -m 1080p -f 60 -b 1000000 -d 0 -n 1000 \n");
      printf(" for 720p, set hdmi mode before running example \n echo 720p-60 >/sys/devices/platform/vpss/display0/mode \n");
      
      exit (1);
    }
    
    /* ========================================================================== */
    /**
    * parse_args() : This function parses the input arguments provided to app.
    *
    * @param argc             : number of args 
    * @param argv             : args passed by app
    * @param argsp            : parsed data pointer
    *
    *  @return      
    *
    *
    */
    /* ========================================================================== */
    
    void parse_args (int argc, char *argv[], IL_ARGS *argsp)
    {
      const char shortOptions[] = "o:f:b:n:m:d:";
      const struct option longOptions[] =
      {
        {"output", required_argument, NULL, ArgID_OUTPUT_FILE},
        {"framerate", required_argument, NULL, ArgID_FRAMERATE},
        {"bitrate", required_argument, NULL, ArgID_BITRATE},
        {"numframes", required_argument, NULL, ArgID_NUMFRAMES},
        {"mode", required_argument, NULL, ArgID_MODE},
        {"display_id", required_argument, NULL, ArgID_DISPLAYID},
        {0, 0, 0, 0}
      };
    
      int index, outfile = 0, mode = 0, nframes = 0;
      int display_id = 0;
      int argID;
    
      for (;;)
      {
        argID = getopt_long (argc, argv, shortOptions, longOptions, &index);
    
        if (argID == -1)
        {
          break;
        }
    
        switch (argID)
        {
          case ArgID_OUTPUT_FILE:
          case 'o':
            strncpy (argsp->output_file, optarg, MAX_FILE_NAME_SIZE);
            outfile = 1;
            break;
          case ArgID_FRAMERATE:
          case 'f':
            argsp->frame_rate = atoi (optarg);
            break;
          case ArgID_BITRATE:
          case 'b':
            argsp->bit_rate = atoi (optarg);
            break;
          case ArgID_NUMFRAMES:
          case 'n':
            argsp->num_frames = atoi(optarg);
            nframes = 1;
            break;
          case ArgID_MODE:
          case 'm':
            strncpy (argsp->mode, optarg, MAX_MODE_NAME_SIZE);
            mode = 1;
            break;
          case ArgID_DISPLAYID:
          case 'd':
            argsp->display_id = atoi (optarg);
            display_id = 1;
            break;
          default:
            usage (argsp);
            exit (1);
        }
      }
    
      if (optind < argc)
      {
        usage (argsp);
        exit (EXIT_FAILURE);
      }
    
      if (argsp->bit_rate == 0 || !outfile || argsp->frame_rate == 0 || !nframes || !mode || !display_id)
      {
        usage (argsp);
        exit (1);
      }
    
      printf ("output file: %s\n", argsp->output_file);
      printf ("bit_rate: %d\n", argsp->bit_rate);
      printf ("frame_rate: %d\n", argsp->frame_rate);
      printf ("num_frames: %d\n", argsp->num_frames);
      printf ("mode: %s\n", argsp->mode);
      printf ("display_id: %d\n", argsp->display_id);
    }
    
    /* ========================================================================== */
    /**
    * IL_ClientInit() : This function is to allocate and initialize the application
    *                   data structure. It is just to maintain application control.
    *
    * @param pAppData          : appliaction / client data Handle 
    * @param width             : stream width
    * @param height            : stream height
    * @param frameRate         : encode frame rate
    * @param bitrate           : encoder bit rate
    * @param numFrames         : encoded number of frames
    * @param displayId         : display instance id
    *
    *  @return      
    *
    *
    */
    /* ========================================================================== */
    
    void IL_ClientInit (IL_Client **pAppData, char *mode, int frameRate,
                        int bitRate, int numFrames, int displayId)
    {
      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 = frameRate;
      pAppDataPtr->nBitRate = bitRate;
      pAppDataPtr->nEncodedFrms = numFrames;
      strncpy ((char *) pAppDataPtr->mode, mode, MAX_MODE_NAME_SIZE);  
      
      /* based on capture/display mode selected set width and height */
      if (strcmp (mode, "1080p") == 0) {
       pAppDataPtr->nHeight = 1080;
       pAppDataPtr->nWidth =  1920; 
      }
      else  if (strcmp (mode, "720p") == 0) {
       pAppDataPtr->nHeight = 720;
       pAppDataPtr->nWidth =  1280; 
      }
      else
      {
        ERROR ("In correct Mode selected!! \n");
      }
      pAppDataPtr->displayId = displayId;
    
      /* 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);
    
      /* alloacte data structure for each component used in this IL Client */
      pAppDataPtr->deiILComp =
        (IL_CLIENT_COMP_PRIVATE *) malloc (sizeof (IL_CLIENT_COMP_PRIVATE));
      memset (pAppDataPtr->deiILComp, 0x0, sizeof (IL_CLIENT_COMP_PRIVATE));
    
      /* these semaphores are used for tracking the callbacks received from
         component */
      pAppDataPtr->deiILComp->eos = malloc (sizeof (semp_t));
      semp_init (pAppDataPtr->deiILComp->eos, 0);
    
      pAppDataPtr->deiILComp->done_sem = malloc (sizeof (semp_t));
      semp_init (pAppDataPtr->deiILComp->done_sem, 0);
    
      pAppDataPtr->deiILComp->port_sem = malloc (sizeof (semp_t));
      semp_init (pAppDataPtr->deiILComp->port_sem, 0);
    
      /* alloacte data structure for each component used in this IL Client */
      pAppDataPtr->encILComp =
        (IL_CLIENT_COMP_PRIVATE *) malloc (sizeof (IL_CLIENT_COMP_PRIVATE));
      memset (pAppDataPtr->encILComp, 0x0, sizeof (IL_CLIENT_COMP_PRIVATE));
    
      /* these semaphores are used for tracking the callbacks received from
         component */
      pAppDataPtr->encILComp->eos = malloc (sizeof (semp_t));
      semp_init (pAppDataPtr->encILComp->eos, 0);
    
      pAppDataPtr->encILComp->done_sem = malloc (sizeof (semp_t));
      semp_init (pAppDataPtr->encILComp->done_sem, 0);
    
      pAppDataPtr->encILComp->port_sem = malloc (sizeof (semp_t));
      semp_init (pAppDataPtr->encILComp->port_sem, 0);
    
      /* alloacte data structure for each component used in this IL Client */
      pAppDataPtr->disILComp =
        (IL_CLIENT_COMP_PRIVATE *) malloc (sizeof (IL_CLIENT_COMP_PRIVATE));
      memset (pAppDataPtr->disILComp, 0x0, sizeof (IL_CLIENT_COMP_PRIVATE));
    
      /* these semaphores are used for tracking the callbacks received from
         component */
      pAppDataPtr->disILComp->eos = malloc (sizeof (semp_t));
      semp_init (pAppDataPtr->disILComp->eos, 0);
    
      pAppDataPtr->disILComp->done_sem = malloc (sizeof (semp_t));
      semp_init (pAppDataPtr->disILComp->done_sem, 0);
    
      pAppDataPtr->disILComp->port_sem = malloc (sizeof (semp_t));
      semp_init (pAppDataPtr->disILComp->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 = 1;
      pAppDataPtr->capILComp->startOutportIndex = 0;
    
      pAppDataPtr->deiILComp->numInport = 1;
      pAppDataPtr->deiILComp->numOutport = 2;
      /* VFPC OMX component support max 16 input / output ports, so o/p port index
         starts at 16 */
      pAppDataPtr->deiILComp->startOutportIndex = OMX_VFPC_NUM_INPUT_PORTS;
    
      pAppDataPtr->encILComp->numInport = 1;
      pAppDataPtr->encILComp->numOutport = 1;
      pAppDataPtr->encILComp->startOutportIndex = 1;
    
      pAppDataPtr->disILComp->numInport = 1;
      /* display does not has o/p ports */
      pAppDataPtr->disILComp->numOutport = 0;
      pAppDataPtr->disILComp->startOutportIndex = 0;
    
      /* 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);
    
      pAppDataPtr->deiILComp->inPortParams =
        malloc (sizeof (IL_CLIENT_INPORT_PARAMS) *
                pAppDataPtr->deiILComp->numInport);
    
      memset (pAppDataPtr->deiILComp->inPortParams, 0x0,
              sizeof (IL_CLIENT_INPORT_PARAMS));
    
      pAppDataPtr->deiILComp->outPortParams =
        malloc (sizeof (IL_CLIENT_INPORT_PARAMS) *
                pAppDataPtr->deiILComp->numOutport);
      memset (pAppDataPtr->deiILComp->outPortParams, 0x0,
              pAppDataPtr->deiILComp->numOutport *
              sizeof (IL_CLIENT_OUTPORT_PARAMS));
    
      pAppDataPtr->encILComp->inPortParams =
        malloc (sizeof (IL_CLIENT_INPORT_PARAMS) *
                pAppDataPtr->encILComp->numInport);
      memset (pAppDataPtr->encILComp->inPortParams, 0x0,
              sizeof (IL_CLIENT_INPORT_PARAMS));
    
      pAppDataPtr->encILComp->outPortParams =
        malloc (sizeof (IL_CLIENT_INPORT_PARAMS) *
                pAppDataPtr->encILComp->numOutport);
      memset (pAppDataPtr->encILComp->outPortParams, 0x0,
              sizeof (IL_CLIENT_OUTPORT_PARAMS));
    
      pAppDataPtr->disILComp->inPortParams =
        malloc (sizeof (IL_CLIENT_INPORT_PARAMS) *
                pAppDataPtr->disILComp->numInport);
      memset (pAppDataPtr->disILComp->inPortParams, 0x0,
              sizeof (IL_CLIENT_INPORT_PARAMS));
    
      /* 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 * 3) >> 1;
    
        /* this pipe will not be used in this application, as capture does not read 
           / write into file */
        pipe ((int *) 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 ((int *) pAppDataPtr->capILComp->localPipe);
    
      for (i = 0; i < pAppDataPtr->deiILComp->numInport; i++)
      {
        inPortParamsPtr = pAppDataPtr->deiILComp->inPortParams + i;
        inPortParamsPtr->nBufferCountActual = IL_CLIENT_DEI_INPUT_BUFFER_COUNT;
        /* since input of DEI is connected to output of capture, size is same as
           capture o/p buffers yuv 420 format */
        inPortParamsPtr->nBufferSize =
          (pAppDataPtr->nHeight * pAppDataPtr->nWidth * 3) >> 1;
        /* this pipe will not be used in this application, as dei does not read /
           write into file */
        pipe ((int *) inPortParamsPtr->ipBufPipe);
      }
      for (i = 0; i < pAppDataPtr->deiILComp->numOutport; i++)
      {
    
        outPortParamsPtr = pAppDataPtr->deiILComp->outPortParams + i;
        outPortParamsPtr->nBufferCountActual = IL_CLIENT_DEI_OUTPUT_BUFFER_COUNT;
        /* DEI one o/p is configured for YUV 422 output, so buffer size is
           calculated as follows */
        if (!(i % 2))
        {
    
    /*
          outPortParamsPtr->nBufferSize =
            pAppDataPtr->nHeight * pAppDataPtr->nWidth * 2;
    */
     
          outPortParamsPtr->nBufferSize =  (SD_WIDTH * SD_HEIGHT * 3) >>1;
    
         outPortParamsPtr->nBufferCountActual = IL_CLIENT_DEI_OUTPUT_BUFFER_COUNT;
    
         if (1 == pAppDataPtr->displayId) {
          /* configure the buffer size to that of the display size, for custom
             display this can be used to change width and height */
          outPortParamsPtr->nBufferSize = DISPLAY_HEIGHT * DISPLAY_WIDTH * 2;      
        }
    
        }
        else
        {
          /* DEI one o/p is configured for YUV 420 output for encode, so buffer
             size is calculated as follows */
          outPortParamsPtr->nBufferSize =
            (pAppDataPtr->nHeight * pAppDataPtr->nWidth * 3) >> 1;
          outPortParamsPtr->nBufferCountActual = IL_CLIENT_ENC_INPUT_BUFFER_COUNT;
    
        }
    
        /* this pipe will not be used in this application, as dei does not read /
           write into file */
        pipe ((int *) outPortParamsPtr->opBufPipe);
      }
    
      /* each componet will have local pipe to take bufffes from other component or 
         its own consumed buffer, so that it can be passed to other connected
         components */
      pipe ((int *) pAppDataPtr->deiILComp->localPipe);
    
      for (i = 0; i < pAppDataPtr->encILComp->numInport; i++)
      {
        inPortParamsPtr = pAppDataPtr->encILComp->inPortParams + i;
        inPortParamsPtr->nBufferCountActual = IL_CLIENT_ENC_INPUT_BUFFER_COUNT;
        /* input buffers size for yuv buffers, format is YUV420 hence 3/2 */
        inPortParamsPtr->nBufferSize =
          (pAppDataPtr->nHeight * pAppDataPtr->nWidth * 3) >> 1;
        /* this pipe is used for taking buffers from file read thread; in this
           example, file read is not used */
        pipe ((int *) inPortParamsPtr->ipBufPipe);
      }
      for (i = 0; i < pAppDataPtr->encILComp->numOutport; i++)
      {
        outPortParamsPtr = pAppDataPtr->encILComp->outPortParams + i;
        outPortParamsPtr->nBufferCountActual = IL_CLIENT_ENC_OUTPUT_BUFFER_COUNT;
        /* this size could be smaller than this value */
        outPortParamsPtr->nBufferSize =
          (pAppDataPtr->nHeight * pAppDataPtr->nWidth * 3) >> 1;
    
        /* This pipe is used if output is directed to file write thread, */
        pipe ((int *) outPortParamsPtr->opBufPipe);
      }
      /* each componet will have local pipe to take bufffers from other component
         or its own consumed buffer, so that it can be passed to other connected
         components */
      pipe ((int *) pAppDataPtr->encILComp->localPipe);
    
      for (i = 0; i < pAppDataPtr->disILComp->numInport; i++)
      {
        inPortParamsPtr = pAppDataPtr->disILComp->inPortParams + i;
        inPortParamsPtr->nBufferCountActual = IL_CLIENT_DISPLAY_INPUT_BUFFER_COUNT;
    
    /*
        inPortParamsPtr->nBufferSize =
          pAppDataPtr->nHeight * pAppDataPtr->nWidth * 2;
    */
        
        inPortParamsPtr->nBufferSize = (SD_HEIGHT * SD_WIDTH  * 3) >> 1;
        /* configuring for custom display parameters */  
         if (1 == pAppDataPtr->displayId) {
          inPortParamsPtr->nBufferSize = DISPLAY_HEIGHT * DISPLAY_WIDTH * 2;     
         }
        
        /* this pipe will not be used in this application, as display does not read 
           / write into file */
        pipe ((int *) inPortParamsPtr->ipBufPipe);
      }
      /* each componet will have local pipe to take bufffers from other component
         or its own consumed buffer, so that it can be passed to other connected
         components */
      pipe ((int *) pAppDataPtr->disILComp->localPipe);
    
      /* populate the pointer for allocated data structure */
      *pAppData = pAppDataPtr;
    }
    
    /* ========================================================================== */
    /**
    * IL_ClientInit() : This function is to deinitialize the application
    *                   data structure.
    *
    * @param pAppData          : appliaction / client data Handle 
    *  @return      
    *
    *
    */
    /* ========================================================================== */
    
    void IL_ClientDeInit (IL_Client * pAppData)
    {
      int i;
      IL_CLIENT_INPORT_PARAMS *inPortParamsPtr;
      IL_CLIENT_OUTPORT_PARAMS *outPortParamsPtr;
    
      close ((int) pAppData->capILComp->localPipe);
    
      for (i = 0; i < pAppData->capILComp->numOutport; i++)
      {
        outPortParamsPtr = pAppData->capILComp->outPortParams + i;
        /* this pipe will not be used in this application, as capture does not read 
           / write into file */
        close ((int) outPortParamsPtr->opBufPipe);
      }
    
      close ((int) pAppData->disILComp->localPipe);
    
      for (i = 0; i < pAppData->disILComp->numInport; i++)
      {
        inPortParamsPtr = pAppData->disILComp->inPortParams + i;
        /* this pipe will not be used in this application, as display does not read 
           / write into file */
        close ((int) inPortParamsPtr->ipBufPipe);
      }
    
      close ((int) pAppData->deiILComp->localPipe);
    
      for (i = 0; i < pAppData->deiILComp->numInport; i++)
      {
        inPortParamsPtr = pAppData->deiILComp->inPortParams + i;
        /* this pipe is not used in this application, as DEI does not read / write
           into file */
        close ((int) inPortParamsPtr->ipBufPipe);
      }
      for (i = 0; i < pAppData->deiILComp->numOutport; i++)
      {
        outPortParamsPtr = pAppData->deiILComp->outPortParams + i;
        /* this pipe is not used in this application, as dei does not read / write
           into file */
        close ((int) outPortParamsPtr->opBufPipe);
      }
    
      close ((int) pAppData->encILComp->localPipe);
    
      for (i = 0; i < pAppData->encILComp->numInport; i++)
      {
        inPortParamsPtr = pAppData->encILComp->inPortParams + i;
        /* This pipe is used if output is directed to file write thread, in this
           example, file read is not used */
        close ((int) inPortParamsPtr->ipBufPipe);
      }
      for (i = 0; i < pAppData->encILComp->numOutport; i++)
      {
        outPortParamsPtr = pAppData->encILComp->outPortParams + i;
        close ((int) outPortParamsPtr->opBufPipe);
      }
    
      free(pAppData->capILComp->outPortParams);
    
      free (pAppData->disILComp->inPortParams);
    
      free (pAppData->deiILComp->inPortParams);
    
      free (pAppData->deiILComp->outPortParams);
    
      free (pAppData->encILComp->inPortParams);
    
      free (pAppData->encILComp->outPortParams);
    
      /* these semaphores are used for tracking the callbacks received from
         component */
      semp_deinit (pAppData->deiILComp->eos);
      free(pAppData->deiILComp->eos);
    
      semp_deinit (pAppData->deiILComp->done_sem);
      free(pAppData->deiILComp->done_sem);
    
      semp_deinit (pAppData->deiILComp->port_sem);
      free(pAppData->deiILComp->port_sem);
    
      semp_deinit (pAppData->capILComp->eos);
      free(pAppData->capILComp->eos);
    
      semp_deinit (pAppData->capILComp->done_sem);
      free(pAppData->capILComp->done_sem);
    
      semp_deinit (pAppData->capILComp->port_sem);
      free(pAppData->capILComp->port_sem);
    
      semp_deinit (pAppData->disILComp->eos);
      free(pAppData->disILComp->eos);
    
      semp_deinit (pAppData->disILComp->done_sem);
      free(pAppData->disILComp->done_sem);
    
      semp_deinit (pAppData->disILComp->port_sem);
      free(pAppData->disILComp->port_sem);
    
      semp_deinit (pAppData->encILComp->eos);
      free(pAppData->encILComp->eos);
    
      semp_deinit (pAppData->encILComp->done_sem);
      free(pAppData->encILComp->done_sem);
    
      semp_deinit (pAppData->encILComp->port_sem);
      free(pAppData->encILComp->port_sem);
    
      free (pAppData->encILComp);
    
      free (pAppData->deiILComp);
    
      free (pAppData->capILComp);
    
      free (pAppData->disILComp);
    
      free (pAppData);
    
    }
    
    /* ========================================================================== */
    /**
    * IL_ClientErrorToStr() : Function to map the OMX error enum to string
    *
    * @param error   : OMX Error type
    *
    *  @return      
    *  String conversion of the OMX_ERRORTYPE
    *
    */
    /* ========================================================================== */
    
    OMX_STRING IL_ClientErrorToStr (OMX_ERRORTYPE error)
    {
      OMX_STRING errorString;
    
      /* used for printing purpose */
      switch (error)
      {
        case OMX_ErrorNone:
          errorString = "OMX_ErrorNone";
          break;
        case OMX_ErrorInsufficientResources:
          errorString = "OMX_ErrorInsufficientResources";
          break;
        case OMX_ErrorUndefined:
          errorString = "OMX_ErrorUndefined";
          break;
        case OMX_ErrorInvalidComponentName:
          errorString = "OMX_ErrorInvalidComponentName";
          break;
        case OMX_ErrorComponentNotFound:
          errorString = "OMX_ErrorComponentNotFound";
          break;
        case OMX_ErrorInvalidComponent:
          errorString = "OMX_ErrorInvalidComponent";
          break;
        case OMX_ErrorBadParameter:
          errorString = "OMX_ErrorBadParameter";
          break;
        case OMX_ErrorNotImplemented:
          errorString = "OMX_ErrorNotImplemented";
          break;
        case OMX_ErrorUnderflow:
          errorString = "OMX_ErrorUnderflow";
          break;
        case OMX_ErrorOverflow:
          errorString = "OMX_ErrorOverflow";
          break;
        case OMX_ErrorHardware:
          errorString = "OMX_ErrorHardware";
          break;
        case OMX_ErrorInvalidState:
          errorString = "OMX_ErrorInvalidState";
          break;
        case OMX_ErrorStreamCorrupt:
          errorString = "OMX_ErrorStreamCorrupt";
          break;
        case OMX_ErrorPortsNotCompatible:
          errorString = "OMX_ErrorPortsNotCompatible";
          break;
        case OMX_ErrorResourcesLost:
          errorString = "OMX_ErrorResourcesLost";
          break;
        case OMX_ErrorNoMore:
          errorString = "OMX_ErrorNoMore";
          break;
        case OMX_ErrorVersionMismatch:
          errorString = "OMX_ErrorVersionMismatch";
          break;
        case OMX_ErrorNotReady:
          errorString = "OMX_ErrorNotReady";
          break;
        case OMX_ErrorTimeout:
          errorString = "OMX_ErrorTimeout";
          break;
        default:
          errorString = "<unknown>";
      }
    
      return errorString;
    }
    
    /* ========================================================================== */
    /**
    * IL_ClientUtilGetSelfBufHeader() : This util function is to get buffer header
    *                                   specific to one component, from the buffer
    *                                   received from other component  .
    *
    * @param thisComp   : application component data structure
    * @param pBuffer    : OMX buffer pointer
    * @param type       : it is to identfy teh port type
    * @param portIndex  : port number of the component
    * @param pBufferOut : components buffer header correponding to pBuffer
    *
    *  @return      
    *  String conversion of the OMX_ERRORTYPE
    *
    */
    /* ========================================================================== */
    
    OMX_ERRORTYPE IL_ClientUtilGetSelfBufHeader (IL_CLIENT_COMP_PRIVATE *thisComp,
                                                 OMX_U8 *pBuffer,
                                                 ILCLIENT_PORT_TYPE type,
                                                 OMX_U32 portIndex,
                                                 OMX_BUFFERHEADERTYPE **pBufferOut)
    {
      int i;
      IL_CLIENT_INPORT_PARAMS *inPortParamsPtr;
      IL_CLIENT_OUTPORT_PARAMS *outPortParamsPtr;
      OMX_ERRORTYPE eError = OMX_ErrorNone;
    
      /* Check for input port buffer header queue */
      if (type == ILCLIENT_INPUT_PORT)
      {
        inPortParamsPtr = thisComp->inPortParams + portIndex;
        for (i = 0; i < inPortParamsPtr->nBufferCountActual; i++)
        {
          if (pBuffer == inPortParamsPtr->pInBuff[i]->pBuffer)
          {
            *pBufferOut = inPortParamsPtr->pInBuff[i];
          }
        }
      }
      /* Check for output port buffer header queue */
      else
      {
        outPortParamsPtr =
          thisComp->outPortParams + portIndex - thisComp->startOutportIndex;
        for (i = 0; i < outPortParamsPtr->nBufferCountActual; i++)
        {
          if (pBuffer == outPortParamsPtr->pOutBuff[i]->pBuffer)
          {
            *pBufferOut = outPortParamsPtr->pOutBuff[i];
          }
        }
      }
    
      return (eError);
    }
    
    /* ========================================================================== */
    /**
    * IL_ClientConnectComponents() : This util function is to update the pipe
    *                                information of other connected comonnet, so that
    *                                buffers can be passed to connected componnet.
    *
    * @param handleCompPrivA   : application component data structure for producer
    * @param compAPortOut      : port of producer comp
    * @param handleCompPrivB   : application component data structure for consumer
    * @param compBPortIn       : port number of the consumer component
    *
    *  @return      
    *  String conversion of the OMX_ERRORTYPE
    *
    */
    /* ========================================================================== */
    
    OMX_ERRORTYPE IL_ClientConnectComponents (IL_CLIENT_COMP_PRIVATE 
                                                *handleCompPrivA,
                                              unsigned int compAPortOut,
                                              IL_CLIENT_COMP_PRIVATE
                                                *handleCompPrivB,
                                              unsigned int compBPortIn)
    {
      OMX_ERRORTYPE eError = OMX_ErrorNone;
      IL_CLIENT_OUTPORT_PARAMS *outPortParamPtr = NULL;
      IL_CLIENT_INPORT_PARAMS *inPortParamPtr = NULL;
    
      /* update the input port connect structure */
      outPortParamPtr =
        handleCompPrivA->outPortParams + compAPortOut -
        handleCompPrivA->startOutportIndex;
    
      inPortParamPtr = handleCompPrivB->inPortParams + compBPortIn;
    
      /* update input port component pipe info with connected port */
      inPortParamPtr->connInfo.remoteClient = handleCompPrivA;
      inPortParamPtr->connInfo.remotePort = compAPortOut;
      inPortParamPtr->connInfo.remotePipe[0] = handleCompPrivA->localPipe[0];
      inPortParamPtr->connInfo.remotePipe[1] = handleCompPrivA->localPipe[1];
    
      /* update output port component pipe info with connected port */
      outPortParamPtr->connInfo.remoteClient = handleCompPrivB;
      outPortParamPtr->connInfo.remotePort = compBPortIn;
      outPortParamPtr->connInfo.remotePipe[0] = handleCompPrivB->localPipe[0];
      outPortParamPtr->connInfo.remotePipe[1] = handleCompPrivB->localPipe[1];
    
      return eError;
    }
    
    /* ========================================================================== */
    /**
    * IL_ClientUseInitialOutputResources() :  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_ClientUseInitialOutputResources (IL_CLIENT_COMP_PRIVATE 
                                                        *thisComp)
    {
    
      OMX_ERRORTYPE err = OMX_ErrorNone;
      unsigned int i = 0, j;
      IL_CLIENT_OUTPORT_PARAMS *outPortParamPtr = NULL;
      OMX_PARAM_PORTDEFINITIONTYPE param;
    
      memset (&param, 0, sizeof (param));
    
      OMX_INIT_PARAM (&param);
    
      /* Give output buffers to component which is limited by no of output buffers
         available. Rest of the data will be written on the callback from output
         data write thread */
      for (j = 0; j < thisComp->numOutport; j++)
      {
    
        param.nPortIndex = j + thisComp->startOutportIndex;
    
        OMX_GetParameter (thisComp->handle, OMX_IndexParamPortDefinition, &param);
    
        outPortParamPtr = thisComp->outPortParams + j;
    
        if (OMX_TRUE == param.bEnabled)
        {
          if (outPortParamPtr->connInfo.remotePipe[0] != 0)
          {
    
            for (i = 0; i < thisComp->outPortParams->nBufferCountActual; i++)
            {
              /* Pass the output buffer to the component */
              err =
                OMX_FillThisBuffer (thisComp->handle, outPortParamPtr->pOutBuff[i]);
    
            } /* for (i) */
          } /* if (outPortParamPtr...) */
        } /* if (OMX_TRUE) */
      } /* for (j) */
    
      return err;
    }
    
    /* ========================================================================== */
    /**
    * 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)
    {
      OMX_ERRORTYPE err = OMX_ErrorNone;
      unsigned int i = 0;
    
      for (i = 0; i < thisComp->outPortParams->nBufferCountActual; i++)
      {
        /* Pass the output buffer to the component */
        err = OMX_FillThisBuffer (thisComp->handle,
                                  thisComp->outPortParams->pOutBuff[i]);
      }
    
      return err;
    }
    
    /* ========================================================================== */
    /**
    * 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)
    {
    
      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_ERRORTYPE eError = OMX_ErrorNone;
    
      OMX_INIT_PARAM (&paramPort);
    
      /* set input height/width and color format */
      paramPort.nPortIndex = OMX_VFCC_OUTPUT_PORT_START_INDEX;
      OMX_GetParameter (pAppData->pCapHandle, OMX_IndexParamPortDefinition,
                        &paramPort);
      paramPort.nPortIndex = OMX_VFCC_OUTPUT_PORT_START_INDEX;
      paramPort.format.video.nFrameWidth = pAppData->nWidth;
      paramPort.format.video.nFrameHeight = pAppData->nHeight;
      paramPort.format.video.nStride = pAppData->nWidth;
      paramPort.nBufferCountActual = IL_CLIENT_CAPTURE_OUTPUT_BUFFER_COUNT;
      paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
      /* Capture output in 420 format */
      paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
    
      paramPort.nBufferSize =
        (paramPort.format.video.nStride * pAppData->nHeight * 3) >> 1;
      printf ("Buffer Size computed: %d\n", (int) paramPort.nBufferSize);
      printf ("set input port params (width = %d, height = %d)",
              (int) pAppData->nWidth, (int) 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;
      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");
    
      OMX_INIT_PARAM (&sHwPortId);
      /* capture on EIO card is component input at VIP1 port */
      sHwPortId.eHwPortId = OMX_VIDEO_CaptureHWPortVIP1_PORTA;
      eError = OMX_SetParameter (pAppData->pCapHandle,
                                 (OMX_INDEXTYPE) OMX_TI_IndexParamVFCCHwPortID,
                                 (OMX_PTR) & sHwPortId);
    
      OMX_INIT_PARAM (&sHwPortParam);
    
      sHwPortParam.eCaptMode = OMX_VIDEO_CaptureModeSC_NON_MUX;
      sHwPortParam.eVifMode = OMX_VIDEO_CaptureVifMode_16BIT;
      sHwPortParam.eInColorFormat = OMX_COLOR_FormatYCbYCr;
      sHwPortParam.eScanType = OMX_VIDEO_CaptureScanTypeProgressive;
      sHwPortParam.nMaxHeight = pAppData->nHeight;
      sHwPortParam.nMaxWidth = pAppData->nWidth;
      sHwPortParam.nMaxChnlsPerHwPort = 1;
    
      eError = OMX_SetParameter (pAppData->pCapHandle,
                                 (OMX_INDEXTYPE)
                                 OMX_TI_IndexParamVFCCHwPortProperties,
                                 (OMX_PTR) & sHwPortParam);
    
      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);
      }
    
      /* Set parameters for TVP controller */
    
      OMX_INIT_PARAM (&sHwPortId);
      /* capture on EIO card is component input at VIP1 port */
      sHwPortId.eHwPortId = OMX_VIDEO_CaptureHWPortVIP1_PORTA;
      eError = OMX_SetParameter (pAppData->pTvpHandle,
                                 (OMX_INDEXTYPE) OMX_TI_IndexParamVFCCHwPortID,
                                 (OMX_PTR) & sHwPortId);
      OMX_INIT_PARAM (&sHwPortParam);
      sHwPortParam.eCaptMode = OMX_VIDEO_CaptureModeSC_NON_MUX;
      sHwPortParam.eVifMode = OMX_VIDEO_CaptureVifMode_16BIT;
      sHwPortParam.eInColorFormat = OMX_COLOR_FormatYCbYCr;
      sHwPortParam.eScanType = OMX_VIDEO_CaptureScanTypeProgressive;
      sHwPortParam.nMaxHeight = pAppData->nHeight;
      sHwPortParam.nMaxWidth = pAppData->nWidth;
      sHwPortParam.nMaxChnlsPerHwPort = 1;
    
      eError = OMX_SetParameter (pAppData->pTvpHandle,
                                 (OMX_INDEXTYPE)
                                 OMX_TI_IndexParamVFCCHwPortProperties,
                                 (OMX_PTR) & sHwPortParam);
    
      OMX_INIT_PARAM (&sVidDecParam);
    
      /* set the mode based on capture/display device */
      if (strcmp ((char *) pAppData->mode, "1080p") == 0)
      {
        sVidDecParam.videoStandard =  OMX_VIDEO_DECODER_STD_1080P_60;
      }
      else if (strcmp ((char *) pAppData->mode, "720p") == 0)
      {
        sVidDecParam.videoStandard =  OMX_VIDEO_DECODER_STD_720P_60;
      }
      else
      {
        ERROR ("Incorrect Display Mode configured!!\n");
      }
      
      /* setting TVP7002 component input */
      sVidDecParam.videoDecoderId = OMX_VID_DEC_TVP7002_DRV;
      sVidDecParam.videoSystemId = OMX_VIDEO_DECODER_VIDEO_SYSTEM_AUTO_DETECT;
      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");
    
      return (eError);
    }
    
    /* ========================================================================== */
    /**
    * IL_ClientSetEncodeParams() : Function to fill the port definition 
    * structures and call the Set_Parameter function on to the Encode
    * Component
    *
    * @param pAppData   : Pointer to the application data
    *
    *  @return      
    *  OMX_ErrorNone = Successful 
    *
    *  Other_value = Failed (Error code is returned)
    *
    */
    /* ========================================================================== */
    
    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;
      OMX_VIDEO_CONFIG_DYNAMICPARAMS tDynParams;
      //OMX_VIDEO_PARAM_STATICPARAMS   tStaticParam;
    
      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 pfofile \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_VIDENC_OUTPUT_PORT;
      eError = OMX_GetParameter (pHandle, OMX_IndexParamVideoBitrate,
                                 &tVidEncBitRate);
    
      tVidEncBitRate.eControlRate = OMX_Video_ControlRateVariable;
      tVidEncBitRate.nTargetBitrate = pAppData->nBitRate;
      eError = OMX_SetParameter (pHandle, OMX_IndexParamVideoBitrate,
                                 &tVidEncBitRate);
    
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set Encode bitrate \n");
      }
    
      /* before creating use set_parameters, for run-time change use set_config
         all codec supported parameters can be set using this index       */
    
      OMX_INIT_PARAM (&tDynParams);
    
      tDynParams.nPortIndex = OMX_VIDENC_OUTPUT_PORT;
      
      eError = OMX_GetParameter (pHandle, OMX_TI_IndexParamVideoDynamicParams,
                                 &tDynParams);
      
      /* setting I frame interval */
      tDynParams.videoDynamicParams.h264EncDynamicParams.videnc2DynamicParams.intraFrameInterval = 90;
                             
      eError = OMX_SetParameter (pHandle, OMX_TI_IndexParamVideoDynamicParams,
                                 &tDynParams);
                                 
      
    
      return eError;
    }
    
    /* ========================================================================== */
    /**
    * IL_ClientSetDeiParams() : Function to fill the port definition 
    * structures and call the Set_Parameter function on to the DEI
    * Component
    *
    * @param pAppData   : Pointer to the application data
    *
    *  @return      
    *  OMX_ErrorNone = Successful 
    *
    *  Other_value = Failed (Error code is returned)
    *
    */
    /* ========================================================================== */
    
    OMX_ERRORTYPE IL_ClientSetDeiParams (IL_Client *pAppData)
    {
      OMX_ERRORTYPE eError = OMX_ErrorNone;
      OMX_PARAM_BUFFER_MEMORYTYPE memTypeCfg;
      OMX_PARAM_PORTDEFINITIONTYPE paramPort;
      OMX_PARAM_VFPC_NUMCHANNELPERHANDLE sNumChPerHandle;
      OMX_CONFIG_ALG_ENABLE algEnable;
      OMX_CONFIG_VIDCHANNEL_RESOLUTION chResolution;
    
      OMX_CONFIG_SUBSAMPLING_FACTOR sSubSamplinginfo = {0};
      
      OMX_INIT_PARAM(&sSubSamplinginfo);
    
      sSubSamplinginfo.nSubSamplingFactor = 1;
      eError = OMX_SetConfig ( pAppData->pDeiHandle, ( OMX_INDEXTYPE )
                               ( OMX_TI_IndexConfigSubSamplingFactor ),
                                 &sSubSamplinginfo );
    
      printf("setting dei mem type\n");
      OMX_INIT_PARAM (&memTypeCfg);
      memTypeCfg.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;
      memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT;
      eError = OMX_SetParameter (pAppData->pDeiHandle, OMX_TI_IndexParamBuffMemType,
                                 &memTypeCfg);
    
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set memory Type at input port\n");
      }
    
      /* Setting Memory type at output port to Raw Memory */
      OMX_INIT_PARAM (&memTypeCfg);
      memTypeCfg.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX;
      memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT;
      eError = OMX_SetParameter (pAppData->pDeiHandle, OMX_TI_IndexParamBuffMemType,
                                 &memTypeCfg);
    
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set memory Type at output port\n");
      }
    
      OMX_INIT_PARAM (&memTypeCfg);
      memTypeCfg.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX + 1;
      memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT;
      eError = OMX_SetParameter (pAppData->pDeiHandle, OMX_TI_IndexParamBuffMemType,
                                 &memTypeCfg);
    
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set memory Type at output port\n");
      }
    
      printf("Setting dei in width/height color\n");
      /* set input height/width and color format */
      OMX_INIT_PARAM (&paramPort);
      paramPort.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;
    
      OMX_GetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
                        &paramPort);
      paramPort.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;
      paramPort.format.video.nFrameWidth = pAppData->nWidth;
      paramPort.format.video.nFrameHeight = pAppData->nHeight;
    
      paramPort.format.video.nStride = pAppData->nWidth;
      paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
      paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
      paramPort.nBufferSize =
        (paramPort.format.video.nStride * pAppData->nHeight * 3) >> 1;
      paramPort.nBufferAlignment = 0;
      paramPort.bBuffersContiguous = 0;
      paramPort.nBufferCountActual = IL_CLIENT_DEI_INPUT_BUFFER_COUNT;
      printf ("set input port params (width = %d, height = %d) \n",
              (int) pAppData->nWidth, (int) pAppData->nHeight);
      OMX_SetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
                        &paramPort);
    
      printf("Setting dei in width/height color\n");
      /* set output height/width and color format */
      OMX_INIT_PARAM (&paramPort);
      paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX;
      OMX_GetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
                        &paramPort);
    
      paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX;
    /*
      paramPort.format.video.nFrameWidth = pAppData->nWidth;
      paramPort.format.video.nFrameHeight = pAppData->nHeight;
    */
      paramPort.format.video.nFrameWidth = SD_WIDTH;
      paramPort.format.video.nFrameHeight = SD_HEIGHT;
    
      paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
    
    //  paramPort.format.video.eColorFormat = OMX_COLOR_FormatYCbYCr;
    
      paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar ;
      paramPort.nBufferAlignment = 0;
      paramPort.nBufferCountActual = IL_CLIENT_DEI_OUTPUT_BUFFER_COUNT;
      /* This port is connected to display and provides 420SP o/p */
      //paramPort.format.video.nStride = pAppData->nWidth * 2;
      paramPort.format.video.nStride = SD_WIDTH;
    
      paramPort.nBufferSize = (paramPort.format.video.nStride * paramPort.format.video.nFrameHeight * 3) >> 1;
    
        if (1 == pAppData->displayId) {
        /*For the case of On-chip HDMI as display device*/
        paramPort.format.video.nFrameWidth = DISPLAY_WIDTH;
        paramPort.format.video.nFrameHeight = DISPLAY_HEIGHT;
        paramPort.format.video.nStride = DISPLAY_HEIGHT * 2;
      }
    /*  
      paramPort.nBufferSize =
        paramPort.format.video.nStride * paramPort.format.video.nFrameHeight;
    */                          
    
      printf ("set output port params (width = %d, height = %d)",
              (int) paramPort.format.video.nFrameWidth, (int)paramPort.format.video.nFrameHeight);
    
      OMX_SetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
                        &paramPort);
    
      OMX_INIT_PARAM (&paramPort);
      paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX + 1;
      OMX_GetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
                        &paramPort);
    
      paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX + 1;
      paramPort.format.video.nFrameWidth = pAppData->nWidth;
      paramPort.format.video.nFrameHeight = pAppData->nHeight;
      paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
      paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar ;
      paramPort.nBufferAlignment = 0;
      paramPort.nBufferCountActual = IL_CLIENT_ENC_INPUT_BUFFER_COUNT;
      paramPort.format.video.nStride = pAppData->nWidth;
    
      /* This port is connected to encoder and provides 420 o/p */
      paramPort.nBufferSize =
        (paramPort.format.video.nStride * paramPort.format.video.nFrameHeight *
         3) >> 1;
    
      printf ("set output port params (width = %d, height = %d)",
              (int) pAppData->nWidth, (int) pAppData->nHeight);
    
      OMX_SetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
                        &paramPort);
    
      /* set number of channles */
      printf ("set number of channels");
    
      OMX_INIT_PARAM (&sNumChPerHandle);
      sNumChPerHandle.nNumChannelsPerHandle = 1;
      eError = OMX_SetParameter (pAppData->pDeiHandle,
                                 (OMX_INDEXTYPE)
                                   OMX_TI_IndexParamVFPCNumChPerHandle,
                                 &sNumChPerHandle);
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set num of channels\n");
      }
    
      /* set VFPC input and output resolution information */
      printf ("set input resolution");
    
      OMX_INIT_PARAM (&chResolution);
      chResolution.Frm0Width = pAppData->nWidth;
      chResolution.Frm0Height = pAppData->nHeight;
      chResolution.Frm0Pitch = pAppData->nWidth;;
      chResolution.Frm1Width = 0;
      chResolution.Frm1Height = 0;
      chResolution.Frm1Pitch = 0;
      chResolution.FrmStartX = 0;
      chResolution.FrmStartY = 0;
      chResolution.FrmCropWidth = pAppData->nWidth;
      chResolution.FrmCropHeight = pAppData->nHeight;
      chResolution.eDir = OMX_DirInput;
      chResolution.nChId = 0;
    
      eError = OMX_SetConfig (pAppData->pDeiHandle,
                              (OMX_INDEXTYPE) OMX_TI_IndexConfigVidChResolution,
                              &chResolution);
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set input channel resolution\n");
      }
    
      printf ("set output resolution");
      OMX_INIT_PARAM (&chResolution);
      /* first output to display */
     /* 
     chResolution.Frm0Width = pAppData->nWidth;
      chResolution.Frm0Height = pAppData->nHeight;
      chResolution.Frm0Pitch = pAppData->nWidth * 2;
    */
      chResolution.Frm0Width = SD_WIDTH;
      chResolution.Frm0Height = SD_HEIGHT;
      chResolution.Frm0Pitch = SD_WIDTH;
    
       if (1 == pAppData->displayId) {
        /* on secondary display, it is scaled to display size */  
        chResolution.Frm0Width = DISPLAY_WIDTH;
        chResolution.Frm0Height = DISPLAY_HEIGHT;
        chResolution.Frm0Pitch = DISPLAY_WIDTH * 2;  
      }
      
      
      /* second output to encode */
      chResolution.Frm1Width = pAppData->nWidth;
      chResolution.Frm1Height = pAppData->nHeight;
      chResolution.Frm1Pitch = pAppData->nWidth;
      chResolution.FrmStartX = 0;
      chResolution.FrmStartY = 0;
      chResolution.FrmCropWidth = 0;
      chResolution.FrmCropHeight = 0;
      chResolution.eDir = OMX_DirOutput;
      chResolution.nChId = 0;
    
      eError = OMX_SetConfig (pAppData->pDeiHandle,
                              (OMX_INDEXTYPE) OMX_TI_IndexConfigVidChResolution,
                              &chResolution);
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set output channel resolution\n");
      }
    
      /* disable algo bypass mode */
      OMX_INIT_PARAM (&algEnable);
      algEnable.nPortIndex = 0;
      algEnable.nChId = 0;
      /* capture providing progressive input, alg is bypassed */
      algEnable.bAlgBypass = 1;
    
      eError = OMX_SetConfig (pAppData->pDeiHandle,
                              (OMX_INDEXTYPE) OMX_TI_IndexConfigAlgEnable,
                              &algEnable);
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to disable algo by pass mode\n");
      }
    
      return (eError);
    }
    
    /* ========================================================================== */
    /**
    * IL_ClientSetDisplayParams() : Function to fill the port definition 
    * structures and call the Set_Parameter function on to the display
    * Component
    *
    * @param pAppData   : Pointer to the application data
    *
    *  @return      
    *  OMX_ErrorNone = Successful 
    *
    *  Other_value = Failed (Error code is returned)
    *
    */
    /* ========================================================================== */
    
    OMX_ERRORTYPE IL_ClientSetDisplayParams (IL_Client *pAppData)
    {
      OMX_ERRORTYPE eError = OMX_ErrorNone;
      OMX_PARAM_BUFFER_MEMORYTYPE memTypeCfg;
      OMX_PARAM_PORTDEFINITIONTYPE paramPort;
      //OMX_PARAM_VFPC_NUMCHANNELPERHANDLE sNumChPerHandle;
      OMX_PARAM_VFDC_DRIVERINSTID driverId;
      OMX_PARAM_VFDC_CREATEMOSAICLAYOUT mosaicLayout;
      OMX_CONFIG_VFDC_MOSAICLAYOUT_PORT2WINMAP port2Winmap;
    
      OMX_INIT_PARAM (&paramPort);
    
      /* set input height/width and color format */
      paramPort.nPortIndex = OMX_VFDC_INPUT_PORT_START_INDEX;
      OMX_GetParameter (pAppData->pDisHandle, OMX_IndexParamPortDefinition,
                        &paramPort);
      paramPort.nPortIndex = OMX_VFDC_INPUT_PORT_START_INDEX;
    /*
      paramPort.format.video.nFrameWidth = pAppData->nWidth;
      paramPort.format.video.nFrameHeight = pAppData->nHeight;
      paramPort.format.video.nStride = pAppData->nWidth * 2;
    */
      paramPort.format.video.nFrameWidth = SD_WIDTH;
      paramPort.format.video.nFrameHeight = SD_HEIGHT;
      paramPort.format.video.nStride = SD_WIDTH;
    
      paramPort.nBufferCountActual = IL_CLIENT_DISPLAY_INPUT_BUFFER_COUNT;
      paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
      //paramPort.format.video.eColorFormat = OMX_COLOR_FormatYCbYCr;
      paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
    
    //  paramPort.nBufferSize = paramPort.format.video.nStride * pAppData->nHeight;
    
      paramPort.nBufferSize = ((paramPort.format.video.nStride *
                                 paramPort.format.video.nFrameHeight) * 3 ) >> 1;
    
      
       if (1 == pAppData->displayId) {
        /* on secondary display, it is scaled to display size */  
        paramPort.format.video.nFrameWidth = DISPLAY_WIDTH;
        paramPort.format.video.nFrameHeight = DISPLAY_HEIGHT;
        paramPort.format.video.nStride = DISPLAY_WIDTH * 2;  
      }
    //  paramPort.nBufferSize = paramPort.format.video.nStride * pAppData->nHeight;
      
      printf ("Buffer Size computed: %d\n", (int) paramPort.nBufferSize);
      printf ("set input port params (width = %d, height = %d)",
              (int) pAppData->nWidth, (int) pAppData->nHeight);
      OMX_SetParameter (pAppData->pDisHandle, OMX_IndexParamPortDefinition,
                        &paramPort);
      /* --------------------------------------------------------------------------*
         Supported display IDs by VFDC and DC are below The names will be renamed in
         future releases as some of the driver names & interfaces will be changed in
         future @ param OMX_VIDEO_DISPLAY_ID_HD0: 422P On-chip HDMI @ param
         OMX_VIDEO_DISPLAY_ID_HD1: 422P HDDAC component output @ param
         OMX_VIDEO_DISPLAY_ID_SD0: 420T/422T SD display (NTSC): Not supported yet.
         ------------------------------------------------------------------------ */
    
      /* set the parameter to the disaply component to 1080P @60 mode */
      OMX_INIT_PARAM (&driverId);
      /* Configured to use on-chip HDMI */
    
      if (0 == pAppData->displayId) {
        /* Configured to use SD output */
         driverId.nDrvInstID = OMX_VIDEO_DISPLAY_ID_SD0;
         
        /* Depending on the mode parameter set via cmd line, set the mode*/
        if (strcmp ((char *) pAppData->mode, "1080p") == 0)
        {
          driverId.eDispVencMode = OMX_DC_MODE_NTSC;
        }
        else if (strcmp ((char *) pAppData->mode, "720p") == 0)
        {
          driverId.eDispVencMode = OMX_DC_MODE_NTSC;
        }
        else
        {
          ERROR ("Incorrect Display Mode configured!!\n");
        }
        
      } 
      else if (1 == pAppData->displayId) {
        /* Configured to use LCD Display */
        driverId.nDrvInstID = OMX_VIDEO_DISPLAY_ID_HD1;
        driverId.eDispVencMode = DISPLAY_VENC_MODE;
      } 
      else {
        ERROR ("Incorrect Display Id configured\n");
      }
      
      eError = OMX_SetParameter (pAppData->pDisHandle,
                                 (OMX_INDEXTYPE) OMX_TI_IndexParamVFDCDriverInstId,
                                 &driverId);
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set driver mode to 1080P@60\n");
      }
    
      /* set the parameter to the disaply controller component to 1080P @60 mode */
      OMX_INIT_PARAM (&driverId);
      /* Configured to use on-chip HDMI */
    
      if (0 == pAppData->displayId) {
        /* Configured to use on-chip HDMI */
         driverId.nDrvInstID = OMX_VIDEO_DISPLAY_ID_SD0;
         
        /* Depending on the mode parameter set via cmd line, set the mode*/
        if (strcmp ((char *) pAppData->mode, "1080p") == 0)
        {
          driverId.eDispVencMode = OMX_DC_MODE_NTSC;
        }
        else if (strcmp ((char *) pAppData->mode, "720p") == 0)
        {
          driverId.eDispVencMode = OMX_DC_MODE_NTSC;
        }
        else
        {
          ERROR ("Incorrect Display Mode configured!!\n");
        }
        
      } 
      else if (1 == pAppData->displayId) {
        /* Configured to use LCD Display */
        driverId.nDrvInstID = OMX_VIDEO_DISPLAY_ID_HD1;
        driverId.eDispVencMode = DISPLAY_VENC_MODE;
      } 
      else {
        ERROR ("Incorrect Display Id configured\n");
      }
    
      eError = OMX_SetParameter (pAppData->pctrlHandle,
                                 (OMX_INDEXTYPE) OMX_TI_IndexParamVFDCDriverInstId,
                                 &driverId);
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set driver mode to 1080P@60\n");
      }
    
      if (1 == pAppData->displayId) {
       IL_ClientSetSecondaryDisplayParams(pAppData);
       }
    
      /* set mosaic layout info */
    #if 0
      OMX_INIT_PARAM (&mosaicLayout);
      /* Configuring the first (and only) window */
      mosaicLayout.sMosaicWinFmt[0].winStartX = 0;
      mosaicLayout.sMosaicWinFmt[0].winStartY = 0;
    /*
      mosaicLayout.sMosaicWinFmt[0].winWidth = pAppData->nWidth;
      mosaicLayout.sMosaicWinFmt[0].winHeight = pAppData->nHeight;
      mosaicLayout.sMosaicWinFmt[0].pitch[VFDC_YUV_INT_ADDR_IDX] =
        pAppData->nWidth * 2;
     */
    
      mosaicLayout.sMosaicWinFmt[0].winWidth = SD_WIDTH;
      mosaicLayout.sMosaicWinFmt[0].winHeight = SD_HEIGHT;
      mosaicLayout.sMosaicWinFmt[0].pitch[VFDC_YUV_INT_ADDR_IDX] = SD_WIDTH;
    
      mosaicLayout.sMosaicWinFmt[0].dataFormat = VFDC_DF_YUV422I_YVYU;
      mosaicLayout.sMosaicWinFmt[0].bpp = VFDC_BPP_BITS16;
      mosaicLayout.sMosaicWinFmt[0].priority = 0;
      mosaicLayout.nDisChannelNum = 0;
      mosaicLayout.nLayoutId = 0;
      /* Only one window in this layout, hence setting it to 1 */
      mosaicLayout.nNumWindows = 1;
    
      if (1 == pAppData->displayId) {
        /* For secondary Display, start the window at (0,0), since it is 
           scaled to display device size */
        mosaicLayout.sMosaicWinFmt[0].winStartX = 0;
        mosaicLayout.sMosaicWinFmt[0].winStartY = 0;
        
        /*If LCD is chosen, fir the mosaic window to the size of the LCD display*/
        mosaicLayout.sMosaicWinFmt[0].winWidth = DISPLAY_WIDTH;
        mosaicLayout.sMosaicWinFmt[0].winHeight = DISPLAY_HEIGHT;
        mosaicLayout.sMosaicWinFmt[0].pitch[VFDC_YUV_INT_ADDR_IDX] = 
                                           DISPLAY_WIDTH * 2;  
      }
    
      eError = OMX_SetParameter (pAppData->pDisHandle, (OMX_INDEXTYPE)
                                 OMX_TI_IndexParamVFDCCreateMosaicLayout,
                                 &mosaicLayout);
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set mosaic window parameter\n");
      }
    
      /* map OMX port to window */
      OMX_INIT_PARAM (&port2Winmap);
      /* signifies the layout id this port2win mapping refers to */
      port2Winmap.nLayoutId = 0;
      /* Just one window in this layout, hence setting the value to 1 */
      port2Winmap.numWindows = 1;
      /* Only 1st input port used here */
      port2Winmap.omxPortList[0] = OMX_VFDC_INPUT_PORT_START_INDEX + 0;
      eError = OMX_SetConfig (pAppData->pDisHandle,
                              (OMX_INDEXTYPE)
                                OMX_TI_IndexConfigVFDCMosaicPort2WinMap,
                              &port2Winmap);
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to map port to windows\n");
      }
    #endif
    
      /* Setting Memory type at input port to Raw Memory */
      printf ("setting input and output memory type to default");
      OMX_INIT_PARAM (&memTypeCfg);
      memTypeCfg.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;
      memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT;
      eError = OMX_SetParameter (pAppData->pDisHandle, OMX_TI_IndexParamBuffMemType,
                                 &memTypeCfg);
    
      if (eError != OMX_ErrorNone)
      {
        ERROR ("failed to set memory Type at input port\n");
      }
    
      return (eError);
    }
    
    /* Nothing beyond this point */
    
    

    Regards,

    Jon

  • Hi Jon ,

    Thanks for trying out the code . Yeah ,there is a problem in displaying SD display  .

    Did you try out the OMX display example ?

    @Vimal,

    I have tried with the SD resolution as 720x480  also ,I see the same behaviour as explained in my above posts  . I observe lot of noise ,improper colors . As Jon asked in the above post ,Is YUV420SP format is supported at the first DEI output port ?

  • Hi Siva / Jon,

    DEI supports 420Sp output. In the capture-encode example, DEI output which is fed to encoder is 420SP. Encoder can take only 420SP (NV12) input in EZSDK. Please check, If you see encoder o/p proper ? If yes, It is correct 420Sp o/p. Also in above posts it is not clear -

     Anyone of you have got SD display  (without capture or DEI) example working properly ? 

    Regards

    Vimal

  • Vimal,

    Please see my reponses to the two items you mentioned. I've tried to provide all the files and detail needed to recreate the issues.

    ===== DEI 420SP Output Issue ====
    I have attached my modifications to Siva's capture encode demo SD-display changes.  The attached code is in the following configuration:

    DEI Output 0 (downscaling) --YUV420SP--> SD Display (Does not work, DEI appears to output YUV422 despite our configuration)

    DEI Output 1 (no scaling) --YUV420SP--> Encoder (Looks good)

    Also attached are a raw frame from DEI Output 0, and the video encoded using DEI Output 1.

    The issue we are seeing is that in this configuration, DEI Output 0 appears to still be outputting YUV422, despite configuration as YUV420SP.  The attached code dumps frames going to the SD display; I attempted to import the luma as a 8-bit raw image in ImageJ: as you see in the below screenshot, it looks like alternating pixels have are chroma data, and we only get 1/2 our image width -- to me this looks like we're getting YUV422 data instead of YUV420SP, as we've configured it.


    In short, I'm convinced that there's either a bug in the modifications to the Capture-Encode demo (which neither Siva or I have spotted yet), or DEI Output 0 fails to output YUV420SP. (But yes, I do see that DEI Output 1 works fine with YUV420SP.) Can you take a look at the attached code and see if it works for you?

    ===== SD Display Demo =====
    I have not seen good output from the SD Display demo -- with my test patterns, the color data doesn't appear to get used, and it looks like some chroma is being used as luma data. I see the checkerboard pattern, but it flickers with some garbage color, and the luma checkerboard becomes green/magenta (indicating that it's being used as chroma.)

    Could you provide a couple frames of the test data that you know to work? I have attached some quick and dirty code that I used to generate YUV420SP checkboard patterns, with chroma values incrementing by 1 each frame.  Perhaps you or Siva could try this out and let me know what you see?

    Regards,
    Jon


    Attachments (Remove .txt extension...forum appears to restrict files based on file extension...)

    2541.capture_encode.sd-only.tar.gz  My modifications to Siva's modified code. It's hardcoded for SD display, so the command line args are mosty dummies (e.g. display select) I run this as follows, with a 720p input source: ./bin/capture_encode_a8host_debug.xv5T -f 60 -m 720p -b 1000000 -o test1.h264 -n 1000 -d 0

    2548.sddump.bin.txt  Raw data frame (720x480) from DEI Output 0, which I would have expected to be YUV420SP, but it looks like YUV422 (or just corrupted) to me...

    4314.test1.h264.txt  H.264 output from encoder (DEI Output 1). This looks good and shows the 720p video what we should be seeing in the above screenshot (of course, scaled down).

    1778.testpattern-420sp.tar.gz  Some code to generate test YUV420SP test patterns.  To generate 500 frames of 720x480 run as follows: ./testpattern 720 480 500 pattern.bin

  • Jon,

    DEI dual out component can provide ONLY one o/p as 420SP. It is as per hw paths. It can provide though both 422 o/p. I could not make out from earlier posts that you have been trying 420 outputs on both ports. apology for inconvenience..

    For SD display, do you see Luma component fine ? We have observed color issues for SD display in few DM8148 EVM. Encoder input samples should be fine for SD display.

    Regards

    Vimal

  • Vimal,

    === (Solved) DEI Output 0 - No 420SP ===

    Thanks for clarifying the dual 420SP issue -- sorry I wasn't clear.  Where is this limitation documented? Did I miss it in the wiki or the DM8148 OpenMax user guide?

    [UPDATE] I now see this looking at Figure 12-1 in the TRM...Writeback0 is 422I only (which I assume is DEI Output 0), whearas the second output goes back through VIP0, which supports RGB, 422, and 420.

    === (Still not working) SD Display Demo ===

    It looks like we were updating posts at  the same time. Look at my previous post (2 posts back). It looks like the luma is somewhat okay, but it gets a bit choppy. The chroma data doesn't seem to work at all, and occasionally I see the luma data as colors (indicating that the luma is being interpreted as chroma).

    See the attachment of my previous post for my YUV420SP test pattern generator program -- perhaps you could verify that my test patterns work for you.

    Thank you,

    Jon




    Siva,

    From working with the code you shared, Vimal's note is definitely the issue with that code:

    Vimal Jain said:
    DEI dual out component can provide ONLY one o/p as 420SP. It is as per hw paths. It can provide though both 422 o/p. I could not make out from earlier posts that you have been trying 420 outputs on both ports. apology for inconvenience..

    To get this working, replace the use of the encoder with the SD display.

  • Vimal Jain said:
    For SD display, do you see Luma component fine ? We have observed color issues for SD display in few DM8148 EVM. Encoder input samples should be fine for SD display.

    Also -- are you saying this is possibly a hardware issue with the EVM. (Will I need to get it replaced?)

    What encoder input samples are you referring to? I only see the 264 sample on the EZSDK rootfs.


    Thanks,

    Jon

  • Hi Jon,

    Thanks for trying out various options for SD display . Now we got it clarified that we can get only YUV422 data out of DEI Port 0 .

    I will try connecting the VFDC component to the DEI Port 1 and see what happens . Also I will generate the YUV420SP color patterns with the source code you have attached ,test the OMX display example and let you know the results .

    Thanks once again for keeping this thread active .

    @Vimal ,

    As Jon has pointed out , chroma information is losed when he is trying to display YUV420SP patterns using OMX display example .

    Can you please tell us what would be the problem ,also if you can provide us the sample YUV420SP test files for SD display ,that would be very helpful .

    Thanks,

    Siva .

  • Hi Vimal,

    So where have we left off on the SD issue (i.e., the SD Display OMX demo not having any chroma)? Are there issues that will be resolved in a future EZSDK release, or is this something Siva and I should continue investing time into debugging?

    If you don't see any issues, could you provide a couple test inputs for us to use?

    Thank you for your time and help,

    Jon

  • Hi,

    As i wrote earlier, this appears to be EVM issue. Could you please tell us which version of EVM are you using ?

    Regards

    Vimal

  • Vimal,


    Here's my EVM info:

    • Base board: DDR3 PG2.0 Rev C
    • I/O Board: (Catalog Application Board) Rev B

    Thank you,

    Jon

  • Hi Vimal ,

    I don't think it will be the EVM issue . I have integrated the v4l2 code into the OMX Capture_Encode application and displayed the frames on Display2 (SD Display ) .

    I can see the display (720 x 480) clearly using v4l2 code  . I think its a problem with the OMX framework . Please attach the YUV420SP sample files that you have used for testing SD display successfully .

    Also it will be better if you can let us know ,how you have tested out SD display on DM8148 EVM using EZSDK 5.04 .Is PAL mode is supported in current EZSDK ?

    @Jon ,

    Hi Jon,

    I have generated the YUV420SP color patterns with your source code  . when I tried to display the patterns using OMX display example , I observe the same . colors are improper . Have you tried any other option ?

    Thanks,

    N Sivaramkrishna .

  • Hi Vimal ,

    Here is my EVM version

    BaseBoard :  DM814x EVM REV D

    I/O Expansion Board :  REV D

    Thanks,

    N Sivaramkrishna .

  • Hi Siva & Jon,

    As i figured out EVM issue would cause color issue for composite Vs SD display mode, (EVM could not be configured for composite mode earlier). However, as one of you also pointed in earlier post, making display explicit composite would show the colors as well. 

    I also tried to reproduce the issue, after few iteration I could see the issue of colors jumping. similar observation as you had, chroma looking like assuming role of Luma. And sometime it is proper as well ! 

    For generating NV12, I used decode example and modify file write function to create required o/p. H264 streams can be used to generate this.

    We are looking at this issue, since I could observer the display sometimes proper as well, It does not seem to be setting issue. I will keep you posted.

    Regards

    Vimal

  • Hi,

    It appears that file read is causing the sd display colors issue. I removed the file read post initial frames fill (same frames repeated after that), and do not see luma/chroma  mixing issue. It appears that not getting the frames in time due to file read delay causes this. Could you try the same and let me know the outcome. 

    Thanks

    Vimal

  • Vimal,

    I have modified the demo to read in and buffer a single frame from a file. I've replaced the fread() in IL_ClientFillData() with a memcpy() of this buffered frame.

    Unfortunately, I still see the issue we've been discussing -- I don't think the file read is the source of the problem.

    A patch of my small changes is attached. Mind sharing a patch or a few files of what you have working?

    diff -ur display.bak/src/ilclient.c display/src/ilclient.c
    --- display.bak/src/ilclient.c	2012-05-17 13:41:18.097975070 -0400
    +++ display/src/ilclient.c	2012-06-19 08:50:52.288898230 -0400
    @@ -346,6 +346,8 @@
         goto EXIT;
       }
     
    +  pAppData->fData = NULL;
    +
       /* Initialize application / IL Client callback functions */
       /* Callbacks are passed during getHandle call to component, Component uses
          these callaback to communicate with IL Client */
    diff -ur display.bak/src/ilclient.h display/src/ilclient.h
    --- display.bak/src/ilclient.h	2012-05-17 13:41:18.084974280 -0400
    +++ display/src/ilclient.h	2012-06-19 08:50:31.163093842 -0400
    @@ -212,6 +212,7 @@
       FILE *fIn;
       FILE *fInFrmSz;
       FILE *fOut;
    +  OMX_U8 *fData;
       OMX_COLOR_FORMATTYPE ColorFormat;
       OMX_U32 displayId;
       void *fieldBuf;
    diff -ur display.bak/src/ilclient_utils.c display/src/ilclient_utils.c
    --- display.bak/src/ilclient_utils.c	2012-05-17 13:41:18.147978098 -0400
    +++ display/src/ilclient_utils.c	2012-06-19 09:41:47.553816073 -0400
    @@ -415,14 +415,23 @@
         /* Setting frame size for SD sized buffer*/    
         frameSize = (SD_WIDTH * SD_HEIGHT * 3) >> 1;
       }
    -  
    -  dataRead = fread (pBuf->pBuffer, frameSize, 1, pAppData->fIn);
    +
    +  if(pAppData->fData == NULL)
    +  {
    +      pAppData->fData = malloc(frameSize);
    +      dataRead = fread(pAppData->fData, frameSize, 1, pAppData->fIn);
    +      //printf("Read %d/%d\n", dataRead, frameSize);
    +  }
    +
    +  memcpy(pBuf->pBuffer, pAppData->fData, frameSize);
    +  //dataRead = fread (pBuf->pBuffer, frameSize, 1, pAppData->fIn);
    +  //printf("Copying data...\n");
       
     
       /* Update the buffer header with buffer filled length and alloc length */
    -  pBuf->nFilledLen = dataRead;
    +  pBuf->nFilledLen = frameSize;
     
    -  return dataRead;
    +  return frameSize;
     }
     
     /* ========================================================================== */
    @@ -826,7 +835,8 @@
         mosaicLayout.sMosaicWinFmt[0].winWidth = SD_WIDTH;
         mosaicLayout.sMosaicWinFmt[0].winHeight = SD_HEIGHT;
         mosaicLayout.sMosaicWinFmt[0].pitch[VFDC_YUV_INT_ADDR_IDX] = 
    -#endif                                       SD_WIDTH ;     
    +                                      SD_WIDTH ;     
    +#endif
       }
       
       if ((0 == pAppData->displayId) || (1 == pAppData->displayId))
    Only in display/src: .ilclient_utils.c.swo
    

    Thanks,

    Jon

  • Jon,

    I tried it multiple times. I even tried with color bar pattern and do not see issue. Please see below code for generating color bar.

    static unsigned long cbcr[8] = {
    0x80808080,
    0x80808080,
    0x5af05af0,
    0x36223622,
    0xf06ef06e,
    0x10921092,
    0xa610a610,
    0xcadecade
    };

    static unsigned long yy[8] = {
    0xebebebeb,
    0x1e1e1e1e,
    0x51515151,
    0x91919191,
    0x29292929,
    0xd2d2d2d2,
    0xaaaaaaaa,
    0x6a6a6a6a
    };

    void color_bar(char *addr, int width, int height)
    {
    unsigned long *ptr = (unsigned long *)addr;
    int i, j, k;

    for(i = 0 ; i < 8 ; i++) {
    for(j = 0 ; j < (height/8) ; j++) {
    for(k = 0 ; k < (width >> 2) ; k++) {
    ptr[k] = yy[i];
    }
    ptr = ptr + (width >> 2);
    }

    }
    for(i = 0 ; i < 8 ; i++) {
    for(j = 0 ; j < (height/16) ; j++) {
    for(k = 0 ; k < (width >> 2) ; k++) {
    ptr[k] = cbcr[i];
    }
    ptr = ptr + (width >> 2);
    }
    }
    }

    You can put this function in Filldata function as 

    frameSize = (SD_WIDTH * SD_HEIGHT * 3) >> 1;

    color_bar(pBuf->pBuffer, SD_WIDTH, SD_HEIGHT);

    dataRead = frameSize; //fread (pBuf->pBuffer, frameSize, 1, pAppData->fIn);

    Please try above and let me know, if you still see the issue. 

    Regards

    Vimal

  • Vimal,

    Thank you for providing this sample - I do not see the issue with the provided color bars! Attached is a picture of what I'm seeing on my display, for your verification. (Note that all the bars are a solid color...there's just some glare off the TV.)

    To further verify your suspicion of the issue being timing related, I added a 150 ms delay (might be a tad overkill...) to the fill data call -- this reintroduced what appeared to be the same issue. 

    (1) So is there a minimum rate at which I need to ensure I deliver data to the SD display component via my OMX code, or will this be dealt with from the M3 firmware side of things?

    (2) Are you at liberty to say when a set of SD-related fixes (M3 firmware binaries or A8 OMX patches) will be released? I know you mentioned there being a number of known issues which the various TI teams have already resolved. Even just a rough estimate will do (a couple weeks, 1 or 2 months, or > 4 months?) -- my team needs me to provide some risk analysis with respect to whether or not we'll meet our SD display functionality on time...anything you can let us know would help greatly! :)

    Thank you so much for your time and help Vimal -- we really appreciate it!

    Jon

  • Hi Vimal ,

    Just to confirm ,I have also tried SD display with the color bar code that you have shared with us ,I see accurate color bars without any issues .

    As you mentioned that (reading buffer from a file ) fread is actually causing the problem ,this observation seems to be correct . We have verified this by reading a single buffer from a NV12 file and feeding the same buffer continuously to the display component . We didn't notice any color issues in this case .

    As Jon asked ,Can you let us know at what rate we can feed the buffers to the Display component .

    Is PAL mode is supported in the current EZSDK 5.04 ? I get a OMX bad parameter error when I configure the display and ctrl components in PAL mode .

    Thanks Vimal for clarifying the SD Display .

    Siva .

  • Hi Vimal and Siva,


    Any updates on planed releases or the questions posed in the last two posts?


    Thank you,

    Jon

  • I just had the opportunity to drive a higher definition display with the SD (composite) output, using Vimal's modifications to the display demo.  I got to get a better look at the output.

    I'm seeing that the chroma and luma seem to be a bit off where one color bar meets another.  Is this just typical by nature of the SD video's fields or is this a possible issue/bug? Siva or Vimal, do you see this?


    Thank you,

    Jon