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.

H264 encoder Buffer error.

Other Parts Discussed in Thread: DM3730

I am working with dvsdk_dm3730_evm_4_02_00_06,linux kernel is 2.6.32, h264 encoder version is 01.00.02.00, dmai version is 2_20_00_15.

My hardware platform is dm3730 with 512M memory.

# 0x80000000     256MB  Linux
# 0x90000000     32 MB  CMEM
# 0x92000000     4 KB   DSPLINK (RESET)
# 0x92001000     1 MB   DSPLINK (MEM)
# 0x92200000    192MB   DDRALGHEAP
# 0x9e200000     8 MB   DDR2 (BIOS, Codecs, Applications)

In purpose of support ColorSpace_YUV420P, I add a part of code in dmai's source file ce/Venc1.c:

from line 149:

    else if (BufferGfx_getColorSpace(hInBuf) == ColorSpace_YUV420P) {/*add by G.K*/
        inBufDesc.bufDesc[0].bufSize    = hVe->minInBufSize[0];
        inBufDesc.bufDesc[1].bufSize    = hVe->minInBufSize[1];
        inBufDesc.bufDesc[2].bufSize    = hVe->minInBufSize[2];

        inBufDesc.bufDesc[0].buf        = inPtr;
        inBufDesc.bufDesc[1].buf        = inPtr + dim.width*dim.height;
        inBufDesc.bufDesc[2].buf        = inBufDesc.bufDesc[1].buf + (dim.width>>1)*(dim.height>>1);
        inBufDesc.numBufs               = 3;
    }    

I call the encoder using the following code:
//open engine

    CERuntime_init();
    Dmai_init();
    handle->engine=Engine_open(engineName,NULL,NULL);
    if(handle->engine==NULL)
    {
        printf("OMAPCELIB ERROR: can not open engine %s.\n",engineName);
        free(handle);
        return 0;
    }

//open encoder

    params.size=sizeof(params);
    params.encodingPreset=XDM_DEFAULT;
    params.rateControlPreset=IVIDEO_NONE;
    params.maxWidth=imageWidth;
    params.maxHeight=imageHeight;
    params.maxFrameRate=30000;
    params.maxBitRate=6000000;
    params.dataEndianness=XDM_BYTE;
    params.maxInterFrameInterval=1;
    params.inputChromaFormat=XDM_YUV_420P;
    params.inputContentType=IVIDEO_PROGRESSIVE;
    params.reconChromaFormat=XDM_CHROMA_NA;

    dynParams.size=sizeof(dynParams);
    dynParams.inputWidth=imageWidth;
    dynParams.inputHeight=imageHeight;
    dynParams.refFrameRate=30000;
    dynParams.targetFrameRate=30000;
    dynParams.targetBitRate=6000000;
    dynParams.intraFrameInterval=30;
    dynParams.generateHeader=XDM_ENCODE_AU;
    dynParams.captureWidth=0;
    dynParams.forceFrame=IVIDEO_NA_FRAME;
    dynParams.interFrameInterval=1;
    dynParams.mbDataFlag=0;
    handle->dynParams=dynParams;

    handle->enc=Venc1_create(lib->engine, h264EncoderName, &params, &dynParams);
    if(handle->enc==NULL)
    {
        printf("OMAPLIB ERROR: create encoder %s failed.\n",h264EncoderName);
        goto VENC_CLEANWORK;
    }

