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-09 22:43:57 +0300 |
commit | c805c3bb3a7753ec868111685217515e0df6b9cb (patch) | |
tree | 64f798c4265efeaf8275aea0574c432b4210ce52 /video | |
parent | 5f70c0f5fe255b438d16d61deab65fdc9d4cacb5 (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/1086>
Diffstat (limited to 'video')
-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) |