I don't know the details about these codecs, but if they share a sparse resource, you may need to configure them with the same groupId. Then the framework (Codec Engine + Framework Components) will try to grant resources the codecs request as 'shared' into the groupId - and will ensure the codecs don't run at the same time.
As this is DM365-based, the codecs are 'local'. Refer to the Engine.algs[].groupId section here: http://tiexpressdsp.com/index.php?title=Codec_Engine_GroupIds Chris ________________________________ From: davinci-linux-open-source-bounces+cring=ti....@linux.davincidsp.com [mailto:davinci-linux-open-source-bounces+cring=ti....@linux.davincidsp.com] On Behalf Of zuowenping Sent: Wednesday, May 13, 2009 7:28 PM To: Liu Yebo; davinci-linux-open-sou...@linux.; Vladimir Pantelic Cc: davinci-linux-open-source Subject: Re: Re: Can JPEG and MPEG4 run on DM355 simultaneity you can use the same codec engine! I am rum them simultaneity,they are ok! 2009-05-14 ________________________________ zuowenping ________________________________ 发件人: Liu Yebo 发送时间: 2009-05-14 10:15:11 收件人: [email protected]; Vladimir Pantelic 抄送: davinci-linux-open-source 主题: Re: Can JPEG and MPEG4 run on DM355 simultaneity Hi, I have made jpeg code in demos, and It seams that JPEG and MPEG4 encoder on our board works fine at the same time. Following is my JPEG code , you can add them into encode demos. /* jpeg.h*/ #include <xdc/std.h> #include <ti/sdo/ce/Engine.h> #include <ti/sdo/ce/image1/imgenc1.h> #include <rendezvous.h> #include <fifoutil.h> #include <pause.h> #include "encode.h" #ifndef __JPEG_H__ #define __JPEG_H__ int jpegEncodeAlgCreate(Engine_Handle hEngine, IMGENC1_Handle *hEncodePtr, int width, int height, int num, XDAS_Int32 *imageBufSize); void jpegencode(IMGENC1_Handle enc, unsigned char *inBuf, unsigned int inBufSize, unsigned char *encodedBuf, unsigned int * encodedBufSize); typedef struct ImageEnv { Rendezvous_Handle hRendezvousInit; Rendezvous_Handle hRendezvousCleanup; Pause_Handle hPause; FifoUtil_Obj inFifo; FifoUtil_Obj outFifo; int imageWidth; int imageHeight; int chcnt; } ImageEnv; void * imageThrFxn(void *arg); #endif /* __JPEG_H__ */ /*jpeg.c*/ /* Standard Linux headers */ #include <stdio.h> #include <fcntl.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <sys/mman.h> #include <sys/ioctl.h> #include <asm/types.h> /* Codec Engine headers */ #include <xdc/std.h> #include <ti/sdo/ce/Engine.h> #include <ti/sdo/ce/osal/Memory.h> #include "encode.h" #include "jpeg.h" #include "capture.h" #include "recorder.h" static char *jpegenc_name[MAXCHNUM] = {"jpegenc", "jpegenc:1", "jpegenc:2", "jpegenc:3"}; int jpegEncodeAlgCreate(Engine_Handle hEngine, IMGENC1_Handle *hEncodePtr, int width, int height, int num, XDAS_Int32 *imageBufSize) { IMGENC1_Params image_encParams; IMGENC1_DynamicParams image_dynParams; IMGENC1_Status image_imgStatus; IMGENC1_Handle hEncode; #define SCANS 4 #define QVALUE 73 image_encParams.size = sizeof(IMGENC1_Params); image_encParams.maxWidth = width; image_encParams.maxHeight = height; image_encParams.maxScans = SCANS; image_encParams.dataEndianness = XDM_DEFAULT; image_encParams.forceChromaFormat = XDM_YUV_422ILE; hEncode = IMGENC1_create(hEngine, jpegenc_name[num], &image_encParams); if (NULL == hEncode) { fprintf(stderr, "error: can't open codec jpegenc\n"); seterrdev(ERR_IMGENCCREAT); return FAILURE; } /* set the parameters for encoding */ image_dynParams.size = sizeof(IMGENC1_DynamicParams); image_dynParams.numAU = XDM_DEFAULT; image_dynParams.inputChromaFormat = XDM_YUV_422ILE; image_dynParams.inputWidth = width; image_dynParams.inputHeight = height; image_dynParams.captureWidth = 0; image_dynParams.generateHeader = XDM_ENCODE_AU; image_dynParams.qValue = QVALUE; image_imgStatus.size = sizeof(image_imgStatus); if (IMGENC1_control(hEncode, XDM_SETPARAMS, &image_dynParams, &image_imgStatus) == XDM_EFAIL) { fprintf(stderr, "error: could not set PARAMS: 0x%x\n", XDM_SETPARAMS); seterrdev(ERR_IMGENCCREAT); return FAILURE; } /* ask the codec for buffer sizes - these are typically conservative */ if (IMGENC1_control(hEncode, XDM_GETBUFINFO, &image_dynParams, &image_imgStatus) == XDM_EFAIL) { fprintf(stderr, "error: could not get BUFINFO: 0x%x\n", XDM_GETBUFINFO); seterrdev(ERR_IMGENCCREAT); return FAILURE; } *imageBufSize = image_imgStatus.bufInfo.minOutBufSize[0]; *hEncodePtr = hEncode; return SUCCESS; } void jpegencode(IMGENC1_Handle enc, unsigned char *inBuf, unsigned int inBufSize, unsigned char *encodedBuf, unsigned int *encodedBufSize) { Int32 status; IMGENC1_InArgs encInArgs; IMGENC1_OutArgs encOutArgs; XDM1_BufDesc inBufDesc; XDM1_BufDesc encodedBufDesc; //XDAS_Int32 numRead; /* initialize buffer descriptors that hold input and output buffers */ inBufDesc.numBufs = 1; inBufDesc.descs[0].bufSize = inBufSize; inBufDesc.descs[0].buf = inBuf; encodedBufDesc.numBufs = 1; encodedBufDesc.descs[0].bufSize = *encodedBufSize; encodedBufDesc.descs[0].buf = encodedBuf; /* the size field of Args and Params structs must be initialized */ encInArgs.size = sizeof(encInArgs); encOutArgs.size = sizeof(encOutArgs); /* perform the image (JPEG) encoding */ status = IMGENC1_process(enc, &inBufDesc, &encodedBufDesc, &encInArgs, &encOutArgs); if (status == IMGENC1_EOK) { *encodedBufSize = encOutArgs.bytesGenerated; } else { printf( "Encoder frame processing FAILED, status = 0x%lx, " "extendedError = 0x%lx\n", status, encOutArgs.extendedError); seterrdev(ERR_IMGENCPROC); } } void * imageThrFxn(void *arg) { Engine_Handle hEngine_en = NULL; ImageEnv *envp = (ImageEnv *) arg; void *status = THREAD_SUCCESS; int imgWidth = envp->imageWidth/(envp->chcnt>1?2:1); int imgHeight = envp->imageHeight/(envp->chcnt>1?2:1); int ch; CaptureBufferElement ce; /* Reset, load, and starot DSP Engine */ hEngine_en = Engine_open("image", NULL, NULL); if (hEngine_en == NULL) { ERR("Failed to open encode engine %s\n", "image"); seterrdev(ERR_ENGINEOPNE); cleanup(THREAD_FAILURE); } DBG("Encode Engine opened in jpeg thread\n"); // here for mjpeg IMGENC1_Handle image_enc = NULL; XDAS_Int8 *image_encodedBuf[MAXCHNUM] = {NULL}; XDAS_Int32 image_encodedBufSize = 0; XDAS_Int32 image_BufSize[MAXCHNUM]; if(FAILURE == jpegEncodeAlgCreate(hEngine_en, &image_enc, imgWidth, imgHeight, 0, &image_encodedBufSize)) { cleanup(THREAD_FAILURE); } printf("image_encodedBufSize: %lu\n", image_encodedBufSize); image_encodedBuf[0] = (XDAS_Int8 *)Memory_contigAlloc(image_encodedBufSize*(envp->chcnt>1?4:1), Memory_DEFAULTALIGNMENT); if (image_encodedBuf[0] == NULL) { fprintf(stderr, "image_encodedBuf[0] alloc failed!\n"); seterrdev(ERR_SYSTEM); cleanup(THREAD_FAILURE); } for(ch=1; ch<MAXCHNUM; ch++) { if(ch < envp->chcnt) image_encodedBuf[ch] = image_encodedBuf[0] + ch*image_encodedBufSize; else image_encodedBuf[ch] = NULL; } DBG("Image encoder created.\n"); /* Signal that initialization is done and wait for other threads */ Rendezvous_meet(envp->hRendezvousInit); DBG("Entering jpeg main loop.\n"); while (!gblGetQuit()) { /* Get a buffer from the capture thread */ if (FifoUtil_get(&envp->inFifo, &ce) == FIFOUTIL_FAILURE) { ERR("Failed to put buffer in output fifo\n"); seterrdev(ERR_SYSTEM); breakLoop(THREAD_FAILURE); } /* Is the capture thread flushing the pipe? */ if (ce.id == CAPTURE_FLUSH) { ERR("Receive Flush and Break fifo\n"); breakLoop(THREAD_SUCCESS); } ms_time_t nTime = ce.nTime; //it's time get yuv data time; /* Encode the captured video frame */ char *virtBuf = ce.virtBuf; //int bufSize = ce.bufSize/(envp->chcnt>1?4:1); int bufSize = imgWidth*imgHeight*SCREEN_BPP/8; for(ch=0; ch<envp->chcnt; ch++) { virtBuf = ce.virtBuf + bufSize*ch; //here for jpegenc image_BufSize[ch] = image_encodedBufSize; jpegencode(image_enc, virtBuf, bufSize, image_encodedBuf[ch], (unsigned int *)&image_BufSize[ch]); //printf(".............. jpeg size %lu\n", image_BufSize[ch]); } writeJpegData(image_encodedBuf, image_BufSize, nTime); #if 0 /* Send the buffer back to the capture thread */ if (FifoUtil_put(&envp->outFifo, &ce) == FIFOUTIL_FAILURE) { ERR("Failed to put buffer in output fifo\n"); breakLoop(THREAD_FAILURE); } #endif } DBG("Exitted jpeg main loop.\n"); cleanup: /* Make sure the other threads aren't waiting for init to complete */ Rendezvous_force(envp->hRendezvousInit); /* Make sure the other threads aren't stuck pausing */ Pause_off(envp->hPause); #if 0 /* Make sure the capture thread isn't stuck in FifoUtil_get() */ FifoUtil_put(&envp->outFifo, &cFlush); #endif /* Meet up with other threads before cleaning up */ Rendezvous_meet(envp->hRendezvousCleanup); if (image_enc) { IMGENC1_delete(image_enc); } if (image_encodedBuf[0]) { Memory_contigFree(image_encodedBuf[0], image_encodedBufSize*(envp->chcnt>1?4:1)); } if (hEngine_en) { Engine_close(hEngine_en); } return status; } ----- Original Message ----- From: "Vladimir Pantelic" <[email protected]<mailto:[email protected]>> To: <[email protected]<mailto:[email protected]>> Cc: "davinci-linux-open-source" <[email protected]<mailto:[email protected]>> Sent: Thursday, May 14, 2009 12:20 AM Subject: Re: Can JPEG and MPEG4 run on DM355 simultaneity > Steve Chen wrote: >> On Wed, 2009-05-13 at 23:14 +0800, Jammy Dane wrote: >>> Hi all, >>> >>> I want to run JPEG and MPEG4 encode on DM355 board, and I wrote a >>> demo referencing the code in ../DVSDK_1_00_30_xx/demo/encode/* and the >>> code in ../DVSDK_1_00_30_xx/examples/jpegenc/*. After I run the demo, >>> it said on the terminal: >>> /*********************************************************/ >>> r...@21:/opt/dvsdk<mailto:r...@21:/opt/dvsdk># ./encode_test_jpeg -v >>> 1.mpeg4 -r 640x576 -b 384000 >>> Encode demo started. >>> gpio control udp socket create ok! >>> the /dev/modem is opened >>> allocate modem buffer >>> fd = 17 >>> Capturing 720x576 video (cropped to 640x576) >>> ERROR: can't open engine image >>> CMEMK Error: GETPHYS: Failed to convert virtual 0x4001cbe0 to physical. >>> CMEM Error: getPhys: Failed to get physical address of 0x4001cbe0 >> >> Don't know much about applications, but 0x400xxxxx seems more like a >> physical rather than virtual address to me. Just a thought... > > no, 0x4001cbe0 is a virtual address > > I doubt you can run JPEG and MPEG4 at the same time, I think they share the > HW. > > but, in any case, run with CE_DEBGU=2 > > > _______________________________________________ > Davinci-linux-open-source mailing list > [email protected]<mailto:[email protected]> > http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source >
_______________________________________________ Davinci-linux-open-source mailing list [email protected] http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
