NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

OMX VENC

From Texas Instruments Wiki
(Redirected from VENC)
Jump to: navigation, search

Video Encoder Component (VENC)[edit]

The VENC component is a video encode component that has one input port and one output port. The job of the VENC is to encode the raw frames provided to it. VENC component is designed to incorporate any video encode algorithm which provides codec engine interface. VENC component can be configured through IL client to configure any of the supported compression type format. Component is designed to plug-in appropriate video encoder.

Note: EZSDK 5.03.00.09 release with OMX 05.02.00.26 supports H264 and MPEG4/H263 encode

Codec specific components functions are pluggable through a table. This Table and associated function needs to be enhanced /added to include different compression format.


VENC component can support N input and M output buffers. Based on requirement of number of B frames, VENC input port properties for nBufferCountActual can be modified. In this release it is set as 4 through IL client. Buffers are owned by writer component. For example, In this release VFPC component will own input buffers to VENC and VENC component will own its output buffers. IL client sets the width/stride and height without any padding required by codec.


Video encode component supports codec supported color format. Format supported in this release is OMX_COLOR_FormatYUV420PackedSemiPlanar. It is based on encoder’s capability. Component uses this value for setting up tunnels..

Through IL client, It is possible to change the profile/level/bitrate/ B frames generation settings. In this release encoder configuration can be done before the codec creation. Dynamic parameter change is not supported in this release. Video encode component support Standard Non-Tunneling between components.

VENC configuration[edit]

Video Encoder componnet crate time parameters can be configured by using OMX_GetParameter / OMX_SetParameter APIs.

Following indices are supported in EZSDK 5.03 release.

  • OMX_IndexParamPortDefinition
OMX_PARAM_PORTDEFINITIONTYPE tPortDef;
 
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;
/* set width and height of buffers */
tPortDef.format.video.nFrameWidth = pAppData->nWidth;
tPortDef.format.video.nFrameHeight = pAppData->nHeight;
/* EZSDK 5.02 supports H264 / MPEG4 / H263 encoding */
/* for H264 use OMX_VIDEO_CodingAVC, for MPEG4 use OMX_VIDEO_CodingMPEG4, for H263 use OMX_VIDEO_CodingH263 */
tPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;


/* Frame rate is in Q16 format as in OpenMax standard */
tPortDef.format.video.xFramerate = (pAppData->nFrameRate << 16);
tPortDef.format.video.nBitrate = pAppData->nBitRate;
/* settings for OMX_IndexParamVideoPortFormat */
eError = OMX_SetParameter (pHandle, OMX_IndexParamPortDefinition, &tPortDef);

  • OMX_IndexParamVideoProfileLevelCurrent
 OMX_VIDEO_PARAM_PROFILELEVELTYPE tProfileLevel;

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

 eError = OMX_GetParameter (pHandle, OMX_IndexParamVideoProfileLevelCurrent,
&tProfileLevel);
tProfileLevel.eProfile = OMX_VIDEO_AVCProfileBaseline;
tProfileLevel.eLevel = OMX_VIDEO_AVCLevel42;

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


 
  • OMX_IndexParamVideoBitrate
 OMX_VIDEO_PARAM_BITRATETYPE tVidEncBitRate;
 
OMX_INIT_PARAM (&tVidEncBitRate);
tVidEncBitRate.nPortIndex = OMX_DirOutput;
eError = OMX_GetParameter (pHandle, OMX_IndexParamVideoBitrate,
&tVidEncBitRate);
 <span id="fck_dom_range_temp_1315980039082_189" />
tVidEncBitRate.eControlRate = OMX_Video_ControlRateDisable;
tVidEncBitRate.nTargetBitrate = pAppData->nBitRate;
eError = OMX_SetParameter (pHandle, OMX_IndexParamVideoBitrate,
&tVidEncBitRate);


  • OMX_TI_IndexParamVideoEncoderPreset
 OMX_VIDEO_PARAM_ENCODER_PRESETTYPE tEncoderPreset;

  OMX_INIT_PARAM (&tEncoderPreset);
  tEncoderPreset.nPortIndex = OMX_VIDENC_OUTPUT_PORT;   
  eError = OMX_GetParameter (pHandle, OMX_TI_IndexParamVideoEncoderPreset,
                             &tEncoderPreset);
/* set preset for video communication applications */
tEncoderPreset.eEncodingModePreset = OMX_Video_Enc_Med_Speed_High_Quality;
tEncoderPreset.eRateControlPreset = OMX_Video_RC_Low_Delay;

 eError = OMX_SetParameter (pHandle, OMX_TI_IndexParamVideoEncoderPreset,                             
  &tEncoderPreset);


  • OMX_IndexParamVideoAvc
OMX_VIDEO_PARAM_AVCTYPE tAVCParams;

  OMX_INIT_PARAM (&tAVCParams);
  
  tAVCParams.nPortIndex = OMX_DirOutput;
eError = OMX_GetParameter(pHandle, OMX_IndexParamVideoAvc, &tAVCParams);

tAVCParams.eLevel = OMX_VIDEO_AVCLevel42;
tAVCParams.eProfile = OMX_VIDEO_AVCProfileBaseline;
tAVCParams.nPFrames = 89;
tAVCParams.nBFrames = 0;

  eError = OMX_SetParameter(pHandle, OMX_IndexParamVideoAvc, &tAVCParams);


 


FAQ-

 

1. I do not see Encoder generating B frames, how to configure to generate B frames?

Ans: For generating B frames following parameters should be set as per above explained indices-

/* Set encoder preset as storage */
tEncoderPreset.eRateControlPreset = OMX_Video_RC_Storage
/* set profile as Main or High */
tProfileLevel.eProfile = OMX_VIDEO_AVCProfileMain;

