TI的工程师你们好。
我现在使用DM3730平台,DVSDK4_03及其内的codec engine2-26-02-11,codecs使用videnc_copy例程,server使用all_codecs例程,apps使用video_copy例程。
现在我每次传给DSP的inbuf数据大小为600K,我在videnc_process函数和viddec_process函数外加了个for循环,次数为20,代码如下。
for (n = 0; n < 20; n++){
// for (n = 0; fread(inBuf, IFRAMESIZE, 1, in) == 1; n++) {
#ifdef CACHE_ENABLED
#ifdef xdc_target__isaCompatible_64P
/*
* fread() on this processor is implemented using CCS's stdio, which
* is known to write into the cache, not physical memory. To meet
* xDAIS DMA Rule 7, we must writeback the cache into physical
* memory. Also, per DMA Rule 7, we must invalidate the buffer's
* cache before providing it to any xDAIS algorithm.
*/
Memory_cacheWbInv(inBuf, IFRAMESIZE);
#else
#error Unvalidated config - add appropriate fread-related cache maintenance
#endif
/* Per DMA Rule 7, our output buffer cache lines must be cleaned */
Memory_cacheInv(encodedBuf, EFRAMESIZE);
#endif
get_frame(fd_video, &q_buffers[0].start, &len, &index_Fra, q_buffers);
memcpy(inBuf, q_buffers[0].start, NSAMPLES);
GT_1trace(curMask, GT_1CLASS, "App-> Processing frame %d...\n", n);
status = VIDENC_process(enc, &inBufDesc, &encodedBufDesc, &encInArgs,
&encOutArgs);
printf("yuv turn to rgb");
MYyuv_2_rgb888(encodedBuf, frame_buffer);
for(y = 0; y < 480; y++){
for (x = 0; x < 640; x++) {
*(fbmem + y * fb_width * 4 + x * 4) = (unsigned char) frame_buffer[y * 1920 + x * 3 + 0];
*(fbmem + y * fb_width * 4 + x * 4 + 1) = (unsigned char) frame_buffer[y * 1920 + x * 3 + 1];
*(fbmem + y * fb_width * 4 + x * 4 + 2) = (unsigned char) frame_buffer[y * 1920 + x * 3 + 2];
*(fbmem + y * fb_width * 4 + x * 4 + 3) = 0x00;
}
}
/* encode the frame */
free_frame(fd_video, index_Fra);
GT_4trace(curMask, GT_2CLASS,
"App-> Encoder frame %d process returned - 0x%x, encoderBuf address 0x%x ,encoderBuf address 0x%x)\n",
n, status, encodedBufDesc.bufs, *encodedBufDesc.bufs);
#ifdef CACHE_ENABLED
/* Writeback this outBuf from the previous call. Also, as encodedBuf
* is an inBuf to the next process call, we must invalidate it also, to
* clean buffer lines.
*/
Memory_cacheWbInv(encodedBuf, EFRAMESIZE);
/* Per DMA Rule 7, our output buffer cache lines must be cleaned */
Memory_cacheInv(outBuf, OFRAMESIZE);
#endif
if (status != VIDENC_EOK) {
GT_3trace(curMask, GT_7CLASS,
"App-> Encoder frame %d processing FAILED, status = 0x%x, "
"extendedError = 0x%x\n", n, status, encOutArgs.extendedError);
// break;
}
/* decode the frame */
status = VIDDEC_process(dec, &encodedBufDesc, &outBufDesc, &decInArgs,
&decOutArgs);
GT_2trace(curMask, GT_2CLASS,
"App-> Decoder frame %d process returned - 0x%x)\n",
n, status);
if (status != VIDDEC_EOK) {
GT_3trace(curMask, GT_7CLASS,
"App-> Decoder frame %d processing FAILED, status = 0x%x, "
"extendedError = 0x%x\n", n, status, decOutArgs.extendedError);
// break;
}
}
/*
* unmap framebuffer's shared memory
*/
fb_munmap(fbmem, screensize);
/*
* close framebuffer device
*/
fb_close(fbdev);
close_v4l2(fd_video);
//}
#ifdef CACHE_ENABLED
/* Writeback the outBuf. */
Memory_cacheWb(outBuf, OFRAMESIZE);
#endif
/* write to file */
fwrite(dst[0], OFRAMESIZE, 1, out);
GT_1trace(curMask, GT_1CLASS, "%d frames encoded/decoded\n", n);
}
以上的代码中,我将摄像头获取到的数据放到q_buffers里面。再用memcy函数复制到inbuf里去,然后将inbuf传入videnc_process函数进行单幅图像的处理,处理后的数据encodecbuf,我将其转成rgb后显示到显示屏上。
现在我的问题是,该函数只能运行3次或4次,每次处理显示屏都能够正常显示。串口输出完如下信息就卡住了
@0x0010cd31:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Application started.
@0x001259ae:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Processing frame 0...
yuv turn to rgb@0x0016ff27:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Encoder frame 0 process returned - 0x0, encoderBuf address 0xbeec2aa4 ,encoderBuf address 0x40de6000)
@0x00171647:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Decoder frame 0 process returned - 0x0)
@0x001742be:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Processing frame 1...
yuv turn to rgb@0x001bdb38:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Encoder frame 1 process returned - 0x0, encoderBuf address 0xbeec2aa4 ,encoderBuf address 0x40de6000)
@0x001bf277:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Decoder frame 1 process returned - 0x0)
@0x001c3d54:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Processing frame 2...
yuv turn to rgb@0x0020be34:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Encoder frame 2 process returned - 0x0, encoderBuf address 0xbeec2aa4 ,encoderBuf address 0x40de6000)
@0x0020d38a:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Decoder frame 2 process returned - 0x0)
@0x002100b8:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Processing frame 3...
yuv turn to rgb@0x00258067:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Encoder frame 3 process returned - 0x0, encoderBuf address 0xbeec2aa4 ,encoderBuf address 0x40de6000)
@0x0025959f:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Decoder frame 3 process returned - 0x0)
@0x0025d4ec:[T:0x4001d2f0] ti.sdo.ce.examples.apps.video_copy - App-> Processing frame 4...
按照该例程最原始的算法,好像是每次传1k的数据给DSP,然后DSP再返回给ARM,在这个过程中inbuf和encodecbuf这两个指针所指向的地址是不是每次都增加1K的呢? 按照我现在对于这个问题的理解,是inbuf每次运行都增加了600k,这样运行多次,使得内存空间被inbuf占用太多导致内存不够无法运行。
而现在,我的算法只能运行4次,大概是处理了2.4M的数据量,然后程序就运行不下去了,请问是什么原因?如何解决。如何达到我的目的---即在多次运算中,每次传给DSP 600k的数据,处理完ARM端显示在显示屏上。