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.

DM365 H264 Platinum Codec ROI Enabling

Hi,

i enabeled ROI feature by setting

Dynamic Params-> enableROI = 1;

input Arguments for ROI parameters before the VIDENC_process() call.

       inArgs.roiPrm.numROI = 5
  
       inArgs.roiParameters.listROI[0].topLeft.x = 80;
       inArgs.roiParameters.listROI[0].topLeft.y = 128;
       inArgs.roiParameters.listROI[0].bottomRight.x = 96;
       inArgs.roiParameters.listROI[0].bottomRight.y = 160;
       inArgs.roiParameters.roiPriority[0] = ALG_VID_ENC_ROI_PRIORITY_HIGH;
       inArgs.roiParameters.roiType[0] = ALG_VID_ENC_ROI_TYPE_FOREGROUND;

       inArgs.roiParameters.listROI[1].topLeft.x = 256;
       inArgs.roiParameters.listROI[1].topLeft.y = 128;
       inArgs.roiParameters.listROI[1].bottomRight.x = 272;
       inArgs.roiParameters.listROI[1].bottomRight.y = 160;
       inArgs.roiParameters.roiPriority[1] = ALG_VID_ENC_ROI_PRIORITY_HIGH;
       inArgs.roiParameters.roiType[1] = ALG_VID_ENC_ROI_TYPE_FACE;

       inArgs.roiParameters.listROI[2].topLeft.x = 0;
       inArgs.roiParameters.listROI[2].topLeft.y = 0;
       inArgs.roiParameters.listROI[2].bottomRight.x = 64;
       inArgs.roiParameters.listROI[2].bottomRight.y = 64;
       inArgs.roiParameters.roiPriority[2] = ALG_VID_ENC_ROI_PRIORITY_HIGH;
       inArgs.roiParameters.roiType[2] = ALG_VID_ENC_ROI_TYPE_FACE;

       inArgs.roiParameters.listROI[3].topLeft.x = 300;
       inArgs.roiParameters.listROI[3].topLeft.y = 250;
       inArgs.roiParameters.listROI[3].bottomRight.x =352;
       inArgs.roiParameters.listROI[3].bottomRight.y = 288;
       inArgs.roiParameters.roiPriority[3] = ALG_VID_ENC_ROI_PRIORITY_HIGH;
       inArgs.roiParameters.roiType[3] = ALG_VID_ENC_ROI_TYPE_FACE;

       inArgs.roiParameters.listROI[4].topLeft.x = 32;
       inArgs.roiParameters.listROI[4].topLeft.y = 240;
       inArgs.roiParameters.listROI[4].bottomRight.x = 64;
       inArgs.roiParameters.listROI[4].bottomRight.y = 256;
       inArgs.roiParameters.roiPriority[4] = ALG_VID_ENC_ROI_PRIORITY_LOW;
       inArgs.roiParameters.roiType[4] = ALG_VID_ENC_ROI_TYPE_PRIVACYMASK;

but in the live video i am not finding any ROI areas ? where i went wrong. does it require any other setting ?

  • Hi,

    can anyone from TI will assist me for this ROI enabling.

    as i have mentioned up how i did and what i did for ROI but i am not getting any ROI area in my live video.

    what should i do to get the ROI's specified to the codec input.

    i am using H264 version 2.0 on DM365 based camera.

  • Hi Sujit,

    sujit mahapatro said:
    in the live video i am not finding any ROI areas ? where i went wrong. does it require any other setting ?

    What do you mean by not finding ROI areas on live video? Do you expect the rectangles on the video? If you compare it against IPNC Ref Design, there we generate ROI based on face detection, draw that rectangle and then pass it to codecs.

    Regards,

    anshuman

    PS: Please mark this post as verified, if you think it has answered your question. Thanks.

     

  • Hi Sujit,

    Your ROI setting looks fine and that is all you need to do to enable ROI.

    One thing you should note is, ROI gets automatically disabled when you use Fixed QP encoding.

    1. Can you confirm on the type of RC being used?

    2. Can you share an encoded stream with encoder settings, so that we can analyze at our end?

    3. Which encoder version is being used (found in release notes)?

    Rgds, mahant

     

  • Anshuman,

    if we don't draw rectangle, also fine.

    my point was how do i know after i enabeled ROI, what is happening in the specified ROI area ?

    what encoder is doing by taking the ROI cordinates as input.

    as per my simple understanding ROI specified areas will be encoded by allocationg higher no of bits and different qvalues will be assigned to ROI's and NonROI's

    so that as a user  point of view, one can visualize the ROI areas  based upon the encoded quality of ROI and NON ROI's in a every frame.

     

  • Hi Mahant,

    RC we use both CBR and VBR, but FIXED QP is not used.

    we use Platinum codec H264v2.0.

    mahant as Anshuman said we can draw rectangle like in IPNC and see but my point was with out rectangle also

    how an user can come to know what is happening after enabling ROI, by viewing the video.

  • Hi Sujit,

    Even if  you draw rectangles it gets mapped to ROI input arguments. So directly setting the ROI input arguments should be fine.

    By viewing the video one can confirm the enabling of ROI by,

    1. Looking at the QP values in the ROI regions and non-ROI regions.

    2. ROI regions usually takes lesser QP than non-ROI region (depends on encoder settings like bitRate, max/min QP, number of ROIs, ROI priority etc).

    Rgds, mahant

  • Hi Sujit,

    As Mahant mentioned, you can look at the stream and see that the Qp value of the ROI should be lower than Qp of the non-ROI region. You would have to use stream analyzer tools to check that. Now, there are some basic things that we need to keep in mind.

    1. The bit rate set should be low enough to make sure that ROI regions get significantly different number of bits as compared to non-ROI region. For example, for a D1 you can try 512Kbps or even lower to see better ROI encoding results.

    If you face problem, you can share the stream with us and we can confirm if ROI is working as expected or not.

    Regards,

    Anshuman

    PS: Please mark this post as verified, if you think it has answered your question. Thanks.

  • Hi Anshuman and Mahant,

    can you suggest what analyser tool to be used to find out the QP value ?

    we don't have any tool. if some tool available for down load please let me know.

    also as a user point of view user will always to to view the difference while viewing.

    so if we can not get a visible difference between the ROI and NONROI area then its difficult .

    i found the following in

    SPRAB83.pdf.

    " ROI can be of any type as mentioned in ROI_type. If the ROI is detected as FACE_OBJECT, then a guard band is added around it. For all other ROI types, no guard band is added "

    what is this GUARD BAND ?

    my point is to from a user point how some one will come to know the diff between the two ROI and NON ROI areas.

    even though we will find out by some analyser, user will always look in direct viewing prospective in the web viewer.

     

  • Hi Sujit,

    Elecard should be fine enough for this.

    If the ROI type is FACE_OBJECT, GUARD BAND is added around the ROI region. It means that the ROI region is further extended than the user provided inputs. This is done to include the entire face in the ROI region.

    We are taking the approach of using the analyzer only to confirm that ROI has been triggered correctly at your end. Going further we can tune the encoder settings so as to perceptually differentiate between ROI and non-ROI regions and also observe overall quality improvements in streams with ROI enabled and ROI disabled with all the otherr settings remaining same.

    Rgds, mahant

     

     

     

  • Hi Mahant,

    what best parameters can give a differentiate image for visualization.

    can you pease suggest the seeting to save my time in experimenting different encoder settings.

    i have attached on recorded video stream for your analysis.

    Can we sepicifically set QP value for ROI and NON-ROI region, or encoder only contols it between the MAX and MIN value provided while creating the encoder.

     

  • Hi Sujit,

    You cannot set QP values for ROI and non-ROI regions. Encoder by itself sets these values accordingly.

    But before moving forward, with the stream you have shared I don't see ROI getting enabled.  Can you check on following things,

    1. To start with use only one bigger ROI.

    2. Set priority of ROI to max positive value.

    3. Allow full swing for QP (Max 45 and min 5 ).

    4. Use relative lower bitRate (~256 Kbps).

    5. Check ROI related parameters before process call (numROI, enableROI flag and co-ordinates).

    Are you enabling ROI from first frame or in between (useful for analyzing the stream)?

    Rgds, mahant

  • Mahant, following are my paramers.

    pDynParams->intraFrameQP = 26; //getInitialQP(); // min 0 ~ max 51
     pDynParams->interPFrameQP = 26; //getInitialQP(); // min 0 ~ max 51
     pDynParams->initQ = 26; //getInitialQP(); // min 0 ~ max 51
     pDynParams->rcQMax = 45; //44; //getMaxQP();//51; // min 0 ~ max 51
     pDynParams->rcQMin = 5; //; //getMinQP();//0 ; // min 0 ~ max 51
        pDynParams->rcQMaxI = 36; //getMinQPI();
        pDynParams->rcQMinI = 1; //getMinQPI();
        pDynParams->rcAlgo = 1;

    pDynParams->maxDelay = 2000;

    pDynParams->enableROI = 1;

     

    m_pInArgs->roiParameters.numOfROI = 1;
      
     m_pInArgs->roiParameters.listROI[0].topLeft.x = 50;
           m_pInArgs->roiParameters.listROI[0].topLeft.y = 50;
           m_pInArgs->roiParameters.listROI[0].bottomRight.x = 560;
           m_pInArgs->roiParameters.listROI[0].bottomRight.y = 242;
           m_pInArgs->roiParameters.roiPriority[0] = 3;
           m_pInArgs->roiParameters.roiType[0] = FACE_OBJECT;
     

    VIDENC1_process(m_pHandle, &inBufDesc, &outBufDesc,(VIDENC1_InArgs *) m_pInArgs, m_pOutArgs);  
     

    for the time being ROI is enabeled from the begining, and i have attached the recorded stream for the above setting.

    Resolution used is : 640x480, bit rate 512 Kbps

  • Hi Sujit,

    Encoder setting looks fine but still ROI is not getting triggered.

    Two thinks that I can think of is,

    1. What is the encQuality value being used? Can you try with encQuality = 0?

    2. What is the exact encoder version being used (can be found in release notes under docs folder, build ID??)?

    Rgds, mahant

     

  • Hi Mahant,

    in current setting i am using encquality as 2 .

    (pParams->videncParams).encodingPreset        = XDM_HIGH_SPEED;    

       pParams->transform8x8FlagIntraFrame  = 1; //(getCodecProfile() == H264_PROFILE_IDC_HIGH)? 1 : 0 ; /* For Baseline,Main Profile: 1 */
        pParams->transform8x8FlagInterFrame  = 1; //(getCodecProfile() == H264_PROFILE_IDC_HIGH)? 1 : 0 ; /* For Baseline,Main Profile: 1 */
        pParams->seqScalingFlag              = 1; //(getCodecProfile() == H264_PROFILE_IDC_HIGH)? 1 : 0 ; /* For Baseline,Main Profile: 1 */
        pParams->encQuality                  = 2; //0; /* 0: ver 1.1 2:Platinum Mode */
        pParams->enableVUIparams             = 1; //0; 
      

        pParams->disableHDVICPeveryFrame     = 0;
        pParams->enableARM926Tcm             = 1;
        pParams->enableDDRbuff               = 1;


    #ifndef SMART_CODEC
        pParams->sliceMode                   = 0;
    #else
        pParams->sliceMode                   = 3;

    #endif

     

    and encoder version is 02.00.00.09 ( Platinum Codec).

    is it related to some hardware version also ? as some where i found for FD the DM365 hardware is "TMS320DM365ZCEF ".

    so is for ROI also same hardware to be used or no issues with which DM365 version we are using.

    i am attaching the video stream with the same settings and only change as suggested by you i am making is

    pParams->encQuality                  = 0 ; //0;

     

  • Mohant,

    am attaching one more recored stream.

    here i have made roitype FOREGROUND_OBJECT from FACE_OBJECT. other parameters same with the previous post.

    m_pInArgs->roiParameters.roiType[0] = FOREGROUND_OBJECT; //FACE_OBJECT

    still the same thing. bout not sure about ROI triggered or not.

    One more thing our DM365 HW version is "TMS320DM365ZCE30   YFB-9BAC0PW"

  • Hi Sujit,

    I don't see ROI getting triggered in both test3 and test4.

    If you are manually setting ROI co-ordinates then normal DM365 board should suffice.

    Rgds, mahant

     

  • Hi Anshuman,

    attached the video stream with the following parameter setting.

     

       /*Encoder Static Params*/
    IVIDENC1 Params: size                      =132
    IVIDENC1 Params:encodingPreset             =2
    IVIDENC1 Params:rateControlPreset          = 1
    IVIDENC1 Params:maxHeight                  =480
    IVIDENC1 Params:maxWidth                   =640
    IVIDENC1 Params:maxFramerate               =20000
    IVIDENC1 Params:maxBitRate                 =524288
    IVIDENC1 Params:inputChromaFormat          =9
    IVIDENC1 Params:reconChromaFormat          =9
    IVIDENC1 Params:dataEndianness             =1
    IVIDENC1 Params:maxInterFrameInterval      =0
    IVIDENC1 Params:inputContentType           =0

    IH264ENC Params:timeScale                  =20000
    IH264ENC Params:numUnitsInTicks            =1000
    IH264ENC Params:aspectRatioX               =1
    IH264ENC Params:aspectRatioY               =1
    IH264ENC Params:pixelRange                 =0
    IH264ENC Params:enableVUIparams            =1
    IH264ENC Params:meAlgo                     =0
    IH264ENC Params:profileIdc                 =100
    IH264ENC Params:levelIdc                   =40
    IH264ENC Params:unrestrictedMV             =1
    IH264ENC Params:entropyMode                =0
    IH264ENC Params:transform8x8FlagIntraFrame =1
    IH264ENC Params:transform8x8FlagInterFrame =1
    IH264ENC Params:seqScalingFlag             =1
    IH264ENC Params:encQuality                 =0
    IH264ENC Params:enableARM926Tcm            =1
    IH264ENC Params:enableDDRbuff              =1
    IH264ENC Params:sliceMode                  =3
    IH264ENC Params:outputDataMode             =1
    IH264ENC Params:sliceFormat                =1

      /* Dynamic Param*/
    Dyn params:inputHeight 480
    Dyn params:inputWidth 640
    Dyn params:targetBitRate 524288
    Dyn params:intraFrameInterval 20
    Dyn params:interFrameInterval 0
    Dyn params:generateHeader 0
    Dyn params:captureWidth 640
    Dyn params:targetFrameRate 20000
    Dyn params:refFrameRate 20000
    Dyn params:forceFrame -1
    Dyn params:mbDataFlag 0
    Dyn params:sliceSize 7
    Dyn params:airRate 0
    Dyn params:rcAlgo 1
    Dyn params:intraFrameQP 26
    Dyn params:interPFrameQP  26
    Dyn params:initQ 26
    Dyn params:rcQMax 45
    Dyn params:rcQMin 5
    Dyn params:rcQMaxI 36
    Dyn params:rcQMinI 1
    Dyn params:mvSADoutFlag 0
    Dyn params:enableROI 1
    Dyn params:metaDataGenerateConsume 0
    Dyn params:maxDelay 2000
    Dyn params:meMultiPart 1
    Dyn params:intraThrQF 5
    Dyn params:perceptualRC 1
    Dyn params:idrFrameInterval 20
    Dyn params:resetHDVICPeveryFrame 1
    Dyn params:enablePicTimSEI 0
    Dyn params:enableBufSEI 0
    [LOG]Profile[0] : [H.264] Encoder init 640x480 20.0 ips
    [LOG]SIMO build_ring:30:13 sec
    [LOG]Add Profile[1] -> to RuntimeID[0], Start Encoder
     m_pHandle=4033320


          /* IVIDEO1_BufDescIn inBufDesc   */


    inBufDesc.frameWidth =640
    inBufDesc.frameHeight =480
    inBufDesc.framePitch =640
    inBufDesc.bufDesc[0].bufSize =307200
     inBufDesc.bufDesc[1].bufSize=153600
     inBufDesc.bufDesc[0].buf=1184096256
     inBufDesc.bufDesc[1].buf =1184403456
     inBufDesc.numBufs =2

         /* XDM_BufDesc   outBufDesc  */


     outBufDesc.numBufs=1
     outBufDesc.bufs=1220623484
     outBufDesc.bufSizes=1220623468


        /*  IN ARGS  */


    (m_pInArgs->videncInArgs).inputID =1
    (m_pInArgs->videncInArgs).topFieldFirstFlag =64
    (m_pInArgs->videncInArgs).size (IH264VENC_InArgs size )=152
    m_pInArgs.timeStamp =0
    m_pInArgs.insertUserData  =0
    m_pInArgs.lengthUserData =0
    m_pInArgs.numOutputDataUnits =0
    m_pInArgs.roiParameters.numOfROI =1
    m_pInArgs.roiParameters.listROI[0].topLeft.x =50
    m_pInArgs.roiParameters.listROI[0].topLeft.y =50
    m_pInArgs->roiParameters.listROI[0].bottomRight.x =560
    m_pInArgs.roiParameters.listROI[0].bottomRight.y =242
    m_pInArgs.roiParameters.roiPriority[0] =3
    m_pInArgs.roiParameters.roiType[0] =2


         /* OUT ARGS  */


    m_pOutArgs->size(IVIDENC1_OutArgs size) =120
     m_pOutArgs->extendedError=0
     m_pOutArgs->bytesGenerated =0
     m_pOutArgs->encodedFrameType =-1
     m_pOutArgs->inputFrameSkip=0
     m_pOutArgs->outputID=1

  • Hi Sujit,

    I see ROI getting triggered in this case(test5).

    Is the change in inArgs size the only change compared to previous runs?

    Rgds, mahant

     

  • Hi Anshuman,

    Attached the log.

  • Hi,

    For the sake of completion of discussion, i am listing the problem with the configuration as discussed in offline discussions:

    (m_pInArgs->videncInArgs).size = sizeof(VIDENC1_InArgs);

    should be modified to

    (m_pInArgs->videncInArgs).size = sizeof(IH264VENC_InArgs);

    Because the process call for the codec was seeing that only base InArgs size is used, it was ignoring the ROI parameters.

    Regards,

    Anshuman

    PS: Please mark this post as verified, if you think it has answered your question. Thanks.

  • Thanks Mahant,

    yes the only change is inArgs .

  • Hi Anshuman and Mahant,

    as we have shifted to platinum codec version 2.10.00.06 i am finding some confusion on ROI .

    the ROI area selected, i am not able observe in the video output stream with the new encoder.

    now again i am doubting wether ROI triggering or not.

    i am attaching 2 recorded video streams in avi format one with 1 ROI area and orher with 2 ROI's.

    can you please conform me , ROI trigeered in the video or not ?

    if yes why i am not able to observe it as like in 2.00.00.09 encoder.

    ROI recorded avi files.rar