/* Set number of B frame as non zero */
tAVCParams.nBFrames = 1;


 

2. How to encode in interlace mode?

Ans: This is not supported in EZSDK 5.02.02.60, it requires codec header file to be available

3. How to modify static parameters of codec ?

Ans: For interlace encoding codec parameters needs to be set for interlace encoding. Please note encoder would expect field separated mode, in same buffer. Same as decoder NV12 output for interlace content. This exmaple shows modification of static parameter.

OMX_VIDEO_PARAM_STATICPARAMS tStaticParam;
OMX_INIT_PARAM (&tStaticParam);
tStaticParam.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

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

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

/* setting Interlace mode */
tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.inputContentType = IVIDEO_INTERLACED;
tStaticParam.videoStaticParams.h264EncStaticParams.bottomFieldIntra = 0;
tStaticParam.videoStaticParams.h264EncStaticParams.interlaceCodingType = IH264_INTERLACE_FIELDONLY_ARF;

tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.encodingPreset = XDM_DEFAULT;
tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.rateControlPreset = IVIDEO_STORAGE;


tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra4x4Enable = 0x1f;
tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra8x8Enable = 0x1f;



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


For the parameter settings, please refer to codec user guide. Also Please note, parameter setting should be done post OMX_IndexParamPortDefinition index is done.


 4. How to modify dynamic parameters?

Ans: It is similar to above static parameter example, with index used for dynamic parameters.

 /* before creating use set_parameters, for run-time change use set_config
all codec supported parameters can be set using this index */

OMX_VIDEO_CONFIG_DYNAMICPARAMS tDynParams;
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);

  5. How to generate SPS / PPS in other than first frame as well ? Also How to enable VUI generation ?

 OMX_INIT_PARAM (&tStaticParam);

tStaticParam.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

eError = OMX_GetParameter (pHandle, OMX_TI_IndexParamVideoStaticParams,
&tStaticParam);
 
 tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.encodingPreset = XDM_USER_DEFINED;

 tStaticParam.videoStaticParams.h264EncStaticParams.numTemporalLayer = IH264_TEMPORAL_LAYERS_1;

/* for base profile */
tStaticParam.videoStaticParams.h264EncStaticParams.transformBlockSize = IH264_TRANSFORM_4x4;
tStaticParam.videoStaticParams.h264EncStaticParams.entropyCodingMode = IH264_ENTROPYCODING_CAVLC;
/* for base profile end */

 /* for the mask bits, please refer to codec user guide */
 tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluControlPreset = IH264_NALU_CONTROL_USERDEFINED;
 tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskStartOfSequence |= 0x2180;
 tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskIDRPicture |= 0x2180;
 tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskIntraPicture |= 0x2180;
 tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskNonIntraPicture |= 0x2180;
 tStaticParam.videoStaticParams.h264EncStaticParams.nalUnitControlParams.naluPresentMaskEndOfSequence |= 0x2180;

 tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.vuiCodingPreset = IH264_VUICODING_USERDEFINED; 
 tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.aspectRatioInfoPresentFlag = 0;
 tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.aspectRatioIdc = 0;
 tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.videoSignalTypePresentFlag = 0;
 tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.videoFormat = IH264ENC_VIDEOFORMAT_NTSC;
 tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.videoFullRangeFlag = 0;
 tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.timingInfoPresentFlag = 0;
 tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.hrdParamsPresentFlag = 1;
 tStaticParam.videoStaticParams.h264EncStaticParams.vuiCodingParams.numUnitsInTicks = 1000;

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

 6. Which codecs/compression formats are supported in OMX VENC component?

Ans: The VENC component suppports H264 and MPEG4/H263 encoding.

 7. How to modify static/dynamic parameters for MPEG4/H263 Encoder?

Ans: This is similar to the process for setting static/dynamic parameters for H264

 
/* For setting Static Parameters */
OMX_VIDEO_PARAM_STATICPARAMS tStaticParams;
OMX_INIT_PARAM (&tStaticParams);
tStaticParams.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

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

tStaticParams.videoStaticParams.mpeg4EncStaticParams.videnc2Params.encodingPreset =
      XDM_USER_DEFINED;

tStaticParams.videoStaticParams.mpeg4EncStaticParams.vopTimeIncrementResolution = g_Framerate;

eError = OMX_SetParameter(pHandle, OMX_TI_IndexParamVideoStaticParams,
                           &tStaticParams);
 
/* For setting Dynamic Parameters */
OMX_VIDEO_CONFIG_DYNAMICPARAMS tDynParams;
OMX_INIT_PARAM (&tDynParams);

tDynParams.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

eError = OMX_GetParameter (pHandle, OMX_TI_IndexParamVideoDynamicParams,
&tDynParams);

tDynParams.videoDynamicParams.mpeg4EncDynamicParams.videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER;

eError = OMX_SetParameter (pHandle, OMX_TI_IndexParamVideoDynamicParams,
&tDynParams);

 8. Where can I find information about static/dynamic parameters of supported codecs/compression formats?

Ans: From EZSDK release 05.03.00.09 which uses OMX 05.02.00.26, all the static and dynamic parameters of supported codecs have been made available from OMX through custom extensions (eg., OMX_VIDEO_PARAM_STATICPARAMS, OMX_VIDEO_CONFIG_DYNAMICPARAMS). The codec interface header files are available in the OMX package under \ti\omx\interfaces. Individual codec User Guide is available under ti\omx\docs.

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article VENC here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article VENC here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article VENC here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article VENC here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article VENC here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article VENC here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article VENC here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article VENC here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article VENC here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity