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.

deinterlacer&mpeg4 problem



Hello,

 I asked this question in DaVinci video porocessors forum but didn't get any answer. So will try here..

In our project based on DM365 chip we work with 2 instances of codec (h264 or mpeg4) and instance of deinterlacer. It worked fine for us with version 0.9 but we encountered a problem of cmem memory leak while multiple create/delete procedures. Seems that version of 1.9 fixes the problem (at least as mentioned in release notes). So we tried to integrate the new deinterlacer with our code but failed.  During creation (after both mpeg4 codecs have been created) next error is indicated while creation of deinterlacer:  Assignment of alg resourcesthrough RMAN FAILED. (0x7). Seems we have lack of DMA resources or smth else. Below snip of codec debug messages during creation of deinterlacer component:

 33,384,668us: [+0 T:0x52b76490] CV - VISA_create(0x60f518, 'dei', 0x7f7498, 0x2496, 'ti.sdo.ce.video1.IVIDENC1')
@33,384,840us: [+0 T:0x52b76490] CV - VISA_create2(0x60f518, 'dei', 0x7f7498, 0x4c, 0x2496, 'ti.sdo.ce.video1.IVIDENC1')
@33,385,044us: [+0 T:0x52b76490] ti.sdo.ce.alg.Algorithm - Algorithm_create> Enter(fxns=0x5ec62c, idma3Fxns=0x0, iresFxns=0x5ec5ec, params=0x7f7498, attrs=0x52b75c8c)
@33,385,240us: [+0 T:0x52b76490] ti.sdo.ce.alg - ALG_create> Enter (scratchId=2, fxns=0x5ec62c, parentAlg=0x0, params=0x7f7498)
@33,385,461us: [+2 T:0x52b76490] ti.sdo.ce.alg - ALG_create> algNumAlloc 3 memory recs
@33,385,630us: [+2 T:0x52b76490] ti.sdo.ce.alg - ALG_create> algAlloc returned numRecs=3
@33,385,770us: [+4 T:0x52b76490] ti.sdo.ce.alg - ALG_create>  Memory requested memTab[0]: size=0xabc, align=0x100, space=0x11, attrs=0x1
@33,385,922us: [+4 T:0x52b76490] ti.sdo.ce.alg - ALG_create>  Memory requested memTab[1]: size=0x3000, align=0x100, space=0x11, attrs=0x1
@33,386,064us: [+4 T:0x52b76490] ti.sdo.ce.alg - ALG_create>  Memory requested memTab[2]: size=0x64, align=0x100, space=0x11, attrs=0x1
@33,386,416us: [+4 T:0x52b76490] OM - Memory_contigAlloc> CMEM_alloc(2748) = 0x43552000.
@33,386,629us: [+4 T:0x52b76490] OM - Memory_contigAlloc> CMEM_getPhys(0x43552000) = 0x8719a000.
@33,387,265us: [+4 T:0x52b76490] OM - Memory_contigAlloc> CMEM_alloc(12288) = 0x53f4b000.
@33,387,499us: [+4 T:0x52b76490] OM - Memory_contigAlloc> CMEM_getPhys(0x53f4b000) = 0x87197000.
@33,388,034us: [+4 T:0x52b76490] OM - Memory_contigAlloc> CMEM_alloc(100) = 0x53f4e000.
@33,388,262us: [+4 T:0x52b76490] OM - Memory_contigAlloc> CMEM_getPhys(0x53f4e000) = 0x85800000.
@33,389,158us: [+4 T:0x52b76490] ti.sdo.ce.alg - ALG_create> algInit returned IALG_EOK
@33,389,468us: [+0 T:0x52b76490] ti.sdo.ce.alg - ALG_create> Exit (algHandle=0x43552000)
@33,389,664us: [+0 T:0x52b76490] ti.sdo.fc.rman - RMAN_assignResources> Enter (alg=0x43552000, resFxns=0x5ec5ec, scratchGroupId=2)
@33,390,087us: [+4 T:0x52b76490] OM - Memory_contigAlloc> CMEM_alloc(128) = 0x53f4f000.
@33,390,314us: [+4 T:0x52b76490] OM - Memory_contigAlloc> CMEM_getPhys(0x53f4f000) = 0x857d6000.
@33,390,611us: [+0 T:0x52b76490] ti.sdo.ce.osal.LockMP - Entered LockMP_acquire> lock[0x60f1e0]
@33,391,229us: [+0 T:0x424bc490] ti.sdo.fc.edma3 - resToDev> Exit (devId=0)
@33,391,433us: [+0 T:0x424bc490] ti.sdo.fc.edma3 - freeResource> Enter (index=1, resObj->type=1, resObj->resId=0, num=1)
@33,391,607us: [+2 T:0x424bc490] ti.sdo.fc.edma3 - freeResource> Calling unregister on 0
@33,391,778us: [+0 T:0x424bc490] ti.sdo.fc.edma3 - freeResource> Exit (status=1)
@33,391,923us: [+0 T:0x424bc490] ti.sdo.fc.edma3 - EDMA3_freeLogicalChannel> Exit (status=EDMA3_SOK)
@33,392,064us: [+0 T:0x424bc490] ti.sdo.fc.edma3 - EDMA3_releaseResourceManagerObject> Enter (algHandle=0x43225000, scratchId=1)
@33,392,221us: [+2 T:0x424bc490] ti.sdo.fc.edma3 - EDMA3_releaseResourceManager> Number of calls:- process 91, overall 91
@33,392,413us: [+0 T:0x424bc490] ti.sdo.fc.edma3 - EDMA3_releaseResourceManagerObject> Exit (status=EDMA3_SOK)
@33,392,557us: [+0 T:0x424bc490] ti.sdo.fc.ires.edma3Chan - _freeResource> Exit (status=0)
@33,392,700us: [+0 T:0x424bc490] ti.sdo.fc.edma3 - EDMA3_releaseResourceManagerObject> Enter (algHandle=0x43225000, scratchId=1)
@33,392,845us: [+2 T:0x424bc490] ti.sdo.fc.edma3 - EDMA3_releaseResourceManager> Number of calls:- process 90, overall 90
@33,392,988us: [+0 T:0x424bc490] ti.sdo.fc.edma3 - EDMA3_releaseResourceManagerObject> Exit (status=EDMA3_SOK)
@33,393,127us: [+0 T:0x424bc490] ti.sdo.fc.ires.edma3Chan - IRES_EDMA3CHAN_getNumMemRecs> Enter (protArgs=0x43225210)
@33,393,263us: [+0 T:0x424bc490] ti.sdo.fc.ires.edma3Chan - IRES_EDMA3CHAN_getNumMemRecs> Exit (Num=1)
@33,398,607us: [+0 T:0x424bc490] ti.sdo.fc.ires.edma3Chan - IRES_EDMA3CHAN_getMemRecs> Enter (handle=0x0, resProtocolArgs=0x43225210, memRecs=0x424bb8e0)
@33,398,829us: [+4 T:0x424bc490] ti.sdo.fc.ires.edma3Chan - IRES_EDMA3CHAN_getMemRecs> Amount of memory requested 0x38, alignment 0x4, space IALG_EXTERNAL attrs IALG_PERSIST
@33,398,997us: [+0 T:0x424bc490] ti.sdo.fc.ires.edma3Chan - IRES_EDMA3CHAN_getMemRecs> Exit (status=IRES_EOK)
@33,399,140us: [+0 T:0x424bc490] ti.sdo.fc.ires.edma3Chan - IRES_EDMA3CHAN_destructHandle> Enter
@33,399,271us: [+0 T:0x424bc490] ti.sdo.fc.ires.edma3Chan - IRES_EDMA3CHAN_destructHandle> Exit (returnVal=IRES_OK)
@33,399,750us: [+0 T:0x424bc490] ti.sdo.fc.ires.edma3Chan - IRESMAN_EDMA3CHAN_freeHandles> Exit (status=0)
@33,399,957us: [+0 T:0x424bc490] ti.sdo.ce.osal.LockMP - Entered LockMP_release>lock[0x60f1e0]
@33,400,188us: [+0 T:0x52b76490] ti.sdo.ce.osal.LockMP - Leaving LockMP_acquire> lock[0x60f1e0]
@33,400,369us: [+0 T:0x52b76490] ti.sdo.fc.ires.hdvicp - IRESMAN_HDVICP_getProtocolName> Enter
@33,400,512us: [+0 T:0x52b76490] ti.sdo.fc.ires.hdvicp - IRES_HDVICP_getName> Enter
@33,400,638us: [+0 T:0x52b76490] ti.sdo.fc.ires.hdvicp - IRES_HDVICP_getName> Exit (Name=ti.sdo.fc.ires.hdvicp)
@33,400,764us: [+0 T:0x52b76490] ti.sdo.fc.ires.hdvicp - IRESMAN_HDVICP_getProtocolName> Exit (name=ti.sdo.fc.ires.hdvicp)
@33,400,895us: [+0 T:0x52b76490] ti.sdo.fc.ires.hdvicp - IRES_HDVICP_getName> Enter
@33,401,047us: [+0 T:0x52b76490] ti.sdo.fc.ires.hdvicp - IRES_HDVICP_getName> Exit (Name=ti.sdo.fc.ires.hdvicp)
@33,401,204us: [+0 T:0x52b76490] ti.sdo.fc.ires.vicp2 - IRESMAN_VICP2_getProtocolName> Enter
@33,401,342us: [+0 T:0x52b76490] ti.sdo.fc.ires.vicp2 - IRESMAN_VICP2_getProtocolName> Exit (name=ti.sdo.fc.ires.vicp2)
@33,401,486us: [+0 T:0x52b76490] ti.sdo.fc.ires.vicp2 - IRESMAN_VICP2_getProtocolRevision> Enter
@33,401,614us: [+0 T:0x52b76490] ti.sdo.fc.ires.vicp2 - IRESMAN_VICP2_getProtocolRevision> Exit (version=(1.0.0))
@33,401,753us: [+0 T:0x52b76490] ti.sdo.ce.osal.LockMP - Entered LockMP_release>lock[0x60f1e0]
@33,401,915us: [+0 T:0x52b76490] ti.sdo.ce.osal.LockMP - Leaving LockMP_release>lock[0x60f1e0]
@33,402,061us: [+2 T:0x52b76490] ti.sdo.fc.rman - RMAN_assignResources> Call getHandle on the IRESMAN implementation 0x5ec67c
@33,402,205us: [+0 T:0x52b76490] ti.sdo.ce.osal.LockMP - Entered LockMP_acquire> lock[0x60f1e0]
@33,402,357us: [+0 T:0x52b76490] ti.sdo.ce.osal.LockMP - Leaving LockMP_acquire> lock[0x60f1e0]
@33,402,717us: [+4 T:0x52b76490] OM - Memory_contigAlloc> CMEM_alloc(344) = 0x43555000.
@33,403,123us: [+4 T:0x52b76490] OM - Memory_contigAlloc> CMEM_getPhys(0x43555000) = 0x8719b000.
@33,403,433us: [+7 T:0x52b76490] ti.sdo.fc.ires.vicp2 - IRESMAN_VICP2_getHandles> Allocation of IMX0 for the VICP2 handle failed busy 1 refcount 0
@33,403,784us: [+0 T:0x52b76490] ti.sdo.fc.ires.vicp2 - IRESMAN_VICP2_getHandles> Exit (resourceHandle=0x0)
@33,403,973us: [+0 T:0x52b76490] ti.sdo.ce.osal.LockMP - Entered LockMP_release>lock[0x60f1e0]
@33,404,156us: [+0 T:0x52b76490] ti.sdo.ce.osal.LockMP - Leaving LockMP_release>lock[0x60f1e0]
@33,404,490us: [+0 T:0x52b76490] ti.sdo.fc.rman - RMAN_assignResources> Exit (status=7)
@33,404,668us: [+7 T:0x52b76490] ti.sdo.ce.alg.Algorithm - Algorithm_create> Assignment of alg resources through RMAN FAILED (0x7)
@33,404,821us: [+0 T:0x52b76490] ti.sdo.ce.alg.Algorithm - Algorithm_delete> Enter(alg=0x623420)
@33,405,321us: [+0 T:0x52b76490] ti.sdo.ce.alg.Algorithm - Algorithm_delete> Exit
@33,405,503us: [+0 T:0x52b76490] ti.sdo.ce.alg.Algorithm - Algorithm_create> return (0x0)
@33,405,647us: [+2 T:0x52b76490] CV - VISA_create2> FAILED to create local codec.

