diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2023-02-08 12:24:27 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2023-02-08 12:26:25 +0300 |
commit | 44405e0cd7a68da89c65ee2b2c76be8883b18f35 (patch) | |
tree | b10faf42a44fbec377b2f0b18534440a84ba5c98 /video/dav1d | |
parent | 0ed74d0aa45c7e0160acc47661cf20c844101298 (diff) |
dav1ddec: Make sure to call `get_picture()` twice in a row when draining
The first time might return `EAGAIN` if there are pending frames but
there is no decoded frame available yet. The second time it will
actually wait for frames to become available and only start returning
`EAGAIN` again once no more frames are left.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1080>
Diffstat (limited to 'video/dav1d')
-rw-r--r-- | video/dav1d/src/dav1ddec/imp.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/video/dav1d/src/dav1ddec/imp.rs b/video/dav1d/src/dav1ddec/imp.rs index 62ed91966..b65e5a5b6 100644 --- a/video/dav1d/src/dav1ddec/imp.rs +++ b/video/dav1d/src/dav1ddec/imp.rs @@ -430,11 +430,23 @@ impl Dav1dDec { mut state_guard: MutexGuard<'s, Option<State>>, drain: bool, ) -> Result<MutexGuard<Option<State>>, gst::FlowError> { - while let Some(pic) = self.pending_picture(&mut state_guard)? { - state_guard = self.handle_picture(state_guard, &pic)?; - if !drain { + // dav1d wants to have get_picture() called a second time after it return EAGAIN to + // actually drain all pending pictures. + let mut call_twice = drain; + + loop { + while let Some(pic) = self.pending_picture(&mut state_guard)? { + state_guard = self.handle_picture(state_guard, &pic)?; + call_twice = false; + if !drain { + break; + } + } + + if !call_twice { break; } + call_twice = false; } Ok(state_guard) |