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.

slices output on Ezsdk

Hi,

  I wanted to get video output as slices instead of full frame.My board is 8168 Evm.I use Ezsdk 5_05_02_00.

  Does omx encoder  surpport mul slices output on Ezsdk 5_05_02_00 ? If it surpport ,can you tell how to set the encoder parameters?

  Thank you very much.

 tory

  • Hello,

    OMX Video Encoder Component (VENC)
    The VENC component is a video encode component that has one input port andone output port. The job of the VENC is to encode the raw frames provided to it.
    -Supports H264 and MPEG4 encode. It does not support any other   compression format.
    -Supports   only  YUV420 semiplannerOMX_COLOR_FormatYUV420PackedSemiPlanar)
    - Supports encoding of I & P and B frames.
    - Supports run time configuration of all dynamic parameters supported by the   codec using OMX_GetConfig and OMX_SetConfig apis
    -Without processing at the most 8 buffers can be queued up.
    -Does not support slice mode encoding

    Best Regards,

    Margarita

  • Hi Margarita,

      Thank you for your reply.

      You say that OMX VENC does not support slice mode encoding.But now our product must support slice mode encodeing.Can you give me some advice?Any other sdk support slice mode encoding.Or when do you do it for surpporting slice mode on ezsdk?

      Thank you very much

    tory

  • Hi ,

    (1)  if i install ezsdk overlay package,does omx encoder support slices mode encodeing?

    (2) Does RDK support slices mode encodeing?

    (3) Is RDK compatible with our customed dm8168?


  • Hi,

    The encoder in EZSDK does support slices - it just doesn't support the ability to extract the slices separately as they are encoded.

    To get slices with a specific maximum size from the encoder, you want something like this in the initial configuration:


    OMX_VIDEO_PARAM_DYNAMICPARAMS dynamic_params;

    OMX_INIT_PARAM(&dynamic_params);
    dynamic_params.nPortIndex = OMX_VIDENC_OUTPUT_PORT;

    OMX_GetParameter(encoder_handle, OMX_TI_IndexParamVideoDynamicParams, &dynamic_params);

    IH264ENC_DynamicParams *h264_params = &dynamic_params.videoDynamicParams.h264EncDynamicParams;

    h264_params->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_USERDEFINED;
    h264_params->sliceCodingParams.sliceMode         = IH264_SLICEMODE_BYTES;
    h264_params->sliceCodingParams.sliceUnitSize     = 1300;
    h264_params->sliceCodingParams.streamFormat      = IH264_BYTE_STREAM;

    OMX_SetParameter(encoder_handle, OMX_TI_IndexParamVideoDynamicParams, &dynamic_params);


    (Note that I extracted that bit of code from a larger codebase and haven't tested it in isolation - there might be other parameters needed to make it work.)

    The above makes the encoder generate smaller slices, but they are still mashed together in the OMX output buffers.  To extract the slices individually, scan through the output for start codes (four bytes in a row with values 0 0 0 1) and remove all the blocks in between.  These should be 1200-1300 bytes each (except possibly the last one, being smaller), and the first byte of each will be a NAL unit header.

    I believe there are also modes to make slices across specific macroblock ranges, but I haven't tried to use that at all.  (It would depend on what you want the slices for - the above size-limited slices are what you want for single NAL unit mode RTP packets when talking to legacy RTP devices which can't handle non-interleaved mode.)

    Regards,

    - Mark

  • Hi Mark,

      Thank you for your reply.

      I set the ecoder parameters according to your advice.But it does not work for mul slices output.I donot know if some parameters are not set.Can you give some advice?And please give me other parameters about encoder slices output.

     Thank you very much.

    tory

  • Hi,

    How big are the slices in the output you are now getting?  Does the encoder generate any errors?  I can't really say anything useful about what might be failing without more information.

    For one thing which could be wrong, the H.264 encoder user guide says "sliceMode == IH264_SLICEMODE_BYTES is only supported ... [when] entropyCodingMode != IH264_ENTROPYCODING_CABAC", so make sure that you are using baseline profile only.

    Regards,

    - Mark

  • Hi Mark,

    I get the output per frame is only one slice.The encoder is ok.

    Yes,now i set  "sliceMode == IH264_SLICEMODE_BYTES",and using baseline.Is anything changed?Is some prameter set?

    tory

  • Tory,

    How did you parse the packets to confirm that there are not multiple slices within the buffer?

  • What version of ezsdk is needed for slice mode?  I am using ezsdk 5_04_00_11

  • The method described above (and relatedly in http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/717/t/279642.aspx ) works in at least EZSDK 5.04.00.11, 5.05.01.04 and 5.05.02.00.

    - Mark

  • Mark,

    That link was very helpful, but when I try setting:

    tStaticParam.videoStaticParams.h264EncStaticParams.videnc2Params.encodingPreset = XDM_USER_DEFINED;

    in EZSDK version 5.04.00.11, like I do in the following code, it builds, but I get a peculiar runtime error of OMX_ErrorBadParameter.  If I comment out the setting of encodingPreset, it runs (with only 1 slice per frame)

      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;

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

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

    Here is the dump of the output...

    execute_demo
    output file: sample.h264
    bit_rate: 1000000
    frame_rate: 60
    num_frames: 1000
    mode: 1080p
    display_id: 1
     Capture-Encode example
    ===============================
     OMX_Init completed
     UIAClient is ready to send a UIA configuration command
    UIAClient received UIA_CONFIGURE_ACK
    UIAClient is done sending requests
    UIAClient is ready to send a UIA configuration command
    UIAClient received UIA_CONFIGURE_ACK
    UIAClient is done sending requests
     openeing file
     capture compoenent is created
     control TVP compoenent is created
    Buffer Size computed: 3110400
    set input port params (width = 1920, height = 1080)enable capture output port
    got eventEnable/Disable Event
     dei compoenent is created
    set input port params (width = 1920, height = 1080)
    set output port params (width = 1920, height = 1080)set output port params (width = 1920, height = 1080)set n
    umber of channelsset input resolutionset output resolutionenable dei input port
    got eventEnable/Disable Event
    enable dei output port 0
    got eventEnable/Disable Event
    enable dei output port 1
    got eventEnable/Disable Event
     encoder compoenent is created
    found handle 0x133708 for component OMX.TI.VPSSM3.VFDC
     got display handle
    found handle 0x137210 for component OMX.TI.VPSSM3.CTRL.DC
    Buffer Size computed: 4147200
    set input port params (width = 1920, height = 1080)setting input and output memory type to defaultenable inpu
    t port
    got eventEnable/Disable Event
     connect call for capture-Dei
      connect call for dei- encoder
      connect call for dei-display
     got eventState changed to: OMX_StateIdle
     Capture outport buffers allocated
     got eventState changed to: OMX_StateIdle
     Capture is in IDLE state
     Dei input port use buffer done
      DEI outport buffers allocated
     got eventState changed to: OMX_StateIdle
     DEI is in IDLE state
     encoder input port use buffer done
      encoder outport buffers allocated
     got event*** unrecoverable error: OMX_ErrorBadParameter (0x80001005)
    Press a key to proceed

  • I found the answer.  When changing to encodingPreset = XDM_USER_DEFINED, one needs to also set some other parameters or it will complain about bad parameters.

     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 */