I've been looking at the decode demo on the DM6467T in quite some detail. I have created two vdec2 decoders in order to decode 2 video streams and switch between them until one of them has finished playing. After one of the clips has finished displaying all of its frames on screen, I wish to return to the beginning and play both the clips back from the start of each as the user specifies.
The problem is quite simply that the primer loop in videoTheFxnFHD requires 11 free buffers in order for the program to work and when the primer loop starts a second time after one of the clips has finished playing, it only has 10 free buffers to play with.
So in more detail, when the FHD decoder finishes running, it calls functions in this order to flush the frames out of the video buffer onto the display:
1) vdec2_flush(....)
2) Buffer_create(1,.....)
3) Buffer_setNumBytesUsed(1,......)
4) vdec2_process(...)*
5) handleCodecBufsFHD(......)* which calls Vdec2_getFreeBuf(....), Vdec2_getDisplayBuf(....) and calls Fifo_put(....).
6) Free up the buffers marked as used by codec.
7) Fifo_get(...) to importantly get buffers back from the display thread.
and then some other stuff to recreate the codecs for the next time that the clips are played back from the start.
*as required by the call vdec2_flush(....)
The problem I am having is that the loop in step 7) to get the buffers back relies on the numDisplayBufs variable which is updated as the function runs to reflect the number of frames that have been given to the display thread.
Something is going wrong because numDisplayBufs is set to 10 after both clips have played and we need it to be at least 11 for the next restart of the primer loop.
Even worse, a simple call of BufTab_print(hBuf) reveals there to be 4 buffers marked as in use by the display (i.e. DISPLAY_FREE is set on those 4 buffers) even though I have done the steps 1) to 7) above as you are meant to after calling vdec2_flush(....) in order to flush _all_ the frames from the display/codec.
With the original videoTheFxnFHD function something similar happens if you try to loop it although it is okay, because precisely 11 frames (instead of 10 as above) are found to be free after a clip has been played back once, and this is all you need for the primer loop.
I hope this makes sense and that someone can help me.
Many thanks,
Ralph
P.S.
-----
By the way, if I remove the call to vdec2_process, I find that now there are 11 (not 10) buffers free and so the primer loop can run fine. This is not a satisfactory solution because a) The documentation says you must call vdec2_process after calling vdec2_flush, and b) I lose frames from the end of the video clip that ends first if I do this. (The lost frames do not appear on the screen.)