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.

problems in allocating memory in shared region 2 in OMX capture encode example

Hi,

I am trying to allocate buffer in shred region 2 as explained by Vimal here: http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/717/p/155685/564349.aspx#564349

by adding the following commands to the capture encode OMX example as suggested by Vimal:

srHeap = SharedRegion_getHeap(region); //region is 2 in ezsdk
virtAddr = (UInt32)Memory_alloc((IHeap_Handle)srHeap , nbytes, 0, NULL);
char *srPtr = (char*) SharedRegion_getSRPtr ((Ptr) virtAddr, region);

i had to add tho following include files to compile the example:

#include <xdc/runtime/Memory.h>
#include <xdc/runtime/IHeap.h>
#include <ti/ipc/SharedRegion.h>

I am receving a srHeap which is non zero, but the example stuck during Memory_alloc.

Can somone please help?

Thanks,
Gabi 

  • Hi,

    I have been trying to skip the Memory_alloc stuck problem for now and continue with what Vimal has suggested, i have used shared region 2 addresses to get the physical addresses and then used mmap to get the corresponding virtual addresses as follows:

    PhydeipOutBuff[0] = (0xB9B00000 + 1*0x400000);
    PhydeipOutBuff[1] = (0xB9B00000 + 2*0x400000);
    PhydeipOutBuff[2] = (0xB9B00000 + 3*0x400000);
    PhydeipOutBuff[3] = (0xB9B00000 + 4*0x400000);
    PhydeipOutBuff[4] = (0xB9B00000 + 5*0x400000);

    VirtdeipOutBuff[0] = mmap(0, 0x400000, PROT_READ | PROT_WRITE, MAP_SHARED, memfd, PhydeipOutBuff[0] );
    VirtdeipOutBuff[1] = mmap(0, 0x400000, PROT_READ | PROT_WRITE, MAP_SHARED, memfd, PhydeipOutBuff[1] );
    VirtdeipOutBuff[2] = mmap(0, 0x400000, PROT_READ | PROT_WRITE, MAP_SHARED, memfd, PhydeipOutBuff[2] );
    VirtdeipOutBuff[3] = mmap(0, 0x400000, PROT_READ | PROT_WRITE, MAP_SHARED, memfd, PhydeipOutBuff[3] );
    VirtdeipOutBuff[4] = mmap(0, 0x400000, PROT_READ | PROT_WRITE, MAP_SHARED, memfd, PhydeipOutBuff[4] );

    Now i am using these buffers in OMX_UseBuffer as follows:

    eError = OMX_UseBuffer (pAppData->pDeiHandle,
    &outPortParamsPtr->pOutBuff[i],
    OMX_VFPC_OUTPUT_PORT_START_INDEX,
    pAppData->deiILComp,
    0x3F4800,
    VirtdeipOutBuff[i]);

    And i get the following error:
    Error in OMX_AllocateBuffer()-Output Port State set : OMX_ErrorUndefined
    Can anyone please help?

    Gabi


  • Hi,

    Well i figured out a way to do it, by inserting CMEM at shared region 2, one can allocate buffers using CMEM_alloc(), and get their physical address with CMEM_getphys().

    Gabi 

  • Gabi,

    If you check decode_mosaic example, which does allocate buffers on A8 from SR2, you should be able to verify the issue. 

    Regards

    Vimal

  • Hi Vimal,

    Thank you very much for your answer, I have tested decode_mosaicdisplay in EZSDK ver 5.04 and indded it working OK and it is doing what i want. Also i saw that there is a new DOMX function DomxCore_mapUsrVirtualAddr2phy() that translate from virtual to physical, this is great.
    Now i can allocate My video frame buffer in shared region 2, copy OMX component video frame buffer fast with EDMA, process it with A8 and copy it back fast with EDMA.
    When only loopback is performed via my buffer the rate remain 60 fps.
    The only problem now is that when doing minor processing on the A8 buffer frame rate drops to 1fps.
    Can you please answer what is TI prefered way to process the video frame fast enough with the A8?
    Please also see this thread: http://e2e.ti.com/support/embedded/linux/f/354/p/206982/733671.aspx#733671

    Thanks,
    Gabi

  • Hello

    i have see that i can not copy directly the buffers out of the capture stage of the example of OMX "capture and encode" becouse it is too slow. I read this thread and i see that i have to

    1) share the omx buffer region

    2) enable dma copy

    3) any other operations?

    Could you show me a complete example about this? Could you attach a code example? Now if i transfer a frame of 720x40 it takes me about 40ms....

    Tanks for the help

  • Hi,

    Are you transferring these buffers to be used by DSP ? As Gabi has suggested on other post EDMA should help.

    Regards

    Vimal

  • Hello

    i have to do some statistics and elaboration so i have to do about 3 copies of the image. i also to do 3 streamings h264. Could you attach me an example on how to do a memcpy from the omx buffers? Are there other threads where there is a attached code example on how to do this? Thanks.