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.

Accessing Motion Vectors using DMAI: got wrong minNumOutBufs

Other Parts Discussed in Thread: OMAP3530

Hi,

I am working for TI MPEG4 video encoder and tying to make an application to access
motion vectors by modifying TI DMAI video_encode_io1. 


I moved the first step forwad to access MV data as follows: I started from video_encode_io1 code under dvsdk_3_00_00_36/dmai_2_00_00_02 packages. Based on MPEG4 Simple Profile Encoder on OMAP3530 User Guide (Jan 2009), I declared IMP4VENC_DynamicParams extDynParams and set the flag of MVDataEnable.
Then, created Venc1 successfully by calling Venc1_create(hEngine, args->codecName, &params, (VIDENC1_DynamicParams*)&extDynParams).

By calling control(..,XDM_SETPARAMS,..) and control(..,XDM_GETBUFINFO,..), minNumOutBufs is supposed to be 2. But I get minNumOutBufs=1 when I run the application on OMAP3530 target.

(I have attached the appMain.c I modified)


Does anyone has a suggestion why this does not work ?

 

Thank you !

John

==============

#include <stdio.h>

#include <xdc/std.h>

#include <ti/sdo/ce/Engine.h>
#include <ti/sdo/ce/CERuntime.h>

#include <ti/sdo/dmai/Dmai.h>
#include <ti/sdo/dmai/Ccv.h>
#include <ti/sdo/dmai/Cpu.h>
#include <ti/sdo/dmai/Time.h>
#include <ti/sdo/dmai/BufTab.h>
#include <ti/sdo/dmai/Capture.h>
#include <ti/sdo/dmai/Framecopy.h>
#include <ti/sdo/dmai/BufferGfx.h>
#include <ti/sdo/dmai/ce/Venc1.h>

#include <string.h>       
#include "appMain.h"
#include "mp4venc_ti.h"
#include "imp4venc.h"

Void appMain(Args * args)
{
    VIDENC1_Params         params    = Venc1_Params_DEFAULT;
    VIDENC1_DynamicParams  dynParams = Venc1_DynamicParams_DEFAULT;
    BufferGfx_Attrs        gfxAttrs  = BufferGfx_Attrs_DEFAULT;
    Buffer_Attrs           bAttrs    = Buffer_Attrs_DEFAULT;
    Time_Attrs             tAttrs    = Time_Attrs_DEFAULT;
    Venc1_Handle           hVe1      = NULL;
    FILE                  *outFile   = NULL;
    FILE                  *reconFile = NULL;
    FILE                  *inFile    = NULL;
    Engine_Handle          hEngine   = NULL;
    Time_Handle            hTime     = NULL;
    Buffer_Handle          hOutBuf   = NULL;
    Buffer_Handle          hInBuf    = NULL;
    Buffer_Handle          hReconBuf = NULL;
    Int                    numFrame  = 0;
    Int                    inBufSize, outBufSize;
    Cpu_Device             device;
    ColorSpace_Type        colorSpace;
    UInt32                 time;

     /* Added for MV Access */
    IMP4VENC_DynamicParams extDynParams = {
        Venc1_DynamicParams_DEFAULT,
        0,    //resync
        0,    //hec
        0,    //air
        1,    //mir
       12,   //QI
       12,   //QP
        3,    //fcode
        1,    //HPI
        0,    //ACpred
        0,    //LFF
        0,    //MVaccess
        1,    //UMV
        0,    //4MV
        1,    //resync data
    };

    CERuntime_init();

   Dmai_init();

    inFile = fopen(args->inFile, "rb");

    outFile = fopen(args->outFile, "wb");

    hEngine = Engine_open(args->engineName, NULL, NULL);

    //set parameters
   params.rateControlPreset = IVIDEO_LOW_DELAY;
   params.maxBitRate        = args->bitRate;
   params.inputChromaFormat = XDM_YUV_422ILE;
   params.maxWidth              = args->width;
   params.maxHeight             = args->height;
   params.dataEndianness         = XDM_BYTE;
   params.maxInterFrameInterval  = 1;
   params.inputContentType       = IVIDEO_CONTENTTYPE_DEFAULT ;
   params.reconChromaFormat      = XDM_CHROMA_NA ;

   dynParams.targetBitRate      = params.maxBitRate;
   dynParams.inputWidth         = params.maxWidth;
   dynParams.inputHeight        = params.maxHeight;

   extDynParams.videncDynamicParams.size = sizeof(IMP4VENC_DynamicParams);
   extDynParams.MVDataEnable = 1; /**** to enable MV access ***/
   extDynParams.videncDynamicParams = dynParams;

    /* Create the video encoder */
    //hVe1 = Venc1_create(hEngine, args->codecName, &params, &dynParams);
    hVe1 = Venc1_create(hEngine, args->codecName, &params, (VIDENC1_DynamicParams*)&extDynParams);

    inBufSize = Venc1_getInBufSize(hVe1);
    outBufSize = Venc1_getOutBufSize(hVe1);
    colorSpace = device == Cpu_Device_DM6467 ? ColorSpace_YUV420PSEMI :
                                               ColorSpace_UYVY;

    gfxAttrs.bAttrs.memParams.align = bAttrs.memParams.align = BUFSIZEALIGN;
    if (args->cache) {
        gfxAttrs.bAttrs.memParams.flags = bAttrs.memParams.flags
            = Memory_CACHED;
   }
   
   gfxAttrs.dim.width      = args->width;
   gfxAttrs.dim.height     = args->height;
   gfxAttrs.dim.lineLength = BufferGfx_calcLineLength(args->width, colorSpace);
   gfxAttrs.colorSpace     = colorSpace;

    /* Create the input buffer for raw yuv data */
   hInBuf = Buffer_create(Dmai_roundUp(inBufSize, BUFSIZEALIGN),
                           BufferGfx_getBufferAttrs(&gfxAttrs));

    /* Create the output buffer for encoded video data */
    hOutBuf = Buffer_create(Dmai_roundUp(outBufSize, BUFSIZEALIGN), &bAttrs);

    while (numFrame++ < args->numFrames) {

            readFrameUYVY(hInBuf, inFile);

            if (args->cache) {
                Memory_cacheWbInv(Buffer_getUserPtr(hInBuf), Buffer_getSize(hInBuf));
                Memory_cacheInv(Buffer_getUserPtr(hOutBuf), Buffer_getSize(hOutBuf));

            }

            BufferGfx_resetDimensions(hInBuf);

            Venc1_process(hVe1, hInBuf, hOutBuf);

            if (args->cache) {
                Memory_cacheWb(Buffer_getUserPtr(hOutBuf), Buffer_getSize(hOutBuf));
            }

            /* Write the encoded frame to the file system */
            if (Buffer_getNumBytesUsed(hOutBuf)) {
            if (fwrite(Buffer_getUserPtr(hOutBuf),
                       Buffer_getNumBytesUsed(hOutBuf), 1, outFile) != 1) {
                printf("Failed to write encoded video data to file\n");
                goto cleanup;
            }
            }
    }

    cleanup:
        /* Clean up the application */
        ....

}

================