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.

force HEVC encoder generate IDR frame in mcsdk-video demo

Hi guys,

I am using the demo of mcsdk-video for a TS streaming. It can produce nice TS stream now. However, ffplay must be start in front of streaming process. Otherwise, it will report "PPS id out of range error". It seems that ffplay need IDR frame to parse picture information. How to tell HEVC encoder generate IDR frame which includes PPS/SPS? I played a little bit with the config file of hevc encoder which is included with mcsdk-video. I tried to change parameters like "generateHeader", "intraRefreshRate". It doesn't work.

I am using mcsdk_video_2_2_0_42. I know there are new version mcsdk_video. I just need finish some work on old version first then porting new version sdk to our ARM board.

So do you guys know how to force HEVC encoder generate PPS/SPS periodically? 

  • Hi ruisucom,

        To generate IDR Frame with PPS/SPS, need to set "forceFrame = 3", it is in dynamic base structure.

    Better you move to latest HEVC Encoder release, which works with mcsdk_video_2_2_0_42.

    Regards

    Kuladeepak

  • Hi Kuladeepak,
    I have changed forceFrame of dynamic structure in a CFG file of mcsdk_video. The output H.265 still only have one PPS/SPS at the beginning of the file. Is this because the mcsdk-video host side doesn't really set dynamic params into dsp firmware? In a mcsdk-video demo host app, how to set dynamic param in front of each frame compression? I need a way to send dynamic cfg of each frame into DSP side.

    Regards

    Ruisucom

  • Hi Ruisucom,

              In MCSDK v42, application needs to call Control API with XDM_SETPARAMS with dynamicParams->forceFrame set to 3, before calling Codec Process API, each time whenever IDR frame needs to be inserted.

    Below Code snipped shall be used as a reference for the dynamic Forcing frame to IDR:

    File : siuVctEncode_xdm2p0.c

    Function : xdm2p0_vid_enc_process()

    /* Sample Code snippet which ensures IDR Frame inserted for every 30 frames being encoded */

    if(cxt->algOutArgs.frameCount % 30 == 0){

         dynamicParams->forceFrame = 3; // IVIDEO_IDR_FRAME

          if ( cxt->algHandle->fxns->algActivate )
               cxt->algHandle->fxns->algActivate((IALG_Handle)cxt->algHandle);

          retVal = ividEncfxns->control((IVIDENC2_Handle)cxt->algHandle, XDM_SETPARAMS, dynamicParams, status);

          if ( cxt->algHandle->fxns->algDeactivate )
             cxt->algHandle->fxns->algDeactivate((IALG_Handle)cxt->algHandle);


          if(retVal == XDM_EFAIL)
          {
              printf("\n Control function returned an Error @ core %d... ", CORE_TEAM_MAPPING[cxt->coreId]);
              return (SIU_CODEC_CREATE_ERR_SETPARAMS_FAILED); /* Error Condition: Application may want to break off */
          }

    }

    TSC_Begin = _itoll(TSCH,TSCL);

    retVal = ividEncfxns->process((IVIDENC2_Handle)cxt->algHandle,
    (IVIDEO2_BufDesc *)&inputBufDesc,
    (XDM2_BufDesc *)&outputBufDesc,
    (IVIDENC2_InArgs *)inArgs,
    (IVIDENC2_OutArgs *)outArgs);


    TSC_End = _itoll(TSCH,TSCL);

    Thanks & Regards,

    Prasanna

  • Hi Guys,

    I‘d like to tell that I have changed dsp code as you said above and the IDR frame generated correctly. Thx
    But I'd like to know how to implement a message between dsp and host, that notice dsp generate a IDR in next compression? It seems mcsdk-video demos don't have this kind dynamic param per frame setting method.

    Thanks and regards,
  • Hi Ruisucom,

    You can use existing mailbox communication between Host <-> DSP to signal DSP for IDR Frame insertion according to your requirement.

    More details can be obtained from :   processors.wiki.ti.com/.../MCSDK_VIDEO_2.1_PCIe_Demo_Development_Guide

    Hope this helps.

    Regards,

    Prasanna

  • Hi Kuladeepak,

    Could you kindly give me some tips about how to integrated latest HEVC encoder into mcsdk_video_2_2_0_42?
    I found that that version demo is using a HEVC encoder which released with demo installer, not released with a separate Codec installer.

    Thanks in advance!

    Ruisucom
  • Hi Ruisucom,

            The required changes are in 3 files after you have installed HEVC encoder Installer.

    a. mcsdk_video_2_2_0_42\dsp\mkrel\setupenvMsys.sh

      - Follow the details configured for MPEG4 Encoder found under "Video Codecs start" section for HEVC Encoder

      - Follow the details configured for VIDEO_MPEG4_DEC_DOS found under "paths for video codecs" section for HEVC Encoder

    b. mcsdk_video_2_2_0_42\dsp\mkrel\c64x\makedefs.mk

       - Update path for HEVC Encoder under 'FXDCINC' 

    c. mcsdk_video_2_2_0_42\dsp\siu\vct\codec\encoder\hevc\vctHevcEncClient.h

      - Modify the hevc interface file path according to its RTSC installed path

    Ex: 

    #include <ti/sdo/codecs/h265venc/ih265enc.h>
    #include <ti/sdo/codecs/h265venc/h265enc_ti.h>

    Regards,

    Prasanna

  • Hi Ruisucom, if you use MCSDK video drop45 you just need to modify setupenvMsys.sh (updating to newer HEVC encoder path), then make clean, make sv04

    software-dl.ti.com/.../index_FDS.html

    High level steps:
    - Install latest HEVC encoder in the same folder location as the previous one (ex <MCSDK_video_path>\username\ti\Codecs
    - Modify setupenvMsys.sh
    #VIDEO_HEVC_ENC_VERSION="C66x_h265venc_01_00_00_44_ELF"
    VIDEO_HEVC_ENC_VERSION="C66x_h265venc_02_00_00_00_ELF"
    - In a command window Go to \dsp\mkrel
    source setupenvMsys.sh
    make sv04

    thank you,
    Paula
  • Hi Paula,

    As you said i am using MCSDK video 2_2_0_45 and 01_00_00_44 h265enc, I also changed HEVC encoder path as you said. However, I encountered a dsp codec create fail. The error message is
    "
    ...
    [946685774.926953800] (DEBUG) DFrameReaderThread() : SchedulerGetFreeNode no free node
    [946685774.926981550] (DEBUG) DFrameReaderThread() : SchedulerGetFreeNode no free node
    [946685774.657544800] (DEBUG) DeviceIORxThread(1) : Getting message from node #8 ...
    [946685775.262490951] (DEBUG) DeviceIORxConfig(1) : Received configuration response from node 8.
    [946685775.262571501] (ERROR) DeviceIORxConfig(1) : DSP codec create on node 8 failed with error code -7!!!!!
    List of error code can be found from iface/media/mediaAppMsg.h
    [946685775.262615901] (DEBUG) DFrameReaderThread() : SchedulerGetFreeNode no free node
    [946685774.657828150] (DEBUG) DeviceIORxThread(0) : Getting message from node #0 ...
    [946685775.262707101] (DEBUG) DeviceIORxConfig(0) : Received configuration response from node 0.
    [946685775.262740151] (ERROR) DeviceIORxConfig(0) : DSP codec create on node 0 failed with error code -7!!!!!
    List of error code can be found from iface/media/mediaAppMsg.h
    [946685775.262850701] (DEBUG) DeviceIORxThread(1) : Getting message from node #9 ...
    [946685775.262924151] (DEBUG) DeviceIORxConfig(1) : Received configuration response from node 9.
    ...
    "

    I guess the 2.0 HEVC encoder need a new config file. Could you send me some cfg file to try?
  • Ruisicom, please see attached configuration files for HEVC GA 2.0. I also attached a required host changed file for encoding 2Kp30 clips (in case you required). 

    4101.Configs.zip

    4064.mcsdk_host_changed_file.zip

    thank you,

    Paula

  • Hi Paula

    Thanks for the CFG files and host side file patch, after update them, the version 2 HEVC encoder is working now. Also I do see some encoding quality improvement after this upgrade.
    Cheers!
    ruisucom