• Not Answered

BufTab_delete return non-zero

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

15 Replies

  • 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

     

     

  • In reply to Mahantesh S Madiwalar:

    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.

     

    Best Regards,

    Philip Lee

  • In reply to philip lee46717:

    Philip,

    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.

    Regards,

    Mahantesh

      

  • In reply to Mahantesh S Madiwalar:

    Hi Mahantesh,

    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?

     

    Best Regards,

    Philip Lee

  • In reply to philip lee46717:

    Philip,

    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.

    Regards,

    Mahantesh 

     

  • In reply to Mahantesh S Madiwalar:

    Hi Mahantesh,

    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.

    Best Regards,

    Philip Lee

  • In reply to philip lee46717:

    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.

    Regards,

    Mahantesh 

  • In reply to Mahantesh S Madiwalar:

    Hi Mahantesh,

    I tried and here is the result.

    Free Buffer of size 1434240 at 0x43c11000 (0x86530000 phys)
    Memory_free fail  <- This is in the Buffer_delete
    Free 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_delete
    fail Index 0 <- cleanupBufs
    Free 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.

     

    Best Regards,

    Philip Lee

  • In reply to philip lee46717:

    Hi Philip,

    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.

    Regards,

    Mahantesh

     

  • In reply to Mahantesh S Madiwalar:

    Hi Mahantesh,

    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 0
    Free 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)
    q
    Free 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,

    Philip Lee