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.

Cann't dynamic change Resolution when Encoder have B frame

Hello, We use DVRRDK 04.00.00.03 for develop. Hardware platform is EVM8168

 

the chains is:    DEI---Encoder

 

When set no B frame encoded,  we can change resolution dynamically.( use System_linkControl(linkId, DEI_LINK_CMD_SET_OUTPUTRESOLUTION, &deiOutRes, sizeof(deiOutRes), TRUE);)

When set B frame encoded, if we change resolution dynamically, we get error log.

 

 [m3video] 320078:!ERROR!:ENCLINK::links_m3video/iva_enc/encLink_h264.c:[470]::INTERNAL ERROR:-1

 [m3video] ALGPROCESS FAILED

  [m3video] Number of Entries in Process List : 1

 [m3video] Extended error for entry 0 : 0x400

 [m3video] encode, invalid FrameType: -1, fillLength: 0, freenum: 1

 [m3video] 320079:WARN

 [m3video] ENCLINK:ERROR in Enclink_h264EncodeFrameBatch.Status[-1] for IVAHD_0  

[m3video] 320079:WARN  

[m3video] ENC : IVAHDID : 0 ENCLINK:ERROR in EncLink_SubmitBatch.Status[-1]

  • RDK 4.0 does not support B-frame encoding. Support will be available only in the next RDK release

  • Hi, Badri

    Is it means DVRRDK 4.0 only support changing resolution dynamically when there is no B-frame encoding ?

     

    What is the fastest time we can get to the next release?

  • It means you cannot enable B-frame encoding in DVR RDK 4.0 because it is not supported. The next RDK release will be available mid Aug 2013.

  • Hi, Badri

    However, we can find it shows "Support B frame encoding" in H264_Encoder_HDVICP2_DataSheet.pdf.

    we use DVRRDK 4.00.00.03,  encode version is REL.500.V.H264AVC.E.IVAHD.02.00.04.01.

  • Enabling B-frame encode requires changes in encLink to manage reference buffer which are not present in DVR RDK 4.0. So even though the codec supports B-frame encoding this feature cannot be enabled because the encLink does not support it.encLink is enhanced to support B-frame encoding only in the next DVR RDK release.

  • Hi, Badri

    Actually, we have changed encLink codec, and can support B-frame encoding correct.

    But we cann't change resolution dynammically when there is B-frame encoding.

  • Pls attach patch having diff of changes done to enable B-frame encode support in dvr_rdk so that changes can be reviewed.you should disable processN APIs when using B-frame encode and you should free buffers based on encoder populated outputID and also do encoder channel flush before reseting/deleting the encoder. We want to check if these and other changes have been done.

  • diff -Nar src_bios6/links_m3video/iva_enc/encLink_common.c /opt/src_bios6/links_m3video/iva_enc/encLink_common.c
    857a858,866
    >     
    >     //add by bigg, 2013.5.24
    > 
    >     pChAlgDynPrm->targetFrameRate   = pChDynPrm->inputFrameRate;
    >     pChAlgDynPrm->refFrameRate      = pChDynPrm->inputFrameRate;        
    >         
    >     //add by bigg, 2013.5.24, end
    >     
    >        	 	        	    
    1586a1618,1622
    > 
    > 		      //add by bigg, 2013.5.29
    > 		      pOutBuf->seqId = pInFrameInfo->seqId;    
    > 		      //add by bigg, 2013.5.29, end  
    >     
    1687c1741,1745
    < 
    ---
    >     
    >     //add by bigg, 2013.5.30
    >     UInt32 outBufs = 0;
    >     //add by bigg, 2013.5.30, end
    >     
    1697c1755,1762
    <            (outBitBufList.numBufs < (VIDBITSTREAM_MAX_BITSTREAM_BUFS - 1)))
    ---
    >            //modify by bigg, 2013.5.30
    >            //original
    >            /*(outBitBufList.numBufs < (VIDBITSTREAM_MAX_BITSTREAM_BUFS - 1))*/
    >            
    >            //now
    >            (outBufs < (VIDBITSTREAM_MAX_BITSTREAM_BUFS - 1))
    >            //modify by bigg, 2013.5.30, end
    >            )
    1735,1737c1800,1818
    <         outBitBufList.bufs[outBitBufList.numBufs] = pReqObj->OutBuf;
    <         outBitBufList.numBufs++;
    < 
    ---
    >         //modify by bigg, 2013.5.30
    >         //original
    >         //outBitBufList.bufs[outBitBufList.numBufs] = pReqObj->OutBuf;
    >         //outBitBufList.numBufs++;
    >         
    >         //now
    >         if(pReqObj->OutBuf->fillLength == 0)
    >         {
    >             status = Utils_bitbufPutEmptyBuf(&pObj->outObj.bufOutQue, pReqObj->OutBuf);
    >             UTILS_assert(status == FVID2_SOK);        	
    >         }
    >         else
    >         {
    > 		    outBitBufList.bufs[outBufs] = pReqObj->OutBuf;
    > 		    outBufs++;        	
    >         }
    >         //modify by bigg, 2013.5.30, end
    >         
    >         
    1750a1832,1836
    >     //add by bigg, 2013.5.30
    >     outBitBufList.numBufs = outBufs;
    >     //add by bigg, 2013.5.30, end
    >     
    > 
    2445c2531
    <         if (pChObj->switchCodec.algCreatePrm.fieldPicEncode)
    ---
    >         if (pChObj->switchCodec.algCreatePrm.fieldPicEncode)
    2452c2538
    <         }
    ---
    >         }
    2646c2732
    <         #ifdef SYSTEM_VERBOSE_PRINTS
    ---
    >         //#ifdef SYSTEM_VERBOSE_PRINTS
    2651c2737
    <         #endif
    ---
    >         //#endif
    2669c2755,2765
    <     pChObj->frameStatus.inCnt += pChObj->inputFrameRate;
    ---
    >     //modify by bigg, 2013.5.29
    >     
    >     //original
    >     //pChObj->frameStatus.inCnt += pChObj->inputFrameRate;
    >     
    >     //now
    >     pChObj->frameStatus.inCnt += (pChObj->inputFrameRate/1000);
    >     
    >     //modify by bigg, 2013.5.29, end
    >     
    >         
    diff -Nar src_bios6/links_m3video/iva_enc/encLink_h264.c /opt/src_bios6/links_m3video/iva_enc/encLink_h264.c
    527a543,595
    > 
    >         //add by bigg, 2013.5.30
    >         
    >         
    >         if(outArgs->videnc2OutArgs.encodedFrameType == IVIDEO_B_FRAME)
    >         {
    >         	pReqObj->OutBuf->isBFrame = 1;
    >         }
    >         else
    >         {
    >         	pReqObj->OutBuf->isBFrame = 0;
    >         }
    >         
    >         {
    >             int  j = 0;
    >             
    >             pReqObj->InFrameList.numFrames = 0;
    >             
    >             while(outArgs->videnc2OutArgs.freeBufID[j] != 0)
    >             {
    >             	pReqObj->InFrameList.frames[pReqObj->InFrameList.numFrames] = 
    >             	          (FVID2_Frame *)outArgs->videnc2OutArgs.freeBufID[j]; 
    >             	pReqObj->InFrameList.numFrames += 1;
    >             	j++;
    >             }
    >         }
    >         //add by bigg, 2013.5.30, end
    649a718
    > 
    

    Hi, Badri, attached our patch. 

  • Hi, Badri

     

    You have mentioned "you should disable processN APIs when using B-frame encode ", is it mean this codec

        if (handle != NULL)    {    

         error =  handle->fxns->processMulti(&processList);  

      }

    which is at Enclink_h264EncodeFrameBatch APIs  in encLink_h264.c

    now errors printf from here when we change resolution dynamically.

     

     

     

  • No that is not the correct change to disable processMulti.Undo the change you did and modify

    /dvr_rdk/mcfw/interfaces/link_api/system_debug.h

    Enable define

    #define SYSTEM_DEBUG_DISABLE_PROCESS_MULTI 

    After this rebuild dvr_rdk and use the newly built firmware.

  • Hi,

    I dont see the changes to set parameters enabling b frame in h.264 encode. Does your encoded output has b frames at all?

    As Badri mentioned, enclink requires more changes not invoke processMulti() for B frame mode. I am attaching a patch which has all changes to enable B Frame which can be applied on 4.0.3 release.

    B frame if enabled should be done for all h.264 encode channels - this is a limitation.

    This patch includes migration to latest h.264 encoder (which is not mandatory for b frame support) - so remove the relevant changes from Rules.make, enclink_h264.c which would create compilation issues.

    http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/717/1882.enc_5F00_link_5F00_b_5F00_frame.patch

  • Hi, Sivagamy

    Thanks for your reply.

    I only patched enclink last time. We have set the  interFrameInterval in dvr_rdk code.

        encPrm.chCreateParams[i].defaultDynamicParams.interFrameInterval = bFrameInterval;// 1: no B frame.

    From encoded output, we can get b frames, and the stream can play well through player.

     

    We will use patch you privided for test.

  • Hi, Sivagamy

    Based your patch, we change encoder link's codec when encoder changing resolution if interFrameInterval is not set 1,

     drop all frames in encoder.

     

     Now we Can dynamiclly change resolution when encoder have B frames. 3Q~