dav1d: Get rid of some unnecessary unwrap()s

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1055>
This commit is contained in:
Sebastian Dröge 2023-01-22 00:32:52 +02:00
parent f62d07633d
commit 037294b077

View file

@ -164,7 +164,7 @@ impl Dav1dDec {
let out_state = instance.output_state().unwrap(); let out_state = instance.output_state().unwrap();
state_guard = self.state.lock().unwrap(); state_guard = self.state.lock().unwrap();
let state = state_guard.as_mut().unwrap(); let state = state_guard.as_mut().ok_or(gst::FlowError::Flushing)?;
state.output_info = Some(out_state.info()); state.output_info = Some(out_state.info());
Ok(state_guard) Ok(state_guard)
@ -189,7 +189,7 @@ impl Dav1dDec {
frame.system_frame_number() frame.system_frame_number()
); );
let state = state_guard.as_mut().unwrap(); let state = state_guard.as_mut().ok_or(gst::FlowError::Flushing)?;
let timestamp = frame.dts().map(|ts| *ts as i64); let timestamp = frame.dts().map(|ts| *ts as i64);
let duration = frame.duration().map(|d| *d as i64); let duration = frame.duration().map(|d| *d as i64);
@ -232,7 +232,7 @@ impl Dav1dDec {
) -> Result<std::ops::ControlFlow<(), ()>, gst::FlowError> { ) -> Result<std::ops::ControlFlow<(), ()>, gst::FlowError> {
gst::trace!(CAT, imp: self, "Sending pending data to decoder"); gst::trace!(CAT, imp: self, "Sending pending data to decoder");
let state = state_guard.as_mut().unwrap(); let state = state_guard.as_mut().ok_or(gst::FlowError::Flushing)?;
match state.decoder.send_pending_data() { match state.decoder.send_pending_data() {
Ok(()) => { Ok(()) => {
@ -266,7 +266,7 @@ impl Dav1dDec {
let mut strides = vec![]; let mut strides = vec![];
let mut acc_offset: usize = 0; let mut acc_offset: usize = 0;
let state = state_guard.as_mut().unwrap(); let state = state_guard.as_mut().ok_or(gst::FlowError::Flushing)?;
let video_meta_supported = state.video_meta_supported; let video_meta_supported = state.video_meta_supported;
let info = output_state.info(); let info = output_state.info();
@ -385,7 +385,7 @@ impl Dav1dDec {
) -> Result<Option<dav1d::Picture>, gst::FlowError> { ) -> Result<Option<dav1d::Picture>, gst::FlowError> {
gst::trace!(CAT, imp: self, "Retrieving pending picture"); gst::trace!(CAT, imp: self, "Retrieving pending picture");
let state = state_guard.as_mut().unwrap(); let state = state_guard.as_mut().ok_or(gst::FlowError::Flushing)?;
match state.decoder.get_picture() { match state.decoder.get_picture() {
Ok(pic) => { Ok(pic) => {
@ -728,8 +728,7 @@ impl VideoDecoderImpl for Dav1dDec {
{ {
let mut state_guard = self.state.lock().unwrap(); let mut state_guard = self.state.lock().unwrap();
if state_guard.is_some() { if let Some(state) = &mut *state_guard {
let state = state_guard.as_mut().unwrap();
self.flush_decoder(state); self.flush_decoder(state);
} }
} }
@ -769,11 +768,12 @@ impl VideoDecoderImpl for Dav1dDec {
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
{ {
let mut state_guard = self.state.lock().unwrap(); let mut state_guard = self.state.lock().unwrap();
let state = state_guard.as_mut().unwrap(); if let Some(state) = &mut *state_guard {
state.video_meta_supported = query state.video_meta_supported = query
.find_allocation_meta::<gst_video::VideoMeta>() .find_allocation_meta::<gst_video::VideoMeta>()
.is_some(); .is_some();
} }
}
self.parent_decide_allocation(query) self.parent_decide_allocation(query)
} }