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.

HEVC codec GOP param question

hello 

I use the HEVC codec to encode, but I am confused about param setting for GOP.

gopCntrlParamsPreset  = 0 ,  it's successful to get the handle by H265VENC_create() function

gopCntrlParamsPreset = 1, it's user defined,   I tried many params, however H265VENC_create always return NULL.

I only need  frame I and P,  no B frame,    how can I set the params, and GOP size .

thank you very much~

here are the gop params:

gopCntrlParamsPreset = 0

GOPPOCNo = {1 0 0} # POC No of each picture

GOPFrameType = {I P P } # Picture Type in encoding order of each picture
GOPQPOffset = {0 0 0 } # QP offset of each picture
GOPRefFramesActive = {1 1 1} # Num of active reference frames used in estimation
GOPNumRefFrames = {1 1 1} # Num of reference frame used to encode
GOPRefIdx = {-1 -1 -1} # Ref pic list of each picture
IsReference = {1 1 1 } # 0 = Not a reference frame ,1 = Reference frame
TemporalId = {0 0 0 } # TemporalId of each picture

  • Welcome to the TI E2E forum. I hope you will find many good answers here and in the TI.com documents and in the TI Wiki Pages (for processor issues). Be sure to search those for helpful information and to browse for the questions others may have asked on similar topics (e2e.ti.com). Please read all the links below my signature.

    Please provide the DSP and software package used.

    We will get back to you on the above query shortly. Thank you for your patience.

  • Hi,

    Can you please send the config file you are using to encode the stream.

    Thanks and Regards,
    Palachandra M V

  • thank you~~

    here is my config file, mosts of params are default in codec project.

    In GOP realated INFO,  if gopCntrlParamPreset is 0, I can run the project, and the handle returned by H265VENC_create function is OK;

    if gopCntrlParamPreset is others,  the handle is always NULL and quit.

    I don't know how to use user defined to set GOP,  could you help me please.

    thank you ~~

    ##########################################################################################
    # Encoder Control
    ##########################################################################################
    EncodingPreset = 3 # 0 => XDM_Default 3=> User defined (see codec-specific document to understand the encoding behaviour).
    rateControlPreset = 1 # 1 : CBR , 2 : VBR , 4 : NONE , 5 : User defined
    NumFramesToEncode = 300 # input frames to be encoded
    MaxWidth = 1920 # Max Frame width should be multiple of 16
    MaxHeight = 1088 # Max Frame height should be multiple of 16
    ncores = 1
    StartFrameNumber = 0 # Frame Encoding Offset
    Profile = 1 # Encoding profile, 1 : MAIN_PROFILE, 3 : MAIN_STILL_PROFILE
    Level = 31 # Level IDC (e.g. 20 = level 2.0)
    MaxInterFrameInterval = 1 # I to P frame distance. 1 indicates no B frames. Value >1 indicates presence of B frames.
    InputChromaFormat = 1 # 1 => XDM_YUV_420P, Only 1 is supported.
    InputContentType = 0 # Input buffer content type, 0 -> Progressive Type, 1-> Interlaced. Only Progressive is supported
    InputDataMode = 3 # Process entire frame. Only supported value is 3.
    OutputDataMode = 3 # Encode entire frame into a bitstream in single call. Only supported value is 3.
    NumOutputUnits = 1 # Number of units of output-data (ex. 1 Slice/Frame encoded stream).
    inputWidth = 352 # width of image
    inputHeight = 288 # Height of image
    targetFrameRate = 25000 # Target frame rate in fps * 1000, => For 60 fields per second it should be 30000
    targetBitRate = 384000 # Target Bit Rate in Bits per second.
    intraFrameInterval = -1 # Interval between two consecutive intra frames, 0 => Only first frame to be intra coded, 1 => All intra frames, N => One intra frame and N-1 inter frames, where N > 1
    interFrameInterval = 1 # M: Number of (M-1) B frames between two reference frames. 1 indicates no B frame.
    # Above line holds only if gopCntrlParamsPreset is zero
    generateHeader = 0 # Header is not encoded seperately. The entire frame is encoded as an access unit alongwith the headers.
    forceFrame = -1 # Frame type is not forced. It is as per the encoding behaviour.
    sampleAspectRatioHeight = 1 # Aspect Ratio Height
    sampleAspectRatioWidth = 1 # Aspect Ratio Width
    mvAccuracy = 2 # Pixel Accuracy of the motion vector: 0 - Full Pel, 1 - Half Pel, 2 - Quarter Pel
    ##########################################################################################
    # CTU level Control
    ##########################################################################################
    maxCTBSize = 32 # Maximum coding unit size in pixel
    maxCUDepth = 2 # Maximum coding unit depth from LCU level
    ###########################################################################################
    # GOP related info
    ###########################################################################################
    gopCntrlParamsPreset = 0 # 0 : Default layer 1
    # 1 : User defined , below parameters will be used
    # 2 : Deafult layer 2, gop size 2 and IPP sequence
    # 3 : Deafult layer 3, gop size 4 and IPP sequence
    # 4 : Deafult layer 4, gop size 8 and IPP sequence
    # 5 : Deafult layer 2, gop size 2 and IBP sequence
    # 6 : Deafult layer 4, gop size 4 and IBBBP sequence
    # 7 : Deafult layer 4, gop size 8 and IBBBBBBBP sequence
    GOPPOCNo = {1 0 0} # POC No of each picture
    GOPFrameType = {I P P } # Picture Type in encoding order of each picture
    GOPQPOffset = {0 0 0 } # QP offset of each picture
    GOPRefFramesActive = {1 1 1} # Num of active reference frames used in estimation
    GOPNumRefFrames = {1 1 1} # Num of reference frame used to encode
    GOPRefIdx = {-1 -1 -1} # Ref pic list of each picture
    IsReference = {1 1 1 } # 0 = Not a reference frame ,1 = Reference frame
    TemporalId = {0 0 0 } # TemporalId of each picture
    ###########################################################################################
    # Rate Control
    ###########################################################################################
    rateControlParamsPreset = 0 # 0 : Default ,1 : User defined ,2 : existing
    RcAlgo = 1 # Rate control algorithm used, 0: Variable Bitrate, 1 : Constant bitrate (low dealy),
    QpI = 32 # Quantization parameter(0-51) for I-Slices
    QpMinI = 21 # Minimum QP for I frames
    QpMaxI = 51 # Maximum QP for I frames
    QpP = 32 # Quantization parameter(0-51) for P-Slices
    QpMinP = 10 # Minimum QP for P frames
    QpMaxP = 51 # Maximum QP for P frames
    QpOffsetB = 0 # Offset of B frames Quantization Parameter from P frames
    QpMinB = 20 # Minimum QP for B frames
    QpMaxB = 51 # Maximum QP for B frames
    enableFrameSkip = 0 # Enable skip frames while encoding
    enablePartialFrameSkip = 0 # Enable Partial frame skips in encoder
    qualityFactorIP = 0 # Not supported
    cbQPIndexOffset = 0 # QP offset for Cb component
    crQPIndexOffset = 0 # QP offset for Cr component
    initialBufferLevel = 3000000 # Initial buffer level of HRD Buffer
    HRDBufferSize = 3000000 # size of the HRD Buffer in bits
    enableHRDComplianceMode = 0 # Enable HRD buffer compliance mode
    maxFrameSkipCnt = 0 # Not Supported. Limit max number of cosecutive skip frames while encoding
    SubFrameRC = 0 # Not Supported
    maxDeltaQP = 0 # CU-based multi-QP optimization
    enablePRC = 0 # 0 : Disable ,1 : Enable
    enableTransQuantBypass = 0 # flag to bypass transform and quantization
    ############################################################################################
    # Slice Coding
    ############################################################################################
    sliceCodingPreset = 0 # 0 : Default ,1 : User defined ,2 : existing
    sliceCodingMode = 0 # 0 : Disable
    # 1 : each slice consist of sliceCodingArg LCU
    sliceCodingArg = 0 # N : each slice consisit of N LCU in raster scan order ; This will be ignored if enableTiles is 1
    enableTiles = 0 # Enable tile encoding
    numTileColumns = 1 # Total number of tile columns in a frame
    numTileRows = 1 # Total number of tiles in a row
    enableDependentSlice = 0 # Enable dependent slice encoding, not supported
    ###########################################################################################
    # IntraCoding Control
    ###########################################################################################
    intraCodingPreset = 0 # Intra coding mode preset, 0 => deafult values, 1 => user defined
    intraRefreshMethod = 0 # 0: Disable, 1: INTRAREFRESH_CYCLIC_MBS
    intraRefreshRate = 0 # Rate at which intra MB Refresh is done. e.g. 10 indicates every 10th MB will coded as Intra in inter pictures.
    constrainedIntraPredEnable = 0 # Not supported
    enableStrongIntraSmoothing = 0 # Enable smoothing for Intra LCUs
    matchYCbCrIntraMode = 0 # Not supported
    enableLumaIntra4x4Mode = 0 # Not supported
    enableLumaIntra8x8Mode = 0 # Not supported
    enableLumaIntra16x16Mode = 0 # Not supported
    enableLumaIntra32x32Mode = 0 # Not supported
    enableChromaIntra4x4Mode = 0 # Not supported
    enableChromaIntra8x8Mode = 0 # Not supported
    enableChromaIntra16x16Mode = 0 # Not supported
    ###########################################################################################
    # InterCoding Control
    ###########################################################################################
    interCodingPreset = 1 # Inter coding mode preset, 0 => deafult values, 1 => user defined
    enableTmvp = 0 # Not supported
    searchRangeHorP = 144 # Horizontal Search Range for P frames in integer pixels, e.g. 144 -> this will make search range from (-144 to +144) offseted by GMV.x
    searchRangeVerP = 128 # Vertical Search Range for P frames in integer pixels
    searchRangeHorB = 144 # Horizontal Search Range for B frames in integer pixels
    searchRangeVerB = 128 # Vertical Search Range for B frames in integer pixels
    interCodingBias = 0 # Not supported
    skipMVCodingBias = 0 # Not supported
    numMergeCandidates = 3 # Total number of merge candidates to be used
    enableBiPredMode = 0 # Enable Bi Prediction in B frames
    enableFastIntraAlgo = 1 # Enble fast intra prediction algorithms to improve performance
    ############################################################################################
    # Loop Filter Control
    ############################################################################################
    loopFilterParamsPreset = 1 # Preset value for loop filter operation parameters, 0 => deafult values, 1 => user defined
    enableDeblockFilter = 1 # Enable Dblock filter
    enableSaoFilter = 1 # Enable SAO filter
    enableLoopFilterSliceBoundary = 0 # Enable Loop filter at Slice Boundary
    enableLoopFilterTileBoundary = 0 # Enable Loop filter at tile boundary
    offsetLoopFilterInPPSFlag = 0 # Parameter controls the presence of TC and Beta offset. at PPS level
    offsetDeblockBetaDiv2 = 0 # alpha offset for loop filter [-6, 6] even number
    offsetDeblockTcDiv2 = 0 # beta offset for loop filter [-6, 6] even number
    ################################################################################
    # VUI Control Params
    ################################################################################
    vuiCodingPreset = 0 # Preset value for VUI Control Params, 0 => deafult values, 1 => user defined
    enableVui = 0 # Flag to enable the VUI params encoding
    aspectRatioInfoPresentFlag = 0 # Controls the insertion of aspect ratio information in VUI part of bit-stream
    aspectRatioIdc = 0 # Aspect ratio ID
    videoSignalTypePresentFlag = 0 # controls the insertion of video signal type in VUI part of bit-stream
    videoFormat = 0 # Video signal type
    videoFullRangeFlag = 0 # Flag to specigy Range of the pixels
    colourDescriptionPresentFlag = 0
    colourPrimaries = 0
    transferCharacteristics = 0
    matrixCoefficients = 0
    timingInfoPresentFlag = 0
    ################################################################################
    # Miss Params
    ################################################################################
    scalingMatrixPreset = 0 # flag to enable scaling list
    # 0 : Disabled
    # 1 : Default scaling list as defined by standard
    # 2 : User defined scaling list sent in SPS
    # 3 : User defined scaling list sent in PPS
    decRefreshType = 0
    decRefreshInterval = 0 # IDR frame Interval
    enableTransQuantBypass = 0 # flag to bypass transform and quantization
    maxPoc = 32
    enableTransformSkip = 0
    maxIntraFrameInterval = -1
    enableWPP = 0 # Flag to enable WPP Coding
    enableSEI = 0
    maxNumRefFrames = 1
    enableVirtualTile = 0 # LS Digit Indicates (Enable (1)/ Disable (0))Virtual Tile MS Digit indicates Number of Chips (1-8)
    disableVirtualTileDependency = 1
    debugTraceLevel = 0
    lastNFramesToLog = 0
    enableROI = 0 #0 : ROI disable , 1: ROI Enable
    writeSpsPpsHdr = 0
    enableIntraRDO = 1
    enableScaleDeadZone = 1
    enableSAONonReference = 1
    roiDataFile = "..\..\..\Test\TestVecs\Config\roi_offset.txt" # ROI filename

  • Hi,

    I have attached the config to run IPP config, if you need to insert Intra frame, please change the intraFrameInterval accordingly. Please see the user guide for more information regarding config parameters. Let me know if you need any more information.

    Thanks and Regards,
    Palachandra M V
    www.pathpartnertech.comencoder.cfg

  • THANK YOU VERY MUCH!

    It works while I use your cfg file.   the handle is returned by H265create function successfully.

    and the Frame encoding  are IPPPPPPPP...

    if I want to set GOP size is 5, frame type like : I P P P P I P P P P I P P P P I P......

    I use this way to do it : 

    if I want a I Frame :

    1, set next frame type param to be IDR_FRAME:

         lDynamicParams.videnc2DynamicParams.forceFrame = IVIDEO_IDR_FRAME;

    2, call control function

    H265VENC_control(handle,
    XDM_SETPARAMS,
    (H265VENC_DynamicParams *)&lDynamicParams,
    (H265VENC_Status *)&lstatus);

    3, set the param back

    lDynamicParams.videnc2DynamicParams.forceFrame = IVIDEO_NA_FRAME

    and this way works correctly~  I got frame like I P P P P I P P P P ...

    SO,  could you tell me ,  is the way right?  or another way to do it ?

    and  thank you very much again~~

  • Hi,

    Insertion of IDR frame can be done as above, even this can be configured through config params.(intraFrameInterval and decRefreshInterval).
    For the above use case this can be achieved by assigning
    - intraFrameInterval = 5
    - decRefreshInterval = 1

    Thanks and Regards,
    Palachandra M V
    www.pathpartnertech.com

  • ! you are the greatest~~~ thank you !
    it works , intraFrameInterval param can control the number of P frame.
    And ... decRefreshInterval is 0, it's still work~~


    thank you very much!! And ... can I ask more question here...

    the demo of H265encoder, test app, download from software-dl.ti.com/.../index.html

    (in C6678, using core 0)
    And When I use JTAG to load the .out file built by this testapp project , the core is running at once... I pause it , it stops in address 0x00000000...
    then I reset dsp using CCS debug [cpu reset] button, and reload .out file ,  
    it becomes narmal, it stops in main function. and I can run it normally...

    however, it's Just encoder's problem. out file of Decoder testapp is always ok..

    thank you very much~~

  • Hi,

    - Config param decRefreshInterval is enabled only if you need an IDR.
    - Regarding loading of encoder .out, can you please try by restarting CCS.

    Thanks and Regards,
    Palachandra M V
    www.pathpartnertech.com
  • thanks~

    I have tried to restart CCS, but the .out file of encoder still doesn't work at first time  .  

    I need reset DSP ,then reload out file and it works.   Decoder'out file is always OK.

     IF I use pcie-load way to load .out file from host to DSP,  maybe it's ok?

    --------------------------------------------------------------------------------------------------

    ---------------------------------------------------------------------------------------------------

    Forgive me I have another question that I met yesterday...

    HERE IS:

    I wanna use PCIE interrupt in my sys/bios project. 

    so I use the example to initalize the PCIE interrupt something.

    the example is from   "mcsdk_2_01_02_06\tools\boot_loader\examples\pcie\pcieboot_interrupt\src"

    I use the code from main function.

    the code is:

    DEVICE_REG32_W(PCIE_LEGACY_A_IRQ_STATUS, 0x1);

    /************************************************
    *************** INTC Configuration *************
    ************************************************/
    write_uart("Debug: GEM-INTC Configuration...\n\r");

    /* INTC module initialization */
    intcContext.eventhandlerRecord = EventHandler;
    intcContext.numEvtEntries = 10;
    if (CSL_intcInit(&intcContext) != CSL_SOK)
    {
    write_uart("Error: GEM-INTC initialization failed n\r");
    return;
    }

    /* Enable NMIs */
    if (CSL_intcGlobalNmiEnable() != CSL_SOK)
    {
    write_uart("Error: GEM-INTC global NMI enable failed n\r");
    return;
    }

    /* Enable global interrupts */
    if (CSL_intcGlobalEnable(&state) != CSL_SOK)
    {
    write_uart("Error: GEM-INTC global enable failed \n\r");
    return;
    }

    /* Open the INTC Module for Vector ID: 4 and Event ID: 63 (C6678) 59 (C6670)
    * Refer to the interrupt architecture and mapping document for the Event ID (INTC0_OUT3)*/
    vectId = CSL_INTC_VECTID_4;
    hTest = CSL_intcOpen (&intcObj, INTC0_OUT3, &vectId , NULL);
    if (hTest == NULL)
    {
    write_uart("Error: GEM-INTC Open failed\n\r");
    return;
    }

    /* Register an call-back handler which is invoked when the event occurs. */
    EventRecord.handler = &test_isr_handler;
    EventRecord.arg = 0;
    if (CSL_intcPlugEventHandler(hTest,&EventRecord) != CSL_SOK)
    {
    write_uart("Error: GEM-INTC Plug event handler failed\n\r");
    return;
    }

    /* Enabling the events. */
    if (CSL_intcHwControl(hTest,CSL_INTC_CMD_EVTENABLE, NULL) != CSL_SOK)
    {
    write_uart("Error: GEM-INTC CSL_INTC_CMD_EVTENABLE command failed\n\r");
    return;
    }

    write_uart("Debug: GEM-INTC Configuration Completed \n\r");

    /**************************************************
    ************* CPINTC-0 Configuration *************
    **************************************************/

    write_uart("Debug: CPINTC-0 Configuration...\n\r");

    /* Open the handle to the CPINT Instance */
    hnd = CSL_CPINTC_open(0);
    if (hnd == 0)
    {
    write_uart("Error: Unable to open CPINTC-0\n\r");
    return;
    }

    /* Disable all host interrupts. */
    CSL_CPINTC_disableAllHostInterrupt(hnd);

    /* Configure no nesting support in the CPINTC Module. */
    CSL_CPINTC_setNestingMode (hnd, CPINTC_NO_NESTING);

    /* We now map System Interrupt 0 - 3 to channel 3 */
    CSL_CPINTC_mapSystemIntrToChannel (hnd, PCIEXpress_Legacy_INTA, 3);

    /* We now enable system interrupt 0 - 3 */
    CSL_CPINTC_enableSysInterrupt (hnd, PCIEXpress_Legacy_INTA);

    /* We enable host interrupts. */
    CSL_CPINTC_enableHostInterrupt (hnd, 3);

    /* Enable all host interrupts also. */
    CSL_CPINTC_enableAllHostInterrupt(hnd);

    =======================================================

    AND It works, I can use PCIE interrupt sended or recieved with Host.

    HOWEVER, the IPC  is always pended in somewhere, like IPC_attach or any ipc function.

    I guess that the PCIE interrupt resource allocted by CSL libaray and the IPC resource allocted by sys/bios.

    are there a conflict between pcie and ipc Interrupt resource?

    could you help me  or point the way out for me please?

    THANK YOU ...  

    T.T    <- cring for this problem

  •  Ha~

    I have solved this problem~~

    If I want to get the PCIE interrupt, I can use two ways:

    1、use CSL_xxx API on the non-sys/bios project;

    2、use Hwi and CpIntc Module on the sys/bios project。

    I try to describe this theory, sorry if I describe less accurately ...

    these two ways are both config the input and output of CIC and INTC.

    in sys/bios, CpIntc module configs the CIC, and Hwi configs INTC.

    the input of CIC is the system interrupt, here is PCIE_interrupt with No. 50 which can be found in c6678 date sheet.

    and the output of CIC is the host interrupt, which also have its own No. and point to the input No.of INTC.

    the input of INTC is the event  No.   which is related to the output of CIC.

    and the output of INTC is the interrupt vector Id, which is [4..15],  we can use one of them and associated a callback function.

    so, if there is a pcie interrupt(50) comes now:

    1、the input of CIC is 50;

    2、the output of CIC should be some number, which is shown in c6678 date sheet,  Here I use No. 3.

    3、and I get the input No. of INTC ,because we can calculate by the output of CIC, the formula is also found in c6678 data sheet,   here is 63.

    4、now I choose the output of INTC is vector_ID_4, and associated a callback function "myhandleFun"

    so ,if the pcie interrupt comes ,  I can get it in the callback function "myhandleFun".