Idea for how to flushing out a number of buffered frames when B-frame is present
When B-frame is present or even if B-frame is not actually present (because it is prior unknown until it actually meets B-frame) for the cases of main and high profile, so the decoder API layer must have to buffer some video frames in order to do frame re-ordering into display order.
I have implemented the frame re-ordering mechanism for display order in decoder API. By enabling the re-ordering mechanism, the test cases in the build system for main and high profile (even no actual b-frame present) fail because last frames in buffer are not flushed out.
I propose to add "DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER" to query for number of frames remaining in buffer with the following code:
if (DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER == eOptID) { if (m_pDecContext->pSps && m_pDecContext->pSps->uiProfileIdc != 66) { * ((int*)pOption) = m_iNumOfPicts > 0 ? m_iNumOfPicts : 0; } return cmResultSuccess; }
Then in client side, adding:
// Get pending last frames int32_t num_of_frames_in_buffer = 0; decoder_->GetOption (DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER, &num_of_frames_in_buffer); for (int32_t i = 0; i < num_of_frames_in_buffer; ++i) { DecodeFrame (NULL, 0, cbk); }
My question is that: Is this kind of awkward to trying to flushing out last frames? I am looking for your better idea for flushing out last frames. So any of your idea is welcome.
Thanks.
-Xiaotian
I have added the function "FlushFrame", it worked. This issue is resolved.