Hi,
I used the H.264 decoder in the DM6467. It works fine to play the video and start and stop. However, after a few start and stop of playing clips. It cannot create the output table anymore. I actually create the input/output table for the codec and I also delete the codec everything time when I stop to play the clip. I found out that the delete of the output table, it returns a -1. Anyone have the same experience?
Best Regards,
Philip Lee
Philip,
We never seen such issue, but pls make sure that the same number of resources you are deleting, which are requested during create time.
Regards,
Mahantesh
Hi Mahantesh,
I suspect this one is related with the resize of the table and this is requested by the H.264 codecs. I found out the BufTab.c and it seems only delete the original buffers only. I tried to collapse and delete. But it still has the same problem. The table re-size is the same code as in the sample of video_decode_io.
Can you please provide the details of this resize table, is it requested by decoder through memtabs etc. You can do one experiment, book keep all the buffers/memory tables, resources etc while h264 decoder request them. And verify about the same during delete whether they are freed appropriately.
Here is the subroutine from TI.
/****************************************************************************** * resizeBufTab******************************************************************************/Int resizeBufTab(Vdec2_Handle hVd2, Int displayBufs){ BufTab_Handle hBufTab = Vdec2_getBufTab(hVd2); Int numBufs, numCodecBuffers, numExpBufs; Buffer_Handle hBuf; Int32 frameSize;
/* How many buffers can the codec keep at one time? */ numCodecBuffers = Vdec2_getMinOutBufs(hVd2); if (numCodecBuffers < 0) { printf("Failed to get buffer requirements\n"); return -1; } else if(numCodecBuffers == 0) { printf("No touch of the buffer\n"); return 0; } /* * Total number of frames needed are the number of buffers the codec * can keep at any time, plus the number of frames in the display pipe. */ numBufs = numCodecBuffers + displayBufs;
/* Get the size of output buffers needed from codec */ frameSize = Vdec2_getOutBufSize(hVd2);
/* * Get the first buffer of the BufTab to determine buffer characteristics. * All buffers in a BufTab share the same characteristics. */ hBuf = BufTab_getBuf(hBufTab, 0);
/* Do we need to resize the BufTab? */ if (numBufs > BufTab_getNumBufs(hBufTab) || frameSize < Buffer_getSize(hBuf)) {
/* Should we break the current buffers in to many smaller buffers? */ if (frameSize < Buffer_getSize(hBuf)) { /* First undo any previous chunking done */ BufTab_collapse(Vdec2_getBufTab(hVd2));
/* * Chunk the larger buffers of the BufTab in to smaller buffers * to accomodate the codec requirements. */ numExpBufs = BufTab_chunk(hBufTab, numBufs, frameSize);
if (numExpBufs < 0) {/* printf("Failed to chunk %d bufs size %d to %d bufsize %d\n", BufTab_getNumBufs(hBufTab), (Int)Buffer_getSize(hBuf), numBufs, (Int)frameSize);*/ return -1; }
/* * Did the current BufTab fit the chunked buffers, * or do we need to expand the BufTab (numExpBufs > 0)? */ if (BufTab_expand(hBufTab, numExpBufs) < 0) { printf("Failed to expand BufTab with %d buffers\n", numExpBufs); return -1;
} } else { /* Just expand the BufTab with more buffers */ if (BufTab_expand(hBufTab, numBufs - BufTab_getNumBufs(hBufTab)) < 0) { printf("Failed to expand BufTab with %d buffers\n", numCodecBuffers); return -1; } } } return numBufs;}
I also use the cat /proc/cmem to find the problem and I found out one of the output buffer from DSP (the first one) is always cannot be cleaned. How can I clean up that one?
If you glance through the above routine, there are four possibilities of returning -1, out of this function. So, do you got any error message out of these four and can you also cross check any wrong inputs to the codec can return -1, out of these four points.
I don't see any error from these 4 returns except the memory pool is not good enough for the codec's request. In my case, the expand is working but it cannot release when you release the buffer and the table.
Hi Philip,
Can you pls check from where this -1 got returned during table delete and also check whether the correct params are passed to this routine, with the wrong inputs it might stuck inside this. One more thing is that this routine is not part of H264 decoder codec, looks might belongs to top level application. Can anybody from app champs help regarding this.
I tried and here is the result.
Free Buffer of size 1434240 at 0x43c11000 (0x86530000 phys)Memory_free fail <- This is in the Buffer_deleteFree Buffer of size 1434240 at 0x43d79000 (0x863c8000 phys)Free Buffer of size 1434240 at 0x43ee1000 (0x86698000 phys)Free Buffer of size 3133440 at 0x42acd000 (0x859af000 phys)Memory_free fail <- This is in the Buffer_deletefail Index 0 <- cleanupBufsFree Buffer of size 3133440 at 0x42dde000 (0x8507c000 phys)Free Buffer of size 3133440 at 0x430ef000 (0x8538d000 phys)Free Buffer of size 3133440 at 0x43400000 (0x8569e000 phys)vdec2 outtab delete -1 Free Buffer of size 5242880 at 0x43711000 (0x84b7c000 phys)
There are 2 buffers' memory free fail. and This fail index is the first one we use for the 1st input.
Can you please take back up of the buffer information while allocating, including their indices if present, pointers, their sizes and the purpose of each buffer etc. And verify before sending for delete whether the correct buffer is going for delete operation and its been not hold by any component.
BufTab:[0] @ 0x42edc000 (0x85de7000 phys) numBytes 0 (3133440) useMask 0 (1) ref no vSize 0 Width 1920, Height 1088, LineLength 1920[1] @ 0x431ed000 (0x85ad6000 phys) numBytes 0 (3133440) useMask 0 (1) ref no vSize 0 Width 1920, Height 1088, LineLength 1920[2] @ 0x434fe000 (0x857c5000 phys) numBytes 0 (3133440) useMask 0 (1) ref no vSize 0 Width 1920, Height 1088, LineLength 1920[3] @ 0x4380f000 (0x854b4000 phys) numBytes 0 (3133440) useMask 0 (1) ref no vSize 0 Width 1920, Height 1088, LineLength 1920
This is the output buffer for the codec. It is before the resize.
resizeBufTab->>> numBufs 11 <- Expected to expand to 11 buffer frameSize 1434240 Buffer_getSize 3133440 with each size 1434240.numExpBufs 3
In this color are the buffers same as before expand. In general, it is split 1 to 2.
In this color are the buffers added for the resize table.
BufTab:[0] @ 0x42edc000 (0x85de7000 phys) numBytes 0 (1434240) useMask 0 (1) ref yes vSize 0 Width 1920, Height 1088, LineLength 1920[1] @ 0x4303a300 (0x85f45300 phys) numBytes 0 (1434240) useMask 0 (1) ref yes vSize 0 Width 1920, Height 1088, LineLength 1920[2] @ 0x431ed000 (0x85ad6000 phys) numBytes 0 (1434240) useMask 0 (1) ref yes vSize 0 Width 1920, Height 1088, LineLength 1920[3] @ 0x4334b300 (0x85c34300 phys) numBytes 0 (1434240) useMask 0 (1) ref yes vSize 0 Width 1920, Height 1088, LineLength 1920[4] @ 0x434fe000 (0x857c5000 phys) numBytes 0 (1434240) useMask 0 (1) ref yes vSize 0 Width 1920, Height 1088, LineLength 1920[5] @ 0x4365c300 (0x85923300 phys) numBytes 0 (1434240) useMask 0 (1) ref yes vSize 0 Width 1920, Height 1088, LineLength 1920[6] @ 0x4380f000 (0x854b4000 phys) numBytes 0 (1434240) useMask 0 (1) ref yes vSize 0 Width 1920, Height 1088, LineLength 1920[7] @ 0x4396d300 (0x85612300 phys) numBytes 0 (1434240) useMask 0 (1) ref yes vSize 0 Width 1920, Height 1088, LineLength 1920[8] @ 0x44320000 (0x86698000 phys) numBytes 0 (1434240) useMask 0 (1) ref no vSize 0 Width 1920, Height 1088, LineLength 1920[9] @ 0x44488000 (0x86530000 phys) numBytes 0 (1434240) useMask 0 (1) ref no vSize 0 Width 1920, Height 1088, LineLength 1920[10] @ 0x445f0000 (0x863c8000 phys) numBytes 0 (1434240) useMask 0 (1) ref no vSize 0 Width 1920, Height 1088, LineLength 1920
Failed to free.
Free Buffer of size 1434240 at 0x44320000 (0x86698000 phys)Memory_free fail Free Buffer of size 1434240 at 0x44488000 (0x86530000 phys)Memory_free fail Free Buffer of size 1434240 at 0x445f0000 (0x863c8000 phys)Free Buffer of size 3133440 at 0x42edc000 (0x85de7000 phys)Memory_free fail fail Index 0Free Buffer of size 3133440 at 0x431ed000 (0x85ad6000 phys)Free Buffer of size 3133440 at 0x434fe000 (0x857c5000 phys)Free Buffer of size 3133440 at 0x4380f000 (0x854b4000 phys)vdec2 outtab delete -1 Free Buffer of size 8388608 at 0x43b20000 (0x84cb4000 phys)qFree Buffer of size 1048576 at 0x42ce7000 (0x83b73000 phys)Free Buffer of size 329728 at 0x42c96000 (0x83c73000 phys)Free Buffer of size 16515072 at 0x41ca6000 (0x83cc4000 phys)Best Regards,
Please make sure that the output buffers for h264 decoder are calculated as below,
{ U32 actualHeight, actualWidth;
actualHeight = (pH264DCxt->height) << pH264DCxt->field_pic_flag; actualWidth = pH264DCxt->width;
BufferReq_Luma = (actualHeight + TOTAL_VER_LUMA_PAD_WIDTH)*\ (actualWidth + TOTAL_HOR_LUMA_PAD_HEIGHT);
BufferReq_Chroma = BufferReq_Luma >> 1;
/* Y frame */ status->bufInfo.minOutBufSize[0] = BufferReq_Luma; /* CB-CR frame */ status->bufInfo.minOutBufSize[1] = BufferReq_Chroma;
status->bufInfo.minNumOutBufs = 2;
status->maxNumDisplayBufs = (pH264DCxt->max_ref_frames + 1); }
Where TOTAL_VER_LUMA_PAD_WIDTH = 0 and TOTAL_HOR_LUMA_PAD_HEIGHT = 48
Based on info in your query it looks that you are trying to allocate buffers for the resolution 1920x1088, make sure that buffers with proper size are allocated. Also make sure that buffers are not overlapping.
I understand what you mean but the buffer size is actually is 1434240 and it is coming from 1280*747*3/2. The width and height doesn't change in the BufTab_expand. That's why you see the 1920 * 1088. Do you think this is a problem for the release of the buffer? Before I release the buffer table, I already use the BufTab_collapse to get back the original setting.
Yes, this might create problem.
Can you please try by allocating same size output buffers based on the ouput frame resolution.
Also can you please clarify the following,
1. What experiment you are trying to do.
2.Can you please explain the following mentioned in your previous updates,
a. This is the output buffer for the codec. It is before the resize.
b. resizeBufTab->>> numBufs 11 <- Expected to expand to 11 buffer c. frameSize 1434240 Buffer_getSize 3133440 with each size 1434240.d. numExpBufs 3
e. In this color are the buffers same as before expand. In general, it is split 1 to 2.
f. In this color are the buffers added for the resize table.
1. It is a spike for us to access the ability of the H.264 in DM6467.
2. a. It is the buftab before I called the subroutine resizeBufTab (this is in the dmai apps).
b. It is after the h264dec get the first few frames and decoded. we called Vdec2_getMinOutBufs and it returns the number of buffer expected from the H.264 es.
c. It is the frame size from the call Vdec2_getOutBufSize(vdec2) and Buffer_getSize is the return value of Buffer_getSize(hBuf).
d. It is the value after the resize and still not enough.
e. This is to resize the buffers in a)
f. It is the buffer added by the subroutine BufTab_expand.
Here is the test result
When I create the table, here is the original buffers
BufTab:[0] @ 0x42dde000 (0x86698000 phys) numBytes 0 (1440000) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280[1] @ 0x42f46000 (0x860f8000 phys) numBytes 0 (1440000) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280[2] @ 0x430ae000 (0x85f90000 phys) numBytes 0 (1440000) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280[3] @ 0x43216000 (0x86260000 phys) numBytes 0 (1440000) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280
This is the buffers after the resize
BufTab:[0] @ 0x42dde000 (0x86698000 phys) numBytes 0 (1402368) useMask 0 (1) ref yes vSize 0 Width 1280, Height 750, LineLength 1280[1] @ 0x42f46000 (0x860f8000 phys) numBytes 0 (1402368) useMask 0 (1) ref yes vSize 0 Width 1280, Height 750, LineLength 1280[2] @ 0x430ae000 (0x85f90000 phys) numBytes 0 (1402368) useMask 0 (1) ref yes vSize 0 Width 1280, Height 750, LineLength 1280[3] @ 0x43216000 (0x86260000 phys) numBytes 0 (1402368) useMask 0 (1) ref yes vSize 0 Width 1280, Height 750, LineLength 1280[4] @ 0x4387e000 (0x85888000 phys) numBytes 0 (1402368) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280[5] @ 0x439e6000 (0x85720000 phys) numBytes 0 (1402368) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280[6] @ 0x43b4e000 (0x85b58000 phys) numBytes 0 (1402368) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280[7] @ 0x43cb6000 (0x85cc0000 phys) numBytes 0 (1402368) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280[8] @ 0x43e1e000 (0x86530000 phys) numBytes 0 (1402368) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280[9] @ 0x43f86000 (0x863c8000 phys) numBytes 0 (1402368) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280[10] @ 0x440ee000 (0x85e28000 phys) numBytes 0 (1402368) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280
numBufs After:11
swidth 1280 sheight 692 spitch 1328 dwidth 1024 dheight 553
codecs_deinitialize start
This is after calling the Vdec2_flush(vdec2)
BufTab:[0] @ 0x42dde000 (0x86698000 phys) numBytes 1402368 (1402368) useMask 1 (1) ref yes vSize 0 Width 1280 (1280) Height 692 (750) Pos 32x5 LineLength 1328 (1280)[1] @ 0x42f46000 (0x860f8000 phys) numBytes 1402368 (1402368) useMask 1 (1) ref yes vSize 0 Width 1280 (1280) Height 692 (750) Pos 1240x4 LineLength 1328 (1280)[2] @ 0x430ae000 (0x85f90000 phys) numBytes 1402368 (1402368) useMask 1 (1) ref yes vSize 0 Width 1280 (1280) Height 692 (750) Pos 1120x4 LineLength 1328 (1280)[3] @ 0x43216000 (0x86260000 phys) numBytes 1402368 (1402368) useMask 1 (1) ref yes vSize 0 Width 1280 (1280) Height 692 (750) Pos 1000x4 LineLength 1328 (1280)[4] @ 0x4387e000 (0x85888000 phys) numBytes 1402368 (1402368) useMask 0 (1) ref no vSize 0 Width 1280 (1280) Height 692 (750) Pos 904x4 LineLength 1328 (1280)[5] @ 0x439e6000 (0x85720000 phys) numBytes 1402368 (1402368) useMask 0 (1) ref no vSize 0 Width 1280 (1280) Height 692 (750) Pos 688x4 LineLength 1328 (1280)[6] @ 0x43b4e000 (0x85b58000 phys) numBytes 1402368 (1402368) useMask 0 (1) ref no vSize 0 Width 1280 (1280) Height 692 (750) Pos 616x4 LineLength 1328 (1280)[7] @ 0x43cb6000 (0x85cc0000 phys) numBytes 1402368 (1402368) useMask 1 (1) ref no vSize 0 Width 1280 (1280) Height 692 (750) Pos 496x4 LineLength 1328 (1280)[8] @ 0x43e1e000 (0x86530000 phys) numBytes 1402368 (1402368) useMask 0 (1) ref no vSize 0 Width 1280 (1280) Height 692 (750) Pos 448x4 LineLength 1328 (1280)[9] @ 0x43f86000 (0x863c8000 phys) numBytes 1402368 (1402368) useMask 0 (1) ref no vSize 0 Width 1280 (1280) Height 692 (750) Pos 40x4 LineLength 1328 (1280)[10] @ 0x440ee000 (0x85e28000 phys) numBytes 0 (1402368) useMask 0 (1) ref no vSize 0 Width 1280, Height 750, LineLength 1280
This is during the call of Buffer_delete(Vdec2_getBufTab(vdec2))
Free Buffer of size 1402368 at 0x4387e000 (0x85888000 phys) <- In the call of Buffer_delete & it is just before Memory_freeMemory_free fail Free Buffer of size 1402368 at 0x439e6000 (0x85720000 phys)Memory_free fail Free Buffer of size 1402368 at 0x43b4e000 (0x85b58000 phys)Memory_free fail Free Buffer of size 1402368 at 0x43cb6000 (0x85cc0000 phys)Memory_free fail Free Buffer of size 1402368 at 0x43e1e000 (0x86530000 phys)Memory_free fail Free Buffer of size 1402368 at 0x43f86000 (0x863c8000 phys)Memory_free fail <- This is after the call of Memory_freeFree Buffer of size 1402368 at 0x440ee000 (0x85e28000 phys)Free Buffer of size 1440000 at 0x42dde000 (0x86698000 phys)Memory_free fail fail Index 0 <- This is shown in cleanupBufsFree Buffer of size 1440000 at 0x42f46000 (0x860f8000 phys)Free Buffer of size 1440000 at 0x430ae000 (0x85f90000 phys)Free Buffer of size 1440000 at 0x43216000 (0x86260000 phys)
Can you please verify by allocating those many number of resize buffers.
Can someone from apps team help further for this query.