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.

How to set to make the decoder of the demo stop?

This is a continue to my previous question about running omtb encoder and decoder, http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/717/t/151859.aspx#556495

 I want to encode and decode yuv420 sequences (test sequences instead of captured in real time) using the fread_venc_fwrite.oms and fread_vdec_fwrite.oms.  I can run successfully the encode now which can exits by using the new SDK of EZSDK 5_03_01_15 and modify the encoder setting as you suggested "

Please change the following line in the omtb script.

Current: omx setp 0 h264venc filereset_flag enable

Modify to: omx setp 0 h264venc filereset_flag disable

When the flag is enabled, omtb will reset the file pointer to the begining of the file when it reaches end of file.

However, at the decoder, it can not stop and there are errors. I guess it is due to the incorrect configuration for decoding the file.

I past the script of fread_vdec_fwrite.oms here:

 

#omx omtb_dbg_lvl 0x10
#omx omtb_dbg_lvl 0x08
omx api init
omx setp 0 h264vdec framerate 60
omx setp 0 h264vdec numinbuf 6
omx setp 0 h264vdec inbufsize 152064
omx setp 0 h264vdec frame_width 352
omx setp 0 h264vdec frame_height 288
omx setp 0 h264vdec numoutbuf 6
omx setp 0 h264vdec outbufsize 152064
omx setp 0 h264vdec inbuf allocate
omx setp 0 h264vdec outbuf allocate
omx setp 0 h264vdec data_opmode file
omx setp 0 h264vdec infile /usr/share/ti/data/videos/dm816x_foreman_cif250_encode.264
omx setp 0 h264vdec outfile /usr/share/ti/data/videos/dm816x_foreman_cif250_420p.yuv
omx api gethandle h264vdec 0 0
omx api sendcommand port h264vdec 0 enable 0
omx api sendcommand port h264vdec 0 waitforsem 0
omx api sendcommand port h264vdec 0 enable 1
omx api sendcommand port h264vdec 0 waitforsem 1
omx api sendcommand state h264vdec 0 idle
omx api sendcommand state h264vdec 0 waitforsem
sleep 500
omx api sendcommand state h264vdec 0 exec
omx api sendcommand state h264vdec 0 waitforsem
sleep 120000
omx api sendcommand state h264vdec 0 idle
omx api sendcommand state h264vdec 0 waitforsem
omx api sendcommand state h264vdec 0 loaded
omx api sendcommand state h264vdec 0 waitforsem
omx api freehandle h264vdec 0
omx api uninit

The script of fread_venc_fwrite.oms is as follows:

#omx omtb_dbg_lvl 0x10

#omx omtb_dbg_lvl 0x08
omx api init
omx setp 0 h264venc numinbuf 6
omx setp 0 h264venc inbufsize 152064
omx setp 0 h264venc frame_width 352
omx setp 0 h264venc frame_height 288
omx setp 0 h264venc numoutbuf 6
omx setp 0 h264venc inbufsize_flag enable
omx setp 0 h264venc outbufsize_flag enable
omx setp 0 h264venc outbufsize 152064
omx setp 0 h264venc inbuf allocate
omx setp 0 h264venc outbuf allocate
omx setp 0 h264venc data_opmode file
omx setp 0 h264venc data_ipmode file
#omx setp 0 h264venc filereset_flag enable
omx setp 0 h264venc filereset_flag disable
omx setp 0 h264venc infile /usr/share/ti/data/videos/foreman_cif_sp250f.yuv
omx setp 0 h264venc outfile /usr/share/ti/data/videos/dm816x_foreman_cif250_encode.264
#Q-16 format 2^16 * framerate
omx setp 0 h264venc framerate 3932160
omx api gethandle h264venc 0 0
omx api getparam h264venc 0 0 1 OMX_IndexParamVideoBitrate
omx setp 0 h264venc OMX_IndexParamVideoBitrate nTargetBitrate 2048000
omx setp 0 h264venc OMX_IndexParamVideoBitrate eControlRate variable
#eRateControlPreset is set to "disable => CBR" or "hq(high quality) => VBR"
#omx setp 0 h264venc OMX_TI_IndexParamVideoEncoderPreset eRateControlPreset hq
#omx setp 0 h264venc OMX_TI_IndexParamVideoEncoderPreset eRateControlPreset disable
omx api setparam h264venc 0 0 1 OMX_IndexParamVideoBitrate
omx api sendcommand port h264venc 0 enable 0
omx api sendcommand port h264venc 0 waitforsem 0
omx api sendcommand port h264venc 0 enable 1
omx api sendcommand port h264venc 0 waitforsem 1
omx api sendcommand state h264venc 0 idle
omx api sendcommand state h264venc 0 waitforsem
sleep 500
omx api sendcommand state h264venc 0 exec
omx api sendcommand state h264venc 0 waitforsem
#sleep 120000
omx notify h264venc 0 eos
omx api sendcommand state h264venc 0 idle
omx api sendcommand state h264venc 0 waitforsem
omx api sendcommand state h264venc 0 loaded
omx api sendcommand state h264venc 0 waitforsem
omx api freehandle h264venc 0
omx api uninit

