openh264 icon indicating copy to clipboard operation
openh264 copied to clipboard

Idea for how to flushing out a number of buffered frames when B-frame is present

Open xiaotianshicomcast opened this issue 8 years ago • 1 comments

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

xiaotianshicomcast avatar Jul 03 '18 17:07 xiaotianshicomcast

I have added the function "FlushFrame", it worked. This issue is resolved.

xiaotianshicomcast avatar Jul 06 '18 18:07 xiaotianshicomcast