Hello,
I am using video_copy example of Code Engine (code_engine_2_10_02). I am porting my h.264 algorithm
on davinci. So, I modified /codec/videnc_copy/ folder with my xDM complient codec algorithm. Then I
used servers/video_copy/ folder to build server for evm6467(video_copy.x64p).
Now I am modifing /apps/video_copy/dualcpu/evmDM6467/ example to use this modified server.
I am expecting that VIDENC_process() should give me lenth of the coded packet in following argument
"encoderOutArgs.bytesGenerated". In Codec side (DSP side), I am updating "outArgs->bytesGenerated"
in VIDENCCOPY_TI_process() function where IVIDENC_OutArgs *outArgs is one of the argument of
VIDENCCOPY_TI_process().
I am getting encoderOutArgs.bytesGenerated as 0. Why I am not getting exact bytesGenerated figures?
I am shaing some code bellow :
/codecs/videnc_copy/videnc_copy.c
XDAS_Int32 VIDENCCOPY_TI_process(IVIDENC_Handle h, XDM_BufDesc *inBufs,
XDM_BufDesc *outBufs, IVIDENC_InArgs *inArgs, IVIDENC_OutArgs *outArgs)
{
XDAS_Int32 curBuf;
XDAS_UInt32 minSamples;
VIDENC_Obj *H264Enc = (Void *) h;
XDAS_Int32 numInBytes = 0;
XDAS_Int32 nSize = 0;
for (curBuf = 0; (curBuf < inBufs->numBufs) &&
(curBuf < outBufs->numBufs); curBuf++) {
/* there's an available in and out buffer, how many samples? */
minSamples = inBufs->bufSizes[curBuf] < outBufs->bufSizes[curBuf] ?
inBufs->bufSizes[curBuf] : outBufs->bufSizes[curBuf];
GT_3trace(curTrace, GT_2CLASS, "VIDENCCOPY_TI_process> "
"memcpy (0x%x, 0x%x, %d)\n",
outBufs->bufs[curBuf], inBufs->bufs[curBuf], minSamples);
/* process the data: read input, produce output */
//memcpy(outBufs->bufs[curBuf], inBufs->bufs[curBuf], minSamples);
nSize = (H264Enc->tHdl->width * H264Enc->tHdl->height) + ((H264Enc->tHdl->width >> 1) * H264Enc->tHdl->height);
nSize = my_encode(H264Enc->handle,
inBufs->bufs[0],
outBufs->bufs[0],
nSize);
outArgs->bytesGenerated += nSize; /* I am updating bytesGenerated at this place on DSP/Server side*/
}
/* Fill out the rest of the outArgs struct */
outArgs->extendedError = 0;
outArgs->encodedFrameType = 0; /* TODO */
outArgs->inputFrameSkip = IVIDEO_FRAME_ENCODED;
outArgs->reconBufs.numBufs = 0; /* important: indicate no reconBufs */
return (IVIDENC_EOK);
}
/apps/video_copy/dualcpu/evmDM6467
int ceapp_encodeBuf(char *inBuf, int inBufSize,
char *encodedBuf, int *nOutBufLen)
{
/* declare codec I/O buffer descriptors for the codec's process() func. */
XDM_BufDesc inBufDesc;
XDM_BufDesc encodedBufDesc;
/* declare in and out argument descriptors for process() */
VIDENC_InArgs encoderInArgs;
VIDENC_OutArgs encoderOutArgs;
/* declare arrays describing I/O buffers and their sizes */
XDAS_Int8* inBufs [ XDM_MAX_IO_BUFFERS ];
XDAS_Int32 inBufSizes [ XDM_MAX_IO_BUFFERS ];
XDAS_Int8* encodedBufs [ XDM_MAX_IO_BUFFERS ];
XDAS_Int32 encodedBufSizes[ XDM_MAX_IO_BUFFERS ];
Int32 status;
int retval = -1; /* nonzero means failure */
int encodedBufSize = *nOutBufLen;
/* define the arrays describing I/O buffers and their sizes */
inBufs[0] = inBuf;
inBufSizes[0] = inBufSize;
encodedBufs[0] = encodedBuf;
encodedBufSizes[0] = encodedBufSize;
/* define I/O buffer descriptors using lengths and addrs of arrays above */
inBufDesc.numBufs = 1;
inBufDesc.bufs = inBufs;
inBufDesc.bufSizes = inBufSizes;
encodedBufDesc.numBufs = 1;
encodedBufDesc.bufs = encodedBufs;
encodedBufDesc.bufSizes = encodedBufSizes;
/* fill in the input arguments structure; we have nothing for this case */
encoderInArgs.size = sizeof(encoderInArgs);
encoderOutArgs.size = sizeof(encoderOutArgs);
/* encode the frame, pass addrs of the structures we populated above */
status = VIDENC_process(encHandle, &inBufDesc, &encodedBufDesc,
&encoderInArgs, &encoderOutArgs);
if (status == VIDENC_EOK) {
retval = 0;
/****************************************************************/
/*********** Here I want exact o/p buf length.*******************/
*nOutBufLen = encoderOutArgs.bytesGenerated;
/****************************************************************/
printf("DEBUG : O/P Packet Length = %d\n",*nOutBufLen );
}
else {
printf("CEapp-> VIDENC_process() failed, status = 0x%lx, "
"extendedError = 0x%lx\n", status, encoderOutArgs.extendedError);
}
return retval;
}
How I can check whether DSP server is getting correct i/p argumets or not?
[I have CCS 3.1 version & codec is checked on it after making it xDM complient]
My 2nd quetion is do I need to fill output buffer decriptor (XDM_BufDesc.bufSizes) before calling VIDENC_process() ? Because if I keep that value as zero
I am getting following error
@0x000cae00:[T:0x00004000] OM - Memory_getBufferPhysicalAddress> invalid buffer size provided (0)
CEapp-> VIDENC_process() failed, status = 0xfffffffe, extendedError = 0xbefffd70
Please, let me know whether I am doing any mistake while passing arguments / expecting modified arguments from DSP server.
Thank you,
Prafull Barpute