diff options
author | Zaggy1024 <zaggy1024@gmail.com> | 2022-11-03 19:18:38 -0500 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-11-12 10:17:27 -0700 |
commit | 72ed286e164093b113f08a598e2a9c97195a123e (patch) | |
tree | f8419c3bf9142c435ee0ffb3b4117d1cbd5a6355 /Userland/Libraries/LibVideo/PlaybackManager.cpp | |
parent | 993385f18d4f467d3122cc5a5a41bbea3fb1215f (diff) | |
download | serenity-72ed286e164093b113f08a598e2a9c97195a123e.zip |
LibVideo: Allow the VP9 decoder to queue multiple frames
Frames will now be queued for retrieval by the user of the decoder.
When the end of the current queue is reached, a DecoderError of
category NeedsMoreInput will be emitted, allowing the caller to react
by displaying what was previously retrieved for sending more samples.
Diffstat (limited to 'Userland/Libraries/LibVideo/PlaybackManager.cpp')
-rw-r--r-- | Userland/Libraries/LibVideo/PlaybackManager.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp index 7d6ca6adc0..c6579a8aa0 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.cpp +++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp @@ -195,6 +195,11 @@ void PlaybackManager::restart_playback() on_decoder_error(result.release_error()); } +void PlaybackManager::post_decoder_error(DecoderError error) +{ + m_main_loop.post_event(*this, make<DecoderErrorEvent>(error)); +} + bool PlaybackManager::decode_and_queue_one_sample() { if (m_frame_queue->size() >= FRAME_BUFFER_COUNT) @@ -215,9 +220,25 @@ bool PlaybackManager::decode_and_queue_one_sample() }) auto frame_sample = TRY_OR_ENQUEUE_ERROR(m_demuxer->get_next_video_sample_for_track(m_selected_video_track)); + OwnPtr<VideoFrame> decoded_frame = nullptr; + while (!decoded_frame) { + TRY_OR_ENQUEUE_ERROR(m_decoder->receive_sample(frame_sample->data())); + + while (true) { + auto frame_result = m_decoder->get_decoded_frame(); + + if (frame_result.is_error()) { + if (frame_result.error().category() == DecoderErrorCategory::NeedsMoreInput) + break; - TRY_OR_ENQUEUE_ERROR(m_decoder->receive_sample(frame_sample->data())); - auto decoded_frame = TRY_OR_ENQUEUE_ERROR(m_decoder->get_decoded_frame()); + post_decoder_error(frame_result.release_error()); + return false; + } + + decoded_frame = frame_result.release_value(); + VERIFY(decoded_frame); + } + } auto& cicp = decoded_frame->cicp(); cicp.adopt_specified_values(frame_sample->container_cicp()); |