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.

Does h264 encoder of 8148 EVM support interlaced video input?

Other Parts Discussed in Thread: TVP5147, TVP7002

The examples capture_encode and encoder only, both of them the h264 encoder supports progressive video input. As to interlaced video input, it's not very clear. In the OpenMax user guide, it's said the omx encoder supports progressive input only; but in the hdvicp user guide, it seems interlaced input is supported too.

There are circumstances that input video is PAL/NTSC, users are forced to use decoder tvp5147,but this is not supported by the OMX capture component. The only option is to capture the interlaced video by V4L2 driver. The captured video  using tvp5147 is feeded to h264 encoder(if capture using V4L2, DEI component can't be used ). The the bitstream file is then decoded by h264 decoder, but there exists apparent vertical edge distortion for moving object. After scanning through this forum quite a few time, this is caused for that interlaced video take two fields at two different time and during the two moment, the moving object has shifted in horizontal direction.

Then my question is how to solve the problem when interlaced video input decoded and digitized by chips other than Tvp7002 is feeded into h264 encoder?  If I do not use tvp7002 but I want to use interlaced video input, how can I do?

  • Hello,

    Does h264 encoder of 8148 EVM support interlaced video input?

    You could check here:

    http://processors.wiki.ti.com/index.php/VENC

    Chapter:

    3. How to modify static parameters of codec ?

    Best Regards,

    Margarita

  • Hi

    On http://processors.wiki.ti.com/index.php/VENC chapter 4, there is a sentence as this:

    " Please note encoder would expect field separated mode, in same buffer"

    what's the meaning of it?

    the input video must have  data format like this:

    1) topfield luma block,  bottomfield luma block,  topfield chroma block,  bottomfield chroma block

    or like the another one ?

    2) topfield luma block, topfield chroma block,  bottomfield luma block,  bottomfield chroma block.

  • Hi

    Currently, is there any solution to meet requirement of V4L2 interlaced capture + OMX h264 encoder component?

    There have no source file related to OMX component in the EZSDK, I have no way to set dataLayout of encoder.

    I have scanned through the forum, I found no previous discussion have resolved the problem.

        

  • Hello,

    yuan gao2 said:
    V4L2 interlaced capture + OMX h264 encoder component

    Are you using gstreamer?

    Best Regards,

    Margarita

  • Hi

    I am not using gstreamer.

    The requirement is interlaced video capture and h264 encode.

     I have to use tvp5147+V4L2 for capture because tvp7002 can't support NTSC/PAL.

    The output of capture is 420 semi-planar and two field interleaved.

    After h264 progressive encoding, around moving object, there are always edge distortion.

    Then I tried the interlaced encoding, but I have not achieved to do it so far.

    I have convert the capture output to field seperated, but the problem still exists.

  • Hi

    Have any new suggestion?

    We are now blocked by this problem.

    Without tvp7002(OMX supports 7002 only), interlaced video can not be used on 8148 if user plans to use CODEC of TI. This is an bad option in business. So we have to solve the problem.

    I have noticed that some developers used other SDK, such as something like RDK,IPNC SDK, etc..With these development tools, does this problem still exist? How to get these tools? EZSDK has not achieved its goal of making video reladed software development easy. 

      

  • Hi,

    We have tested interlaced encoding with h264 encoder. We have modified captrue_encode demo only to do this .

    OMX_VFCC captrues 1080i from tvp7002 and encoder encodes field interleaved video.

    You can modify capture_encode to bypass DEI 

  • Hi

    What's the captured video format of VFCC?

    OMX DEI component can't exist in my project because I used V4L2 capture. So I capture video using V4L2 and encode it with OMX VENC component.

    I use V4L2 + VENC component(encoder setting same with OMX encode example), V4L2 output 420 semi-planar field interleaved, in this case, video decoded has edge distortion.

    I use V4L2 + VENC component(encoder setting as http://processors.wiki.ti.com/index.php/OMX_VENC, input height divided by 2), V4L2 output 420 semi-planar field separated, in this case, video decoded becomes even worse.

  • Below is interlaced encode result(input 4:2:0 semi-planar, two field seperated)

  • Hi

    In the example of capture_encode, the encoder is working as progressive encode by default? Because if input is 1080i, then DEI algorithm is enabled, output bitstream will be ok in this condition. 

  • Below is encoder setting from ilclient

    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;
    OMX_VIDEO_PARAM_AVCTYPE tAVCParams;

    pHandle = pAppData->pEncHandle;

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


    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;//IL_CLIENT_ENC_WIDTH;
    tPortDef.format.video.nStride = pAppData->nWidth;//IL_CLIENT_ENC_WIDTH;
    tPortDef.format.video.nFrameHeight = pAppData->nHeight;//IL_CLIENT_ENC_HEIGHT;
    tPortDef.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;


    if (strcmp ((char *) pAppData->mode, "1080i") == 0)
    tPortDef.format.video.nFrameHeight = pAppData->nHeight >> 1;


    /* settings for OMX_IndexParamVideoPortFormat */
    tPortDef.nBufferSize = (pAppData->nWidth * pAppData->nHeight * 3) >> 1;


    tPortDef.nBufferSize = (tPortDef.format.video.nFrameWidth * tPortDef.format.video.nFrameHeight * 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;;//IL_CLIENT_ENC_WIDTH;
    tPortDef.format.video.nFrameHeight = pAppData->nHeight;//pAppData->nWidth;//IL_CLIENT_ENC_HEIGHT;

    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");
    }
    /* 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_AVCProfileHigh;//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_Default;
    tEncoderPreset.eRateControlPreset = OMX_Video_RC_None;

    eError = OMX_SetParameter (pHandle, OMX_TI_IndexParamVideoEncoderPreset,
    &tEncoderPreset);
    if (eError != OMX_ErrorNone)
    {
    ERROR ("failed to Encoder Preset \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);


    OMX_INIT_PARAM (&tStaticParam);

    tStaticParam.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

    eError = OMX_GetParameter (pHandle, OMX_TI_IndexParamVideoStaticParams,
    &tStaticParam);

    /* To use extended parameters */
    tStaticParam.videoStaticParams.h264EncStaticParams.rateControlParams.HRDBufferSize
    = 4000000;
    tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.encodingPreset
    = XDM_USER_DEFINED;
    tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.rateControlPreset
    = IVIDEO_USER_DEFINED;

    /* for interlace, base profile can not be used */
    tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.profile = IH264_HIGH_PROFILE;
    tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.level = IH264_LEVEL_22;

    /* setting Interlace mode */
    tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.inputContentType = IVIDEO_INTERLACED;
    tStaticParam.videoStaticParams.h264EncStaticParams.bottomFieldIntra = 0;
    tStaticParam.videoStaticParams.h264EncStaticParams.interlaceCodingType = IH264_INTERLACE_FIELDONLY;
    tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.encodingPreset = XDM_USER_DEFINED;
    tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.rateControlPreset = IVIDEO_USER_DEFINED;

    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra4x4Enable = 309;
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra8x8Enable = 320;

    eError = OMX_SetParameter (pHandle, OMX_TI_IndexParamVideoStaticParams,
    &tStaticParam);

    OMX_INIT_PARAM (&tAVCParams);

    tAVCParams.nPortIndex = OMX_DirOutput;
    eError = OMX_GetParameter(pHandle, OMX_IndexParamVideoAvc, &tAVCParams);
    if(eError != OMX_ErrorNone)
    {
    printf("failed to Encoder OMX_IndexParamVideoAvc getparams\n");
    }
    else
    {
    printf("success OMX_IndexParamVideoAvc getparams\n");
    }

    tAVCParams.eLevel = OMX_VIDEO_AVCLevel42;
    tAVCParams.eProfile = OMX_VIDEO_AVCProfileHigh;
    tAVCParams.nPFrames = 89;
    if(pAppData->bframe)
    {
    tAVCParams.nBFrames = pAppData->bframe;
    }
    else
    {
    tAVCParams.nBFrames = 0;
    }

    eError = OMX_SetParameter(pHandle, OMX_IndexParamVideoAvc, &tAVCParams);
    if(eError != OMX_ErrorNone)
    {
    printf("failed to encoder OMX_IndexParamVideoAvc setparams\n");
    }
    else
    {
    printf("success OMX_IndexParamVideoAvc setparams\n");
    }


    return eError;
    }

    We are using fieldMerged capture.

  • Thank for your quick reply.

    I will compare with my setting and if any result I will feedback you.

  • Hi

    I have tried with the setting you provided, but result keeps same.

    There are apparent chroma error in the video after the bitstream file is decoded, just as the image I posted previously.

    In My input 420 semi-planar YUV video, two fields are separated. Is there any difference in input buf format?

       

  • I have set 

    if ( frameDataContentType.eContentType == OMX_Video_Interlaced )
    {
    pVidEncComPvt->tVedEncInBufsPtr->contentType = IVIDEO_INTERLACED;
    pVidEncComPvt->tVedEncInBufsPtr->dataLayout = IVIDEO_FIELD_INTERLEAVED ;

    in omx_h264ve.c

  • Hi

    Thanks for your quick reply.

    In my EZSDK, there isn't a file named omx_h264ve.c. By no means can I set what you have set in this file. I think this is the problem.

    My EZSDK version is ti-ezsdk_dm814x-evm_5_05_02_00.In each component, only a header file exists. 

    How could I do in this case?

  • Hi

    From the forum, I have noticed that some users' EZSDK have source file under directory ezsdk-5_05_02_00/component-sources/omx-ti81xx-src_05_02_00_48/src/ti/omx/comp/venc/src, other users' EZSDK have not. It seems that the EZSDK downloaded from TI official website has been revised for part of users? Does this difference attribute to NDA? 

    How can I  get the full version of EZSDK 5.5.2.0?  

  • Hi ,

    Overlaypackage is available only under NDA. Please contact your local TI FAE to get overLay package for EZSDK 05.05.02.00.

    Can you try out with modified captreu_encode demo with DEI bypassed?

    Please use belo settings for VFCC

    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;

    pAppData->capILComp->numFrames = pAppData->nEncodedFrms;
    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)\n",
    (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.bFieldMerged = OMX_FALSE;

    if (strcmp ((char *) pAppData->mode, "1080i") == 0) {
    sHwPortParam.eScanType = OMX_VIDEO_CaptureScanTypeInterlaced;
    // sHwPortParam.nMaxHeight = pAppData->nHeight >> 1;
    sHwPortParam.bFieldMerged = OMX_TRUE;
    }

    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.bFieldMerged = OMX_FALSE;
    sHwPortParam.nMaxHeight = pAppData->nHeight;

    if (strcmp ((char *) pAppData->mode, "1080i") == 0) {
    sHwPortParam.eScanType = OMX_VIDEO_CaptureScanTypeInterlaced;

    sHwPortParam.bFieldMerged = OMX_TRUE;
    }

    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, "1080i") == 0)
    {
    sVidDecParam.videoStandard = OMX_VIDEO_DECODER_STD_1080I_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);
    }

    Here VFCC(tvp7002 1080i 420SP) -> H264Encoder

    Ram

  • Thanks for your help.

    I have to contact with distributor to deal with the NDA issuse.

    Because currently I have not used tvp7002(input of decoder is composite video), I can't capture video using VFCC component.That's why I have chosen V4L2 to capture.

    I think I have to suspend the work some time now. After I get the overlay version, I will resume the work.