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.

Slice Mode Configuration for MPEG4 encoder

Hi,

        If i set "ShortVideoHeader = 1, sliceMode = 2 and sliceUnitSize = 500", the CCS4 console will show below:

"ERROR: XDM_UNSUPPORTEDPARAM = 14, 

ERROR: XDM_FATALERROR = 15 

ERROR: IMPEG4ENC_UNSUPPORTED_MPEG4ENCPARAMS = 29, 

Error in Dynamic Parameter Settings.

Check the Dynamic parameter settings."

       The MPEG4 encoder version is "500_V_MPEG4SP_E_IVAHD_01_00." 

  • Hi Ed Jiang,

    The codec has been configured to encode video H263 or short video header and with packetization based on maximum number of bits (IMPEG4_SLICEMODE_BITS).

    For this to work, even the datasync functionality of Slice mode needs to be enabled (outputDataMode to be Equal to IVIDEO_SLICEMODE) as the H263 standard does not support packetization other than gob intervals.

    To quickly see how the bitstream is generated with packets based on bits consumed, reset the ShortVideoHeader = 0.

    Regards,

    Venugopala Krishna

     

     

  • Thanks a lot.  

    But i got another problem. Now i have to package H.263 stream into RTP package, so i need to know the boundary of the macro-block and the three parameters "QUANT, GOBN, and MBA".

    Is there any way to get the values of these parameters?

     

    Best Regards

  • Hi Ed Jiang,

    Which version of the Encoder you are using?

    The version 01.00.00.03 has this support to provide this additional information needed for RTP packetization.

    Regards,

    Venugopala Krishna

  • Dear Venugopala Krishna,

      Could you tell us, where could get the version 01.00.00.03 MPEG4 Encoder.

     

    Thanks a lot,

    Frank Lin

  • It should be available from the following site http://software-dl.ti.com/dsps/dsps_public_sw/codecs/HDVICP2/index_FDS.html

    or you might have to get in touch with business representatives.

     

    Regards,

    Venugopala Krishna

  • Thanks a lot.

    I've found the structure "IMPEG4ENC_DataSyncDesc" in the "impeg4enc.h", 

    but i didn't find any code about this in the "MPEG4SPEncTest.c", 

    Could you tell me how to use it?

  • Please refer to MPEG4E_TI_Update_putDataCallBack() function in the file client\Test\Src\mpeg4enc_ti_config.c

    To see how things works , In the .cfg file set the

    OutputDataMode             = 1     # 0=> Output DataSync (FIXEDLENGTH)
                                       # 1=> Output DataSync (SLICEMODE)
                                       # 3=> Encode entire frame into a bitstream in single call.

     

    Regards,

    Venugopala Krishna

  •  

            If i set "ShortVideoHeader = 1, sliceMode = 2 ,sliceUnitSize = 500 , and OutputDataMode  = 1" ,

                 or  "ShortVideoHeader = 0, sliceMode = 2 ,sliceUnitSize = 500 , and OutputDataMode  = 1" ,

     

             the encoder process will block on calling "MPEG4ENC_encodeFrame" on CCS4.

     

     

     

     

     

  • Hi Ed Jiang,

    Are you running on the simulator or EVM?

    On simulator this feature is not guaranteed to work properly or else it should work fine if run on Silicon H/w.

    Can you try giving higher value of sliceUnitSize? Which version of the codec you are using?

     

    Regards,

    Venu

  •   Dear Venu:

      The codec version is "REL.500.V.MPEG4.E.SP.IVAHD.01.00.00.03."

      It's running on the simulator CCS4. 

      And we don't have the McFW code for H.263 encoder, how to run it on the EVM?

     

      Thanks a lot.

  • Hi Ed Jiang,

    As doubted the this feature might not work properly on Simulator.

    The release has got sample testApp to test all the features, currently supported platforms are OMAP4 and DM816x.

    Say you have DM816x EVM, you can connect to M3_video and run the .out of test app in the folder Client\Build\TestAppDM816x\Out.

    What ever you were doing to run on the simulator, you can do on EVM too.

    Regards,

    Venu

  • Dear Venu:

     

        I've already run it on EVM. But the console just shows that "killed" .

     

    Thanks a lot.

     

  • Ed Jiang,

    Were you able to successfully run or not? What EVM you are using?

     

  •       Dear Venu:

          Yes, i were able to run it on DM816x EVM.

           But the console just showed that "killed", and nothing happened.

     

     

           Thanks a lot.

  • Ed Jiang,

    This is not on expected lines. Can you run the encoder with the .cfg(with out any modification) which comes along with the release?

     

  •      Dear Venu:

         I've tried it  !

         The same situation happened again, if i ran the encoder with the .cfg (without any modification ).

     

         Thanks a lot.

  • Ed jiang,

    Problem would be that you are not loading the correct .out on to the correct device.

    Can you share the log what gets printed on the M3 console?

     

  • Dear Venu:

      Thanks a lot!!

    I've already run the encoder successfully. But i need to get the info for RTP packetization, and i can't find the declared "XDM_DataSyncDesc" variable.

            So I have no idea to use the "Putdatacallback" function.  

     

    Best Regards 

  • HI Ed Jiang,

    Please refer to the Data Structure IMPEG4ENC_DataSyncDesc defined in the impeg4enc.h.

    May be what you do is put a break point in  MPEG4E_TI_Update_putDataCallBack()  and run a sample run with standalone test app with cfg modification done for multiSlice and outputDataSync to be slice mode. The you would get an understanding of how this information can be used RTP packetization.

     

     

  • Hi, 

    Now, i'm trying to merge the H.263 encoder into the EncLink. For this work, i modified MakeFile and added some files about H.263 for EncLink Obj creating.

            But i meet some problems about system command controlling. Ex: XDM_GETVERSION

            [m3video] 24911:!ERROR!:ENCLINK::links_m3video/iva_enc/encLink_h263.c:[306]::INTERNAL ERROR:-1

            [m3video] ALGCONTROL FAILED:CMD:6

            No matter what commands i used, the internal error always happened during system command contorlling. 
       
            Can you give me some suggestion for this work?

     

  • I suppose your are calling the control(XDM_GETVERSION) soon after the codec create.

    The alCreate failure is shown/prompted in the control(XDM_GETVERSION) call.

    Which means the create is failing.

    Can you share the values of the parameters of IMPEG4ENC_Params what you are passing to the codec create?

     

  •    I set the values by following 

      *staticParams = MPEG4ENC_TI_PARAMS;

      //=======================================================

      staticParams->videnc2Params.size = sizeof(IMPEG4ENC_Params);

      staticParams->videnc2Params.encodingPreset = 3;

      staticParams->videnc2Params.level = 3;

      staticParams->videnc2Params.maxHeight = 1088;

      staticParams->videnc2Params.maxWidth = 1920;

      staticParams->videnc2Params.dataEndianness = 1;

      staticParams->videnc2Params.maxInterFrameInterval = 0; /* No B frames */

      staticParams->videnc2Params.maxBitRate = 0;

      staticParams->videnc2Params.minBitRate = 0;

      staticParams->videnc2Params.inputContentType = 0;

      staticParams->videnc2Params.inputChromaFormat = 9;

      staticParams->videnc2Params.rateControlPreset = 5;

      staticParams->videnc2Params.operatingMode = 1;

      staticParams->vopTimeIncrementResolution = 30;

     

      staticParams->videnc2Params.inputDataMode = 2;

      staticParams->videnc2Params.outputDataMode = 1;

      staticParams->videnc2Params.numInputDataUnits = 5;

      staticParams->videnc2Params.numOutputDataUnits = 1;

     

      staticParams->videnc2Params.profile = 3;/* Simple profile */

     

     

      //==========================================================rate control

      staticParams->rateControlParams.vbvBufferSize = 0;

      staticParams->rateControlParams.initialBufferLevel = 0;

      staticParams->rateControlParams.rateControlParamsPreset = 1;

      staticParams->rateControlParams.rcAlgo = 1;

      staticParams->rateControlParams.qpI = 5;

      staticParams->rateControlParams.qpP = 5;

      staticParams->rateControlParams.seIntialQP = 5;

      staticParams->rateControlParams.qpMax = 31;

      staticParams->rateControlParams.qpMin = 1;

      staticParams->rateControlParams.enablePerceptualQuantMode = 1;

      staticParams->rateControlParams.allowFrameSkip = 0;

     

      //==================================================intercoding control

      staticParams->interCodingParams.interCodingPreset = 1;

      staticParams->interCodingParams.searchRangeHorP  = 44;

      staticParams->interCodingParams.searchRangeVerP = 28;

      staticParams->interCodingParams.globalOffsetME = 1;

      staticParams->interCodingParams.earlySkipThreshold  = 200;

      staticParams->interCodingParams.enableThresholdingMethod = 1;

      staticParams->interCodingParams.minBlockSizeP = 1;

      staticParams->interCodingParams.enableRoundingControl = 1;

     

      //=====================================================intracoding control

      staticParams->intraCodingParams.intraCodingPreset = 1;

      staticParams->intraCodingParams.intraRefreshMethod = 1;

      staticParams->intraCodingParams.intraRefreshRate = 12;

      staticParams->intraCodingParams.acpredEnable = 1;

      staticParams->intraCodingParams.insertGOVHdrBeforeIframe = 0;

      staticParams->intraCodingParams.enableDriftControl = 1;

     

      //========================================================slicecoding control

      staticParams->sliceCodingParams.sliceCodingPreset = 1;

      staticParams->sliceCodingParams.sliceMode = 2 ;

      staticParams->sliceCodingParams.sliceUnitSize = 1000;

      staticParams->sliceCodingParams.gobInterval = 1;

      staticParams->sliceCodingParams.useHec = 0;

     

      //========================================================MPEG4 param

      staticParams->useDataPartitioning = 0;

      staticParams->useRvlc = 0;

      staticParams->useShortVideoHeader = 1;

      staticParams->nonMultiple16RefPadMethod = 1;

      staticParams->pixelRange = 1;

      staticParams->enableSceneChangeAlgo = 1;

     

     

      //=======================================================DEBUG param

      staticParams->debugTraceLevel = 2;

      staticParams->lastNFramesToLog = 0;

     

      staticParams->useVOS = 1;

      staticParams->enableMONA = 0;

      staticParams->enableAnalyticinfo = 0;

  • Can you try making staticParams->debugTraceLevel =  0;

  • Hi, Venugopala:

     

          Thanks really!  Now XDM_GETVERSION,XDM_SETLATEACQUIREARG, and XDM_SETDEFAULT are working.

     

          But  XDM_SETPARAMS also failed .

     

     

         [m3video] 25265:!ERROR!:ENCLINK::links_m3video/iva_enc/encLink_h263.c:[306]::INTERNAL ERROR:-1

         [m3video] ALGCONTROL FAILED:CMD:1

     

  • This time pass on the values of the parameters of IMPEG4ENCDynamic_Paramswhich you are sending to control(XDM_SETPARMS)??

  •  The dynamic params as follows:

     

     memcpy (&((dynamicParams)->rateControlParams), &((staticParams)->rateControlParams),

        sizeof (IMPEG4ENC_RateControlParams));

      memcpy (&((dynamicParams)->interCodingParams), &((staticParams)->interCodingParams),

        sizeof (IMPEG4ENC_InterCodingParams));

      memcpy (&((dynamicParams)->sliceCodingParams), &((staticParams)->sliceCodingParams),

        sizeof (IMPEG4ENC_sliceCodingParams));

     

     

        dynamicParams->videnc2DynamicParams.size = sizeof(IVIDENC2_DynamicParams);

        dynamicParams->videnc2DynamicParams.inputWidth = 176 ;

        dynamicParams->videnc2DynamicParams.inputHeight = 144;

     

        dynamicParams->videnc2DynamicParams.captureWidth = 176;

     

        dynamicParams->videnc2DynamicParams.targetBitRate = 128000;

     

        dynamicParams->videnc2DynamicParams.targetFrameRate = 30000;

        dynamicParams->videnc2DynamicParams.generateHeader = 0; 

    dynamicParams->videnc2DynamicParams.forceFrame = -1;

        dynamicParams->videnc2DynamicParams.interFrameInterval = 1;

        dynamicParams->videnc2DynamicParams.intraFrameInterval = 30;

     

        dynamicParams->videnc2DynamicParams.mvAccuracy = 1;

     

        dynamicParams->videnc2DynamicParams.sampleAspectRatioHeight = 40;

     

        dynamicParams->videnc2DynamicParams.sampleAspectRatioWidth = 33;

    dynamicParams->videnc2DynamicParams.ignoreOutbufSizeFlag = 0;

    dynamicParams->videnc2DynamicParams.lateAcquireArg = 0;

            dynamicParams->videnc2DynamicParams.refFrameRate = 30000;

     

    dynamicParams->aspectRatioIdc = 1;

    dynamicParams->videnc2DynamicParams.getDataFxn = (XDM_DataSyncGetFxn)MPEG4E_TI_Update_getDataCallBack;

     

    dynamicParams->videnc2DynamicParams.getDataHandle = NULL;

     

     

    dynamicParams->videnc2DynamicParams.getBufferFxn = (XDM_DataSyncGetFxn)MPEG4E_TI_Update_getBufferCallBack;

     

    dynamicParams->videnc2DynamicParams.getBufferHandle = NULL;

     

     

    dynamicParams->videnc2DynamicParams.putDataFxn = (XDM_DataSyncPutFxn)MPEG4E_TI_Update_putDataCallBack;

     

    dynamicParams->videnc2DynamicParams.putDataHandle = NULL;

  • Can you check in the user guide what values are valid for interFrameInterval??

  • Is the issue resolved??

  • Hi,

     

         Thanks a lot . The problem is videnc2DynamicParams.size & InterframeInterval.

  • Hi, Venugopala:

    I got another problem when merging the H.263 encoder into EncLink.

            Encoding the frames by "handle->fxns->ividenc.process"  is failed.

           The error message is "INTERNAL ERROR:-1"

            I had checked the "Handle, inArgs, outArgs, inputBufDesc, and outputBufDesc".

            Should i check anything else?

     

    Best Regards

  •  

             MPEG4ENC_TI_Report_Error

             ERROR: XDM_INSUFFICIENTDATA = 10

  •  Hi Ed Jiang,

    One of the probable reason could be that The bufffer size given to encoder is not suffcient.

    What the value you have given for ignoreBufSize?? and what are the sizes of inBuf and outBuf??

  • Hi Venugopala,

    Do you mean the "ignoreOutbufSizeFlag"?  I set ignoreOutbufSizeFlag = 0.

           When the TilerEnable = FALSE, the size of inBuf is "inputBufDesc->planeDesc[i].bufSize.bytes = status.videnc2Status.bufInfo.minInBufSize[i].tileMem.width * status.videnc2Status.bufInfo.minInBufSize[i].tileMem.height".

           The size of outBuf is  "outputBufDesc->descs[i].bufSize.bytes = pReqObj->OutBuf->bufSize". Note that The type of pReqObj is "EncLink_ReqObj"

           In my case, the input src is 176 X 144 data, so the size of planeDesc[0] is 25344, and 12672 for planeDesc[1].

     

     

    Best Regards

  •  

    inputBufDesc->planeDesc[i].bufSize.bytes = status.videnc2Status.bufInfo.minInBufSize[i].tileMem.width * status.videnc2Status.bufInfo.minInBufSize[i].tileMem.height".

     

  • If you have set

    Ed Jiang said:
    ignoreOutbufSizeFlag = 0.

    Then the

    Ed Jiang said:
    outputBufDesc->descs[i].bufSize.bytes

    is not sufficient. Can you try giving a value which GET_BUF_INFO has requested for?

  • Hi,Venugopala,

     

      If i set "outputBufDesc->descs[i].bufSize.bytes = status.videnc2Status.bufInfo.minOutBufSize[i].bytes",

    the "handle->fxns->ividenc.process" seems to block. No getting any return value or error message.

     

           Best Regards.

     

  • Check whether you have implemented the dataSync function calls properly?

    HDVICP2 might be waiting for some data from M3. If these function implementations are not properly, HDVICP2 might be waiting for these to pass on some info for ever.

    Thats what you are seeing as the process() being blocking.

  • Hi,Venugopala,

     

               Thanks a lot. I resolved the dataSync problem, and encoded successfully.

     

    Best Regards.

  • Glad to know that the problem got fixed. What was the problem in DataSync implementation?

  • Hi,Venugopala,

     

    The "baseAddrGetBuffer" needed to set properly.  

     

           Best Regards

     

  • Hi, Venugopala,

    If i need to change the "FrameRate" dynamically, should i set the parameter "targetFrameRate" or "refFrameRate" or both them? 

    The user guide said both of them should be set the same value for encoder. And i  set targetFrameRate = 15*1000 ,  refFrameRate = 15*1000,

    the numbers of frame after encoding is double of that set targetFrameRate = 30*1000 , refFrameRate =30*1000 in the same encoding time.  

    The expected result should be half.

     

           I can encode successfully when set the sliceMode = 0, the output stream is correct. If i set sliceMode = 2, sliceUnitSize = 1000, OutputDataMode = 1, 

    the outputBufDesc->descs[0].buf seems to be not  written any data after "handle->fxns->ividenc.process".

    The values of outputBufDesc->descs[0].buf are the same whatever numbers of the encoded frame.

    But i watch the values of  bytesGenerated, encodedFrameType of outArgs->videnc2OutArgs. They seem to be correct.

    What is possible reason for this ?

     

    Best Regards

  • Coming to the framerate:

    Codec does not do any framerate conversion. In other words it gives out those many frame as many times process() call is called.

    The parameters targetFrameRate and refFrameRate needs to have same value and this value is used internall by Rate control algorithms for bit budgeting.

     

     

  • Hi,Venugopala,

     

    The framerate issue had resolved . Thanks a lot !!

             Do you  have any suggestion for the problem of  encoding with slice mode ?

     

     

    Best Regards

  • Hi,Venugopala:

    for the slice mode problem:

            I used the XDM_SETDEFAULT in my code, and the output bitstream is incorrect, and it didn't be blocked in the process().

    Without the cmd, I can encode the first frame correctly in slice mode, but blocked when the second frame into the process(). 

    This information is useful for helping me?

  • Hi Ed Jiang,

    You say:

    Ed Jiang said:
    Without the cmd, I can encode the first frame correctly in slice mode, but blocked when the second frame into the process().

    Can you try with out the cmd, give the sliceBits a huge value and see still the second frame process is blocked?

    Can you verify pass those post of mine which answered/solved each individual issue in this long thread of posts?

  • Hi,Venugopala:

    I try to give a huge value for sliceBits, ex: 8000,10000,20000 without the cmd.

    After being executed several times in the same sliceBits, the process() would be blocked in different frame.  Maybe 10th frame,or maybe 50th frame,or maybe 200th frame. 

    It seems to be blocked after executed the MPEG4E_TI_Update_putDataCallBack

    And i verified all ansered/solved issue. Thanks a lot!

  • Ed Jiang,

    Then the issue is with putData DataSync implementation at your end.

     

  • Hi,Venugopala:

    Still for the process() blocking issue, 

    The issue is with putData DataSync implementation at your end. 

    My DataSync functions all copied from mpeg4enc_ti_config.c of the TEST_APP. So do i need to modify it for Link architecture???

    You had ever said that if these dataSync function implementations are not properly, HDVICP2 might be waiting for these to pass on some info for ever.

    Thats what you are seeing as the process() being blocking.

    But i disable all codes of MPEG4E_TI_Update_putDataCallBack and MPEG4E_TI_Update_getBufferCallBack by comment marks, and run it on EVM.

    The encoding process of TEST_APP still works well, and no blocking in process.

    According to some DEBUG msgs, the Enc_Link seems to block in HDVICP_Wait(), and no one call the HDVICP_Done() for unlocking the semaphore.

    Best Regards.

  • Hi Ed Jiang,

    Can you try resetting the semphore used in the HDVICP_acquire() after every process call?

    Regards,

    Venu

  • Hi,Venugopala,

    Resetting the semphore doesn't work.

    I try to assign only one task to HDVICP. There is only one encoder or decoder at every HDVICP. 

    And i try to set a huge value which is equal to the frame size of inputstream to the sliceUnitSize.

    The encoding process with huge value of sliceUnitSize could live longer than the process with smaller value of sliceUnitSize.

    That is the encoding process with huge value of sliceUnitSize could encode more frame before it blocked.

    And i try to modify the HDVICP_WAIT and HDVICP_DONE. 

    I use the below code to replace the semaphore

           while(gMPEG4EIvahdDoneFlag == 0); gMPEG4EIvahdDoneFlag--;   for HDVICP_WAIT

            gMPEG4EIvahdDoneFlag++;                                                         for HDVICP_DONE.

    The encoding process with huge value of sliceUnitSize never block.

    But it could still blocked with smaller value of sliceUnitSize .

    Best Regard