//get in buffer size and out buffer size

    bufSize=Venc1_getInBufSize(handle->enc);
    bufSize=Dmai_roundUp(bufSize,BUFSIZEALIGN);
    gfxAttrs=BufferGfx_Attrs_DEFAULT;
    gfxAttrs.colorSpace=ColorSpace_YUV420P;
    gfxAttrs.dim.width=imageWidth;
    gfxAttrs.dim.height=imageHeight;
    gfxAttrs.dim.lineLength=BufferGfx_calcLineLength(imageWidth,ColorSpace_YUV420P);
    handle->inBuf=Buffer_create(bufSize,BufferGfx_getBufferAttrs(&gfxAttrs));
    if(handle->inBuf==NULL)
    {
        printf("OMAPLIB ERROR: create encoder input buffer failed.\n");
        return -1;
    }
    BufferGfx_resetDimensions(handle->inBuf);

    bufSize=Venc1_getOutBufSize(handle->enc);
    bufSize=Dmai_roundUp(bufSize,BUFSIZEALIGN);
    bAttrs=Buffer_Attrs_DEFAULT;
    handle->outBuf=Buffer_create(bufSize,&bAttrs);
    if(handle->outBuf==NULL)
    {
        printf("OMAPLIB ERROR: create encoder output buffer failed.\n");
        return -1;
    }
// do encode

    userPtr=Buffer_getUserPtr(enc->inBuf);
    bufLen=Buffer_getSize(enc->inBuf);
    if(bufLen<dataLen)
    {
        printf("OMAPCELIB ERROR: setted picture size is not consonant with input picture size.\n");
        return -1;
    }
    memcpy(userPtr,picData,dataLen);
    Buffer_setNumBytesUsed(enc->inBuf,dataLen);
    /*  
     *  To meet xDAIS DMA Rule 7, when input buffers are cached, we
     *  must writeback the cache into physical memory.  Also, per DMA
     *  Rule 7, we must invalidate the output buffer from
     *  cache before providing it to any xDAIS algorithm.
     */
    Memory_cacheWbInv(userPtr,bufLen);
    Memory_cacheInv(Buffer_getUserPtr(enc->outBuf),Buffer_getSize(enc->outBuf));
    ret=Venc1_process(enc->enc,enc->inBuf,enc->outBuf);
    if(ret<0)
    {
        printf("OMAPCELIB ERROR: call Venc1_process() failed.\n");
        return -1;
    }
    
    userPtr=Buffer_getUserPtr(enc->outBuf);
    bufLen=Buffer_getSize(enc->outBuf);
    Memory_cacheInv(userPtr,bufLen);
//other work ........

I use the CREW_704x576_30_orig_01.yuv file as source file, encode one frame->decode it->show.

This Test app can work well, with out the initial decoded frames (about 8 frames)can not be shown(wrong frame size, such as -1091537980x1073860616).

However, When I run the test app with CE_DEBUG=1, I get the wrong message:

$CE_DEBUG=1 ./test

....

@1,612,823us: [+7 T:0x400202f0] OM - Memory_getVirtualAddress> Error: buffer (physAddr=0x92474575, size=0x75d80) not found in translationcache

Ensure that you have registered this buffer with Memory_registerContigBuf()
@1,612,976us: [+7 T:0x400202f0] OM - Memory_getVirtualAddress> Error: buffer (physAddr=0x924eefd3, size=0x1d640) not found in translationcache

Ensure that you have registered this buffer with Memory_registerContigBuf()
@1,613,037us: [+7 T:0x400202f0] OM - Memory_getVirtualAddress> Error: buffer (physAddr=0x9250e3d3, size=0x1d640) not found in translationcache

Ensure that you have registered this buffer with Memory_registerContigBuf()

...

Through the printf(" ") sentence, I am sure The error message comes frome Venc1_process() function.

How can I solve this problem?

Thank you very much!!!!!!

  • Hi geng,

    These error messages are saying that CE is trying to get the virtual address of some buffers and failing to do so, probably via the Memory_getBufferVirtualAddress() calls in the stubs <CE_INSTALL_DIR>/packages/ti/sdo/ce/video1/videnc1_stubs.c. Maybe the physical memory pointers returned by the codec for the output are not within the range of the output buffers given to it? You may want to run your program with CE_DEBUG=2 or CE_DEBUG=3 to get the full trace which has more details.

    Best regards,

    Vincent