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.

Call Back function for NAL Units

Other Parts Discussed in Thread: OMAP3530

Hi

 

I have query regarding the H264 callback function for NAL Units.

As per documents, I have implemented function as below

void H264BP_outputNalUnit(
unsigned int *pNalu,
unsigned int *pPacketSizeInBytes
)
{
}

 

and set the dynamic parameter

ext_dynamicParams.pfNalUnitCallBack = H264BP_outputNalUnit;

But function is not get called. Please can anyone know What I missing? Is there any extra setting required apart from this so that function gets called?

 

Thanks,

Sachin Hambar

  • I think the Call back function to be of the form

    void H264BP_outputNalUnit(
    unsigned char *pNalu,
    unsigned int pPacketSizeInBytes
    )
    {
    }

    Your dynamic parameter setting looks fine. Also CallBack function is invovked only when there are more than one slice in a process call.

    Can you tell me which platform you are trying this?

    Regards,

    Venu

     

  • Hi


    Thanks for immediate reply.

    I am working on OMAP3530 and dvsdk version is dvsdk_3_00_00_21. 
    With following H264 encoder setting, process call never comes back.  If I set dynamicParams.pfNalUnitCallBack to NULL, process comes back and everything goes fine.

            dynamicParams.qpIntra                        = 28;
            dynamicParams.qpInter                        = 28;
            dynamicParams.qpMax                          = 51;
            dynamicParams.qpMin                          = 0;
            dynamicParams.lfDisableIdc                   = 0;
            dynamicParams.quartPelDisable                = 0;
            dynamicParams.airMbPeriod                    = 0;
            dynamicParams.maxMBsPerSlice                 = ((720>>4)*(480>>4));
            dynamicParams.maxBytesPerSlice               = 0x7FFFFFFF;
            dynamicParams.sliceRefreshRowStartNumber     = 0;
            dynamicParams.sliceRefreshRowNumber          = 0;
            dynamicParams.filterOffsetA                  = 0;
            dynamicParams.filterOffsetB                  = 0;
            dynamicParams.log2MaxFNumMinus4              = 0;
            dynamicParams.chromaQPIndexOffset            = 0;
            dynamicParams.constrainedIntraPredEnable     = 0;
            dynamicParams.picOrderCountType              = 2;
            dynamicParams.maxMVperMB                     = 1;
            dynamicParams.intra4x4EnableIdc              = INTRA4x4_IPSLICES;
            dynamicParams.mvDataEnable                   = 0;
            dynamicParams.hierCodingEnable               = 0;
            dynamicParams.streamFormat                   = IH264_NALU_STREAM;
            dynamicParams.intraRefreshMethod             = IH264_INTRAREFRESH_NONE;
            dynamicParams.pfNalUnitCallBack              = H264BP_outputNalUnit;
            dynamicParams.numSliceASO                    = 0;
            for (i=0; i<MAXNUMSLCGPS; i++)
            {
                dynamicParams.asoSliceOrder[i]           = 0;
            }
            dynamicParams.numSliceGroups                 = 0;
            dynamicParams.sliceGroupMapType              = 0;
            dynamicParams.sliceGroupChangeDirectionFlag  = 0;
            dynamicParams.sliceGroupChangeRate           = 0;
            dynamicParams.sliceGroupChangeCycle          = 0;
            for (i=0; i<MAXNUMSLCGPS ; i++)
            {
                dynamicParams.sliceGroupParams[i]        = 0;
            }

    Thanks,
    Sachin Hambar

  • With the setting you provided encoder encodes entire frame as a slice. Can you play around with the following parameters to make encoder generate multiple slices out of a frame?

    1) Give dynamicParams.maxMBsPerSlice                 = 10;

            dynamicParams.maxBytesPerSlice               = 1024;
    2) Also you can play around with dynamicParams.numSliceASO                    = 0;
    Rgds,
    Venu
  • Thanks for the suggestions

    I tried with the parameters you have given.

    With only first suggestion, the function still not get called.

    With your second suggestion,  I am getting configuration error i.e XDM_SETPARAMS gets failed.

    I tried numSliceASO = 2;

    dynamicParams.asoSliceOrder[0]   = 0;

    dynamicParams.asoSliceOrder[0]   = 1;

     

     

  • First try generating multiple slices out of a frame with out CALLBACK initialisation.

    Then with the multiple slice configuration, initialize the CALLBACK function pointer.

     

    One small correction in your settings:

    dynamicParams.asoSliceOrder[0]   = 0;

    dynamicParams.asoSliceOrder[1]   = 1;

  • Has there been any resolution to this thread?

     

    I am also trying to implement the NAL call back, and so far no success.

  • I'm arriving very late to the party for OMAP3530 low level software integration for the H.264 Encoder ...  I have the basic H.264 encoder working but have been stalled trying to get the "callback" function to work for breaking the encoded H.264 output in NAL packet format.  I only see two unresolved threads on this that have been quiet over a year.

    I was surprised to Google the entire planet Earth and not find a single reference to "pfNalUnitCallBack", but it is documented in a PDF file packaged with the codecs:

    H.264 Baseline Profile Encoder on
    OMAP3530
    User’s Guide
    Literature Number: SPRUET9
    July 2009

    in Appendix B.  The Appendix gives conflicting examples on the prototype of the function (the example omits the *pContext argument).

    We would be extremely grateful if anyone at TI (or anywhere else) could shed light on how the callback function is supposed to be configured and work.

    My code works fine with the callback set to NULL.  Below is a debug trace (with all debugging I could turn on which shows a call in VIDENC1_process() and the DSP dying instead of doing the next thing, like CN - NODE ...

    First debug trace is from callback function pfNalUnitCallBack = NULL:

    call VIDENC1_process()... @2,678,765us: [+0 T:0x403c6000] ti.sdo.ce.video1.VIDENC1 - VIDENC1_process> Enter (handle=0x54960, inBufs=0x5263c, outBufs=0x5270c, inArgs=0x52720, outArgs=0x5272c)                                                        
    @2,679,070us: [+4 T:0x403c6000] CV - VISA_getMaxMsgSize(0x54960): returning 0x1000                                                                                                                                                                                                     
    @2,679,222us: [+5 T:0x403c6000] CV - VISA_allocMsg> Allocating message for messageId=0x000288eb                                                                                                                                                                                         
    @2,679,405us: [+0 T:0x403c6000] CV - VISA_call(visa=0x54960, msg=0x413d4880): messageId=0x000288eb, command=0x0                                                                                                                                                                         
    [DSP] @5,049,736tk: [+5 T:0x87f1242c] CN - NODE> 0x87f11e30(h264enc#0) call(algHandle=0x87f11ef8, msg=0x87305880); messageId=0x000288eb                                                                                                                                                 
    [DSP] @5,049,820tk: [+0 T:0x87f1242c] OM - Memory_cacheInv> Enter(addr=0x86350000, sizeInBytes=101376)                                                                                                                                                                                  
    [DSP] @5,049,987tk: [+0 T:0x87f1242c] OM - Memory_cacheInv> return                                                                                                                                                                                                                      
    [DSP] @5,050,020tk: [+0 T:0x87f1242c] OM - Memory_cacheInv> Enter(addr=0x86368c00, sizeInBytes=25344)                                                                                                                                                                                   
    [DSP] @5,050,099tk: [+0 T:0x87f1242c] OM - Memory_cacheInv> return                                                                                                                                                                                                                      
    [DSP] @5,050,131tk: [+0 T:0x87f1242c] OM - Memory_cacheInv> Enter(addr=0x8636ef00, sizeInBytes=25344)                                                                                                                                                                                  
    [DSP] @5,050,210tk: [+0 T:0x87f1242c] OM - Memory_cacheInv> return                                                                                                                                                                                                                     
    [DSP] @5,050,244tk: [+0 T:0x87f1242c] OM - Memory_cacheInv> Enter(addr=0x86300000, sizeInBytes=327680)                                                                                                                                                                                 
    [DSP] @5,050,650tk: [+0 T:0x87f1242c] OM - Memory_cacheInv> return                                                                                                                                                                                                      
    [DSP] @5,050,689tk: [+0 T:0x87f1242c] ti.sdo.ce.video1.VIDENC1 - VIDENC1_process> Enter (handle=0x87f11ef8, inBufs=0x87f1764c, outBufs=0x87f1771c, inArgs=0x87305a04, outArgs=0x87305a10)                                                          
    [DSP] @5,050,787tk: [+5 T:0x87f1242c] CV - VISA_enter(visa=0x87f11ef8): algHandle = 0x87f11f30                                                                                                                                                                                    
    [DSP] @5,050,836tk: [+0 T:0x87f1242c] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Enter(alg=0x87f11f30)                                                                                                                                                                               
    [DSP] @5,050,886tk: [+0 T:0x87f1242c] ti.sdo.ce.alg.Algorithm - Algorithm_activate> Exit                                                                                                                                                           
    [DSP] @5,064,528tk: [+5 T:0x87f1242c] CV - VISA_exit(visa=0x87f11ef8): algHandle = 0x87f11f30                                                                                                                                                                 
    [DSP] @5,064,605tk: [+0 T:0x87f1242c] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Enter(alg=0x87f11f30)                                                                                                                                                                             
    [DSP] @5,064,664tk: [+0 T:0x87f1242c] ti.sdo.ce.alg.Algorithm - Algorithm_deactivate> Exit                                                                                                                                                   
    [DSP] @5,064,710tk: [+0 T:0x87f1242c] ti.sdo.ce.video1.VIDENC1 - VIDENC1_process> Exit (handle=0x87f11ef8, retVal=0x0)                                                                                                                                                        
    [DSP] @5,064,771tk: [+0 T:0x87f1242c] OM - Memory_cacheWb> Enter(addr=0x86300000, sizeInBytes=327680)                                                                                                                                    
    [DSP] @5,065,202tk: [+0 T:0x87f1242c] OM - Memory_cacheWb> return                                                                                                                                                                                                   
    [DSP] @5,065,237tk: [+5 T:0x87f1242c] CN - NODE> returned from call(algHandle=0x87f11ef8, msg=0x87305880); messageId=0x000288eb                                                                                                                                                      
    @2,692,986us: [+0 T:0x403c6000] CE - Engine_fwriteTrace> returning count [1998]                                                                                                                                                                                                         
    @2,693,108us: [+0 T:0x403c6000] CV - VISA_call Completed: messageId=0x000288eb, command=0x0, return(status=0)                                                                                                                                                                      
    @2,693,260us: [+5 T:0x403c6000] CV - VISA_freeMsg(0x54960, 0x413d4880): Freeing message with messageId=0x000288eb                                                                                                                                                                  
    @2,693,382us: [+0 T:0x403c6000] ti.sdo.ce.video1.VIDENC1 - VIDENC1_process> Exit (handle=0x54960, retVal=0x0)                                                                                                                                                                      
    ... return                                                                                                                                                                                                                                                                 
       DSP encoding output: frameType 0x3, frameSkip 0x0, bytes 439                                                                                                                                                                                                                   
    call VIDENC1_process()... @2,696,770us: [+0 T:0x403c6000] ti.sdo.ce.video1.VIDENC1 - VIDENC1_process> Enter ... (and so on, all 61 frames encoded)

     

    This is the trace when assign the callback function:

    call VIDENC1_process()... @3,053,013us: [+0 T:0x403c6000] XU - XdmUtils_validateExtendedStruct> Enter (pStruct=0x52720, minSize=0xc, name=inArgs
    @3,053,318us: [+0 T:0x403c6000] XU - XdmUtils_validateExtendedStruct> return (0x1)
    @3,053,440us: [+0 T:0x403c6000] XU - XdmUtils_validateExtendedStruct> Enter (pStruct=0x5272c, minSize=0x78, name=outArgs
    @3,053,562us: [+0 T:0x403c6000] XU - XdmUtils_validateExtendedStruct> return (0x1)
    @3,053,715us: [+0 T:0x403c6000] ti.sdo.ce.video1.VIDENC1 - VIDENC1_process> Enter (handle=0x54960, inBufs=0x5263c, outBufs=0x5270c, inArgs=0x52720, outArgs=0x5272c)
    @3,053,837us: [+0 T:0x403c6000] XU - XdmUtils_validateSparseBufDesc> Enter (bufDesc=0x5270c, name=outBufs
    @3,053,959us: [+0 T:0x403c6000] XU - XdmUtils_validateSparseBufDesc> return (0x1)
    @3,054,081us: [+4 T:0x403c6000] CV - VISA_getMaxMsgSize(0x54960): returning 0x1000
    @3,054,172us: [+5 T:0x403c6000] CV - VISA_allocMsg> Allocating message for messageId=0x00028944
    @3,054,356us: [+0 T:0x403c6000] CV - VISA_call(visa=0x54960, msg=0x413d4880): messageId=0x00028944, command=0x0

    (it just stops here)