The error is as below:

OMTB> sleep 120000

OMTB-OMTB script reading task sleeping for 120000 msecs

OMTB-Entering <Thread, instance #> : < OMTB_ClientApiTsk, 0 >

...

OMTB-Entering <Thread, instance #> : < OMTB_FileRead, 0>

OMTB-In OMTB_ClientEnventHandler: OMX_EventError - 800100b

OMTB-FAIL: OMX_ErrorStream Corrrupt

....

Leaving <Function: OMTB_CotexA8Task>

it then stay here and not goes on.

It would be appreciated much if you can attach two availble script for both encoder and decoder for the coding of  yuv420 sequence.

Thank you very much!

 

  • When i add omx setp 0 h264vdec filereset_flag disable  ahead omx setp 0 h264vdec infile  in the fread_vdec_fwrite.oms as pasted above, the decoder can exit.

    However, the reconstructed file size is smaller than original test sequence size.  (1) When i use h.264 software to decode the bitstream, the frame number is still smaller than original coding frame number and is different from the frame number decoded by TI board using fread_vdec_fwrite.oms script.  (2) the first several rows of pixels over each reconstructed images decoded by TI board are very noisy while those decoded by H.264 software (JM17.0) are more prone to original images.  I guess there is still problem over the script.  Can you help me to find the solutions?

    By the way, i edition of my sdk is EZSDK 5_03_01_15.

    If you can send me the files which can work well, i would be very appreciate it.  

    I notice the configuration over the two script which using template 0 are not the best confiuration (not the high profile). Do you have the avialble configuration files for the configurations which are the default configuration for H.264? 

    Looking forward to your reply! 

    Thank you so much! 

     

     

  • spring,

    You could also look at examples in component-sources/omx_xx  folder. It is IL client based app, and EOS flag can be given to decoder to exit. decode_display example uses EOS for the decoder.

    Regards

    Vimal

  • Hi, Vimal Jain

          I open the folder under component-sources/omx_05_02_00_30/examples/ti/omx/demos/decode_display/src. I can see the files such as ilclient.c ilcient.h ilcient_utils.c ilcient_utils.h. There is no files about  .omx. Do you mean i should rebuild decode_display  (or use decode_a8host_debug.xv5T under ti-omx folder) and should not use omtb_dm81xxbm_a8host.xv5T for the decoding?

         Thank you so much! 

  • Spring,

    That's right, I meant you can build these apps and try instead of OMTB.

    Regards

    Vimal

  • I wonder whether the demo only support a kind of configuration for the encoder.

     Except for image size, bitrate control related setting such as omx setp 0 h264enc  OMX_TI_IndexParamVideoEncoderPreset eRateControlPreset hq/userdef/hsmq/msmq/default, I found t that even if i change the configuration, such as motion estimation parameters of searching range, the supporting of intraprediction related parameters, the coding results are the same.

    Do that mean user have no right to change the parameter setting related with coding configration? If so, what is the used default configuration? 

    Thank you very much!

    Regards 

     

  • Spring,

    Please follow IL client examples in omx-xx/examples folder. Encode parameters can be chnaged in that, and it has examples as well. Also

    see following wiki topic

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

    Regards

    Vimal

  • 1. Can not those parameters be modified directly through script of xxx.oms? That would be more easy to do.

    2. If i only code the test sequences without capturation operation, does that means i should only change the ilcinet.c and ilcient_utils.h under omx/demos/encode/src ? 

    3. For the default configuration in omtb_dm816xxbm_a8host.xv5T where my setting to parameters can affect the coding results, what about its coding performance? Dose it has similar coding performance with the high profile configuration with many coding tools enabled (such as intra prediction nine directions for 4x4 blocks, 4x4, 8x4/4x8 inter prediction, loopfilter)?  If so, i can simply use the default configuration in  omtb_dm816xxbm_a8host.xv5T to run our sequences.

    Thank you very much! 

     

  • I want to obtain such configuration as:

    #omx omtb_dbg_lvl 0x10



    #omx omtb_dbg_lvl 0x08

    omx api init

    omx setp 0 h264venc frame_width 352
    omx setp 0 h264venc frame_height 288
    omx setp 0 h264venc inbufsize 152064
    omx setp 0 h264venc outbufsize 152064

    omx setp 0 h264venc infile /usr/share/ti/data/videos/foreman_cif_sp250f.yuv
    omx setp 0 h264venc outfile /usr/share/ti/data/videos/enc_foreman_cif_1000000_VBR_final.h264

    omx setp 0 h264venc inbufsize_flag enable
    omx setp 0 h264venc outbufsize_flag enable
    omx setp 0 h264venc inbuf allocate
    omx setp 0 h264venc outbuf allocate
    omx setp 0 h264venc data_opmode file
    omx setp 0 h264venc data_ipmode file
    omx setp 0 h264venc filereset_flag disable


    omx setp 0 h264venc numinbuf 1
    omx setp 0 h264venc numoutbuf 1
    omx api gethandle h264venc 0 0

    #Framerate is in Q16 Format 30 * 2^16
    omx setp 0 h264venc framerate 1966080
    #omx setp 0 h264venc OMX_IndexConfigVideoFramerate xEncodeFramerate 1966080
    #omx setp 0 h264venc OMX_IndexParamVideoPortFormat xFramerate 1966080

    #omx setp 0 h264venc OMX_TI_IndexConfigVideoPixelInfo nWidth 352
    #omx setp 0 h264venc OMX_TI_IndexConfigVideoPixelInfo nHeight 288

    omx api getparam h264venc 0 0 0 OMX_IndexParamPortDefinition
    omx setp 0 h264venc OMX_IndexParamPortDefinition video.nStride 352
    omx setp 0 h264venc OMX_IndexParamPortDefinition nBufferSize 152064
    omx setp 0 h264venc OMX_IndexParamPortDefinition video.nBitrate 1000000
    omx setp 0 h264venc OMX_IndexParamPortDefinition video.xFramerate 1966080
    omx api setparam h264venc 0 0 0 OMX_IndexParamPortDefinition


    #eRateControlPreset is set to "disable=>CBR" or "hq(high quality)=>VBR"
    omx api getparam h264venc 0 0 1 OMX_TI_IndexParamVideoEncoderPreset
    omx setp 0 h264venc OMX_TI_IndexParamVideoEncoderPreset eRateControlPreset hq
    #omx setp 0 h264venc OMX_TI_IndexParamVideoEncoderPreset eRateControlPreset disable
    omx api setparam h264venc 0 0 1 OMX_TI_IndexParamVideoEncoderPreset

    omx api getparam h264venc 0 0 1 OMX_IndexParamVideoBitrate
    omx setp 0 h264venc OMX_IndexParamVideoBitrate nTargetBitrate 1000000
    #omx setp 0 h264venc OMX_IndexParamVideoBitrate eControlRate disable
    omx setp 0 h264venc OMX_IndexParamVideoBitrate eControlRate variable
    #omx setp 0 h264venc OMX_IndexParamVideoBitrate eControlRate constant
    omx api setparam h264venc 0 0 1 OMX_IndexParamVideoBitrate


    #SETCONFIG FOR CHANNEL INDEX NAME FOR VENC COMPONENT
    #omx setp 0 h264venc chan_name h264venc_fq_1
    #omx api setconfig h264venc 0 0 1 OMX_TI_IndexConfigChannelName

    omx api getparam h264venc 0 0 0 OMX_TI_IndexParamBuffMemType
    omx setp 0 h264venc OMX_TI_IndexParamBuffMemType eBufMemoryType default
    omx api setparam h264venc 0 0 0 OMX_TI_IndexParamBuffMemType


    omx setp 0 h264venc maxfilesize 2170368000

    omx api getparam h264venc 0 0 1 OMX_IndexParamVideoProfileLevelCurrent
    #omx setp 0 h264venc OMX_IndexParamVideoProfileLevelCurrent eProfile main
    #omx setp 0 h264venc OMX_IndexParamVideoProfileLevelCurrent eProfile baseline
    omx setp 0 h264venc OMX_IndexParamVideoProfileLevelCurrent eProfile high
    omx setp 0 h264venc OMX_IndexParamVideoProfileLevelCurrent eLevel 5.1

    #omx api getparam h264venc 0 0 1 OMX_IndexParamVideoAvc
    omx getp 0 h264venc OMX_IndexParamVideoAvc
    omx setp 0 h264venc OMX_IndexParamVideoAvc bEntropyCodingCABAC enable
    omx setp 0 h264venc OMX_IndexParamVideoAvc eProfile high
    omx setp 0 h264venc OMX_IndexParamVideoAvc eLevel 5.1
    omx setp 0 h264venc OMX_IndexParamVideoAvc nRefFrames 4
    #Refrence Index in Bwd Frames list
    omx setp 0 h264venc OMX_IndexParamVideoAvc nRefIdx10ActiveMinus1 4
    omx setp 0 h264venc OMX_IndexParamVideoAvc nRefIdx11ActiveMinus1 4
    omx setp 0 h264venc OMX_IndexParamVideoAvc bWeightedPPrediction enable
    omx setp 0 h264venc OMX_IndexParamVideoAvc eLoopFilterMode enable
    #omx api setparam h264venc 0 0 0 OMX_IndexParamVideoAvc

    #omx getp 0 h264venc OMX_TI_IndexParamVideoIntraPredictionSettings
    omx setp 0 h264venc OMX_TI_IndexParamVideoIntraPredictionSettings nLumaIntra4x4Enable 0x1FF
    omx setp 0 h264venc OMX_TI_IndexParamVideoIntraPredictionSettings nLumaIntra8x8Enable 0x1FF
    omx setp 0 h264venc OMX_TI_IndexParamVideoIntraPredictionSettings nLumaIntra16x16Enable 0x0F
    omx setp 0 h264venc OMX_TI_IndexParamVideoIntraPredictionSettings nChromaIntra8x8Enable 0x0F
    omx setp 0 h264venc OMX_TI_IndexParamVideoIntraPredictionSettings eChromaComponentEnable cb_cr_both

    #omx api getparam h264venc 0 0 0 OMX_TI_IndexConfigVideoMESearchRange
    omx setp 0 h264venc OMX_TI_IndexConfigVideoMESearchRange eMVAccuracy quarterpel
    omx setp 0 h264venc OMX_TI_IndexConfigVideoMESearchRange nHorSearchRangeP 128
    omx setp 0 h264venc OMX_TI_IndexConfigVideoMESearchRange nVerSearchRangeP 128
    omx setp 0 h264venc OMX_TI_IndexConfigVideoMESearchRange nHorSearchRangeB 128
    omx setp 0 h264venc OMX_TI_IndexConfigVideoMESearchRange nVerSearchRangeB 128

    omx setp 0 h264venc OMX_IndexParamVideoMotionVector bUnrestrictedMVs disable
    omx setp 0 h264venc OMX_IndexParamVideoMotionVector bFourMV disable
    omx setp 0 h264venc OMX_IndexParamVideoMotionVector sXSearchRange 128
    omx setp 0 h264venc OMX_IndexParamVideoMotionVector sYSearchRange 128

    omx setp 0 h264venc OMX_TI_IndexParamVideoMEBlockSize eMinBlockSizeP 4x4
    omx setp 0 h264venc OMX_TI_IndexParamVideoMEBlockSize eMinBlockSizeB 4x4

    omx setp 0 h264venc OMX_TI_IndexParamVideoTransformBlockSize eTransformBlocksize adaptive


    #omx getp 0 h264venc OMX_TI_IndexConfigChannelName


    # Add to TI_IndexParamVideoFrameDataContentSettings start
    #omx setp 0 h264venc OMX_TI_IndexParamVideoFrameDataContentSettings eContentType interlaced
    #omx setp 0 h264venc OMX_TI_IndexParamVideoFrameDataContentSettings eInterlaceCodingType mbaff
    #omx api setparam h264venc 0 0 1 OMX_TI_IndexParamVideoFrameDataContentSettings
    # Add to TI_IndexParamVideoFrameDataContentSettings end


    omx getp 0 h264venc

    omx api sendcommand port h264venc 0 enable 0
    omx api sendcommand port h264venc 0 waitforsem 0
    omx api sendcommand port h264venc 0 enable 1
    omx api sendcommand port h264venc 0 waitforsem 1
    omx api sendcommand state h264venc 0 idle
    omx api sendcommand state h264venc 0 waitforsem
    sleep 500
    omx api sendcommand state h264venc 0 exec
    omx api sendcommand state h264venc 0 waitforsem
    #sleep 180000
    omx notify h264venc 0 eos
    omx api sendcommand state h264venc 0 idle
    omx api sendcommand state h264venc 0 waitforsem
    omx api sendcommand state h264venc 0 loaded
    omx api sendcommand state h264venc 0 waitforsem
    omx api freehandle h264venc 0
    omx api uninit



     

    There is no difference over the coding results before and after I set the parameters such as

    omx setp 0 h264venc OMX_TI_IndexParamVideoMEBlockSize eMinBlockSizeP 4x4
    omx setp 0 h264venc OMX_TI_IndexParamVideoMEBlockSize eMinBlockSizeB 4x4  

    Do you mean omtb_dm81xxbm_a8host.xv5T dose not support the setting of such coding parameters?

    If I use the encode under demo folder with ilclient modification,

    (1) I do not know how to change the parameters such as   eMinBlockSizeP since i donot know the parameter name. 

          Do you have examples showing how such parameters should be set?  

    (2) How to compile the modified ilcient  demo? Can you give me some instructions?

    Thank you! 

     

  • In order to be able to configure the parameters, I try to modify the file of ilcinet.c under omx/demos/encode/src. 

    Then, i rebuid the code by excuting  make omx

    However, i find there is no difference before and after i modify some settings. Can you give me some hints where the problem is?

    I post the modified code here:

    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_FRAMEDATACONTENTTYPE tFrameType;

    //lan add
    OMX_VIDEO_PARAM_AVCTYPE tAVCParams;

    pHandle = pAppData->pEncHandle;

    /* Number of frames to be encoded, not used by defaualt */
    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;
    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 = pAppData->eCompressionFormat;
    tPortDef.format.video.xFramerate = (pAppData->nFrameRate << 16);
    tPortDef.format.video.nBitrate = pAppData->nBitRate;

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

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

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

    /*
    enum OMX_VIDEO_CONTROLRATETYPE {
    OMX_Video_ControlRateDisable, OMX_Video_ControlRateVariable, OMX_Video_ControlRateConstant, OMX_Video_ControlRateVariableSkipFrames,
    OMX_Video_ControlRateConstantSkipFrames, OMX_Video_ControlRateMax = 0x7FFFFFFF
    }
    */
    tVidEncBitRate.eControlRate = OMX_Video_ControlRateVariable; //OMX_Video_ControlRateDisable;
    tVidEncBitRate.nTargetBitrate = pAppData->nBitRate;
    eError = OMX_SetParameter (pHandle, OMX_IndexParamVideoBitrate,
    &tVidEncBitRate);

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

    /* 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 profile / level */
    if(pAppData->eCompressionFormat == OMX_VIDEO_CodingAVC) {
    tProfileLevel.eProfile = OMX_VIDEO_AVCProfileHigh;//OMX_VIDEO_AVCProfileBaseline;
    tProfileLevel.eLevel = OMX_VIDEO_AVCLevel42;//OMX_VIDEO_AVCLevel42;
    }
    else if (pAppData->eCompressionFormat == OMX_VIDEO_CodingMPEG4) {
    tProfileLevel.eProfile = OMX_VIDEO_MPEG4ProfileSimple;
    tProfileLevel.eLevel = OMX_VIDEO_MPEG4Level5;
    }
    else if (pAppData->eCompressionFormat == OMX_VIDEO_CodingH263) {
    tProfileLevel.eProfile = OMX_VIDEO_H263ProfileBaseline;
    tProfileLevel.eLevel = OMX_VIDEO_H263Level40;
    }


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

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

    /* example for h264 parameters settings */

    if(pAppData->eCompressionFormat == OMX_VIDEO_CodingAVC) {

    /* 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; //OMX_Video_Enc_High_Quality;//
    tEncoderPreset.eRateControlPreset = OMX_Video_RC_Low_Delay; //OMX_Video_RC_Storage;//

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

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



    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 = 30000;//90;
    tDynParams.videoDynamicParams.h264EncDynamicParams.interCodingParams.interCodingPreset = 1;
    tDynParams.videoDynamicParams.h264EncDynamicParams.interCodingParams.searchRangeHorP = 144;
    tDynParams.videoDynamicParams.h264EncDynamicParams.interCodingParams.searchRangeVerP = 32;
    tDynParams.videoDynamicParams.h264EncDynamicParams.interCodingParams.interCodingBias = IH264_BIASFACTOR_DEFAULT;
    tDynParams.videoDynamicParams.h264EncDynamicParams.interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_DEFAULT;
    tDynParams.videoDynamicParams.h264EncDynamicParams.interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_4x4;


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

    /* for interlace encoding */
    #if 0
    OMX_INIT_PARAM (&tStaticParam);

    tStaticParam.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

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

    tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.profile = IH264_HIGH_PROFILE;
    tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.level = IH264_LEVEL_42;

    /* setting I frame interval */
    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);
    #endif
    }


    if((pAppData->eCompressionFormat == OMX_VIDEO_CodingMPEG4) ||
    (pAppData->eCompressionFormat == OMX_VIDEO_CodingH263))
    {
    OMX_INIT_PARAM(&tStaticParam);
    tStaticParam.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

    eError =
    OMX_GetParameter(pHandle, OMX_TI_IndexParamVideoStaticParams,
    &tStaticParam);
    if (eError != OMX_ErrorNone)
    {
    ERROR ("failed to Encoder OMX_GetParameter StaticParams \n");
    }

    tStaticParam.videoStaticParams.mpeg4EncStaticParams.videnc2Params.encodingPreset
    = XDM_USER_DEFINED;
    tStaticParam.videoStaticParams.mpeg4EncStaticParams.vopTimeIncrementResolution
    = pAppData->nFrameRate;

    eError =
    OMX_SetParameter(pHandle, OMX_TI_IndexParamVideoStaticParams,
    &tStaticParam);
    if (eError != OMX_ErrorNone)
    {
    ERROR ("failed to Encoder OMX_SetParameter StaticParams \n");
    }
    }
    else
    {
    //lan for setting the parameters
    OMX_INIT_PARAM (&tStaticParam);

    tStaticParam.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

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

    tStaticParam.videoStaticParams.h264EncStaticParams.transformBlockSize = IH264_TRANSFORM_4x4;// IH264_TRANSFORM_ADAPTIVE; //when IH264_TRANSFORM_4x4 and IH264_TRANSFORM_ADAPTIVE, same results.
    tStaticParam.videoStaticParams.h264EncStaticParams.entropyCodingMode = IH264_ENTROPYCODING_CAVLC;// IH264_ENTROPYCODING_CABAC;
    tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.rateControlPreset = IVIDEO_STORAGE; //VBR; (IVIDEO_LOW_DELAY (CBR for video conference)
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.intraCodingPreset = IH264_INTRACODING_USERDEFINED;
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra4x4Enable = 0x1FF; //when 0x1f and 0x1ff, same results
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra8x8Enable = 0x1FF;
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra16x16Enable = 0xF;
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.chromaIntra8x8Enable = 0xF;
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.chromaComponentEnable = IH264_CHROMA_COMPONENT_CB_CR_BOTH;
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.interCodingPreset = IH264_INTERCODING_USERDEFINED;
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.searchRangeHorP = 144;
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.searchRangeVerP = 32;
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_4x4; //when 4x4 and 8x8, same results (less than 8 is not supported)
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.interCodingBias = IH264_BIASFACTOR_DEFAULT;
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_DEFAULT;
    tStaticParam.videoStaticParams.h264EncStaticParams.loopFilterParams.loopfilterPreset = IH264_LOOPFILTER_DEFAULT;

    eError = OMX_SetParameter (pHandle, OMX_TI_IndexParamVideoStaticParams,
    &tStaticParam);
    if (eError != OMX_ErrorNone)
    {
    ERROR ("failed to Encoder OMX_SetParameter StaticParams \n");
    }
    }

    /*
    OMX_INIT_PARAM (&tAVCParams);
    tAVCParams.nPortIndex = OMX_DirOutput;
    eError = OMX_GetParameter(pHandle, OMX_IndexParamVideoAvc, &tAVCParams);
    tAVCParams.eLevel = OMX_VIDEO_AVCLevel42;// OMX_VIDEO_AVCLevel42;
    tAVCParams.eProfile = OMX_VIDEO_AVCProfileHigh;//OMX_VIDEO_AVCProfileBaseline;
    tAVCParams.nPFrames = 29999;//89;
    tAVCParams.nBFrames = 0;
    tAVCParams.nRefFrames = 4;
    tAVCParams.nRefIdx10ActiveMinus1 = 3;
    tAVCParams.nRefIdx11ActiveMinus1 = 3;
    tAVCParams.bEnableUEP = OMX_FALSE;
    tAVCParams.bEnableFMO = OMX_FALSE;
    tAVCParams.bEnableASO = OMX_FALSE;
    tAVCParams.bEnableRS = OMX_FALSE;
    tAVCParams.nAllowedPictureTypes = 2;//?
    tAVCParams.bFrameMBsOnly = 1;
    tAVCParams.bMBAFF = OMX_FALSE;
    tAVCParams.bEntropyCodingCABAC = OMX_TRUE;
    tAVCParams.bWeightedPPrediction = OMX_TRUE;
    //tAVCParams.nWeightedBipredicitonMode = 1;//
    tAVCParams.bconstIpred = OMX_TRUE;//OMX_FALSE; //?? Enable/disable intra prediction
    tAVCParams.bDirect8x8Inference = OMX_FALSE;
    tAVCParams.nCabacInitIdc = 0;
    tAVCParams.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable;
    //tAVCParams.bDirectSpatialTemporal = OMX_FALSE; //spatial is the default
    //eError = OMX_SetParameter(pHandle, OMX_IndexParamVideoAvc, &tAVCParams);
    tAVCParams.bUseHadamard = 1;//
    eError = OMX_SetParameter (pHandle, OMX_IndexParamVideoAvc, &tAVCParams);
    if (eError != OMX_ErrorNone)
    {
    ERROR ("failed to Encoder OMX_IndexParamVideoAvc \n");
    }

    */

    return eError;
    }

    (1) I guess RDO may be controlled by  tEncoderPreset.eEncodingModePreset = OMX_Video_Enc_Med_Speed_High_Quality; //OMX_Video_Enc_High_Quality;//

    tEncoderPreset.eRateControlPreset = OMX_Video_RC_Low_Delay; //OMX_Video_RC_Storage;//

    Then, I set it as high quality and RC storage to get high performance. There is error:

    got event*** unrecoverable error: OMX_ErrorBadParameter


    How to fix this error?

    (2) When I set the coding tools as,  

    tStaticParam.videoStaticParams.h264EncStaticParams.transformBlockSize = IH264_TRANSFORM_4x4;// IH264_TRANSFORM_ADAPTIVE; //when IH264_TRANSFORM_4x4 and IH264_TRANSFORM_ADAPTIVE, same results.
    tStaticParam.videoStaticParams.h264EncStaticParams.entropyCodingMode = IH264_ENTROPYCODING_CAVLC;// IH264_ENTROPYCODING_CABAC;

    When i change the settings, it leads to same coding results, which means it does not work for the changing of parameters.

    Similar phenomenons are observed for other parameters

    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra4x4Enable = 0x1FF; //when 0x1f and 0x1ff, same results
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra8x8Enable = 0x1FF;
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra16x16Enable = 0xF;
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.chromaIntra8x8Enable = 0xF;

    (3) I don't know how to set the reference frame numbers. When I use tAVCParams.nRefFrames = 4 to do that, the actual reference number is still 1.

    I have no idea how to solve the problem. I have take a long time try to find the solution and still have no idea to tacle that.  I just want to test the performance when all coding tools are opened (best coding performance) of TI codec. 

    Wishing to get your help and advices!

    Thank you!

     

  • Spring,

    I would suggest you to go through h264 encoder user guide, before changing the parameters. Some of the parameter combination would not be allowed and will result in errors. Also I assume you have gone through wiki, i suggested. For changing any parameter, ENCODING PRESET has to be defined as XDM_USER_DEFINED. 

    Regards

    Vimal

  • I have gone through wiki http://processors.wiki.ti.com/index.php/OMX_VENC

    When I change parameters such as  intraCodingParams, i have set as  IH264_INTRACODING_USERDEFINED as the example below. There are no errors in the rebuild process. In this case, however there is still no difference over the coding bitstream. 

    When I define videnc2Params.encodingPreset as XDM_USER_DEFINED, there will be error in the coding.  As you said, may be some combination is not allowed, how can i know what combinations are not allowed?  


    Do you mean the H.264 Encoder on HDVICP2 and Media Controller Based Platform User's Guide? However, it only supply the name of parameters. It dose not tell us how to access the paramters in ilclient interfaces, such as through what data structure? Do you have detailed instruction about how to access the parameters?

    Thank you very much!


    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.intraCodingPreset = IH264_INTRACODING_USERDEFINED;
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra4x4Enable = 0x1FF; //when 0x1f and 0x1ff, same results
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra8x8Enable = 0x1FF;
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.lumaIntra16x16Enable = 0xF;
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.chromaIntra8x8Enable = 0xF;
    tStaticParam.videoStaticParams.h264EncStaticParams.intraCodingParams.chromaComponentEnable = IH264_CHROMA_COMPONENT_CB_CR_BOTH;
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.interCodingPreset = IH264_INTERCODING_USERDEFINED;
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.searchRangeHorP = 144;
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.searchRangeVerP = 32;
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_4x4; //when 4x4 and 8x8, same results (less than 8 is not supported)
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.interCodingBias = IH264_BIASFACTOR_DEFAULT;
    tStaticParam.videoStaticParams.h264EncStaticParams.interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_DEFAULT;
    tStaticParam.videoStaticParams.h264EncStaticParams.loopFilterParams.loopfilterPreset = IH264_LOOPFILTER_DEFAULT;

    Thank you so much!

  • Spring,

    For setting any h264 specific parameter use tStaticParam.videoStaticParams.h264EncStaticParams. It is exactly as codec supported parameter. All the fields are same as codec supported static parameter.If encodingPreset results in error, It will not set any parameter and hence no change in bitstream. Please refer to below user guide in EZSDK for all teh parameters supported. btw, did you try taking code snippet from wiki as it is and see if creates any difference.

    component-sources/omx_05_02_00_XX/src/ti/omx/docs/H264_Encoder_HDVICP2_UserGuide.pdf

    Regards

    Vimal

  • Thank you for your good suggestions.

    After set XDM_USERDEFINED, and rebuild the whole SDK, i can set some parameters.

    By the way, i have another question, as belows, when I change   tEncoderPreset.eEncodingModePreset among  OMX_Video_Enc_Med_Speed_High_Quality, OMX_Video_Enc_High_Quality, and OMX_Video_Enc_User_Defined, there is no dfference over the coding bitstream.  Is it supported by SDK?

    Using the similar configrations between JM18.3 and the best configration of TI h.264 codec, i found TI h.264 codec had a performance loss about 1dB.  For JM18.3 configaration, i have disable inter 8x4/4x8/4x4 partions, disable the rate distortion optimization, set the reference frame number as 1 (to be consistent with the best configration of TI board as far I can set).  Is it strange? Or because i have not configure the parameters fully?

     

    /* 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; //OMX_Video_Enc_High_Quality;//
    tEncoderPreset.eRateControlPreset = OMX_Video_RC_Low_Delay; //OMX_Video_RC_Storage;//

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