Can you explain what  message Allocation of IMX0 for the VICP2 handle failed busy 1 refcount 0 means? DEI is created after MPEG4 encoder has been created succesfully. We use framework component 2.25.03.07 and linuxutils 2.25.03.09 if it is relevant

 

Thank you in advance

  • Per your detailed trace log, the failure is a result of failure to allocate some IRES VICP2 type resources. Specifically the IMX1 component of the VICP2 resource is busy (likely because it has been previously allocated to some other codec).

    Maybe you can double check if some other codec (previously created) is requesting this component. (Either through the codec data sheet, or look at the IRES implementation in the codec sources, to see if it requires resources of type IRES VICP2, specifically the IMX1 resource).

    From the trace I can tell that the codec that has occupied this resource, is probably in scratch group #1. This codec (the trace from which has been displayed) is in scratch group #2, which means that you intend to create it with a different set of resources and you intend to run the two codecs simultaneously. Since only 1 codec can get the IMX1 component and both seem to need it, the codec creation has failed....

  • Hi Julia,

    Yes,DM36X DEI ver 1.9 fixes the memory leak issue.

    While integrating it into your system pl. note the following points:

    1.You download the DM36x DEI ver 1.9 from the link - https://twiki.dal.design.ti.com/twiki/bin/view/ASP/DSPS/VsiProjects

    2.When you want to create DEI with scratch id = 2 and MPEG4 enc with scratch id = 1 then make sure you set 'askIMCOPRes = 0' while creating the DEI algorithm.

    3.Pl. look at sec 4.4 of DEI user guide for info on passing sysBaseAddr parameter to the DEI alg.

    4.Avoid running DEI in parallel with MPEG4 enc using mutex.

    regards,

    Anand

     

  • Hi Anand,

    thank you for the response. First of all this link doesn'work for me. We got DEI from TI FAE at September,2010 (more updated version will be appreciated )..  I checked twice and askIMCOPRes=0 while DEI aldorithm creating. I pass sysBaseAddr as described in DEI user guide .There is no API DM365MM_mmap (I tried to added it but get the same result)exposed to user in our dvsdk version so I use next function to get sysBaseAddr  :

    //sysRegBase = DM365MM_mmap(0x01C40000,0x4000);
      fm = open("/dev/mem",O_RDWR|O_SYNC);
        sysRegBase = (int)mmap( (void*)0,
          0x4000,
          PROT_READ | PROT_WRITE,
          MAP_SHARED,
          fm,
          0x01C40000);

    here snip of cfg file:

    var DEI      = xdc.useModule('ti.sdo.codecs.dei.ce.DEI');
    var H264ENC  = xdc.useModule('ti.sdo.codecs.h264enc.ce.H264ENC');
    var MPEG4ENC = xdc.useModule('ti.sdo.codecs.mpeg4enc.ce.MPEG4ENC');
    var G711ENC  = xdc.useModule('ti.sdo.ce.examples.codecs.g711.G711ENC');
    var JPEGENC  = xdc.useModule('ti.sdo.codecs.jpegenc.ce.JPEGENC');
    var JPEGDEC  = xdc.useModule('ti.sdo.codecs.jpegdec.ce.JPEGDEC');
    var KTNF     = xdc.useModule('ti.sdo.codecs.ktnf.ce.KTNF');
     

    var Engine = xdc.useModule('ti.sdo.ce.Engine');
    var myEngine = Engine.create("encode", [
     {name: "ktnf",   mod: KTNF,  local: true, groupId: 2},
     {name: "dei",   mod: DEI,      local: true, groupId: 2},
     {name: "mpeg4enc", mod: MPEG4ENC,  local: true, groupId: 1},
     {name: "h264enc",  mod: H264ENC,  local: true, groupId: 1},
     {name: "g711enc",  mod: G711ENC,  local: true},
     {name: "jpegdec",  mod: JPEGDEC,  local: true, groupId: 1},
     {name: "jpegenc",  mod: JPEGENC,  local: true, groupId: 1}
     
    ]);

    We use MPEG4 codec of version 01.00.00.09 and it works with previous version of DEI (we use mutex when they run parallel).  Can you advice?

  • Hi Gunjan,

    yes you are right, I use different scratch groups for MPEG4 codec and DEI.

     {name: "dei",   mod: DEI,      local: true, groupId: 2},
     {name: "mpeg4enc", mod: MPEG4ENC,  local: true, groupId: 1},
     {name: "h264enc",  mod: H264ENC,  local: true, groupId: 1},
     {name: "g711enc",  mod: G711ENC,  local: true},
     {name: "jpegdec",  mod: JPEGDEC,  local: true, groupId: 1},
     {name: "jpegenc",  mod: JPEGENC,  local: true, groupId: 1} 


    How can you suggest to configure scratch group Ids  to get both codecs and DEI working?

     

    Thank you in advance

     

     

  • HI Julia,

    Can you check with TI FAE for the latest DM36x DEI and dm365mmap lib?

    regards,

    Anand

     

  • Hi Anand,

    sorry my fault, we have version 1.9 of september 2011. I think the problem is actually that mpeg4 and dei can not be run from differemt scratch id groups. Now I will try to run them from the same id.

    Julia

  • Hi Julia,

    You should be able to create MPEG4 and DEI with different group ids.

    Can you pl. check if you have different versions idei.h file in DEI RTSC package and in your application?

    regards,

    Anand