mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-09-02 09:43:48 +00:00
dav1ddec: Simplify LATENCY query handling
And don't keep state locked while querying upstream. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2190>
This commit is contained in:
parent
6ee63a465d
commit
0afd415bcb
1 changed files with 36 additions and 37 deletions
|
@ -1196,49 +1196,48 @@ impl VideoDecoderImpl for Dav1dDec {
|
||||||
settings.max_frame_delay
|
settings.max_frame_delay
|
||||||
};
|
};
|
||||||
|
|
||||||
match *state_guard {
|
let n_cpus_and_fps = match *state_guard {
|
||||||
Some(ref state) => match state.output_state.as_ref().map(|s| s.info()) {
|
Some(ref state) => {
|
||||||
Some(info) => {
|
let fps = state.output_state.as_ref().map(|s| s.info().fps());
|
||||||
let mut upstream_latency = gst::query::Latency::new();
|
|
||||||
|
|
||||||
if self.obj().sink_pad().peer_query(&mut upstream_latency) {
|
fps.map(|fps| (state.n_cpus, fps))
|
||||||
let (live, mut min, mut max) = upstream_latency.result();
|
}
|
||||||
// For autodetection: 1 if live, else whatever dav1d gives us
|
None => None,
|
||||||
let frame_latency: u64 = if max_frame_delay < 0 && live {
|
};
|
||||||
1
|
drop(state_guard);
|
||||||
} else {
|
|
||||||
self.estimate_frame_delay(
|
|
||||||
max_frame_delay as u32,
|
|
||||||
state.n_cpus as u32,
|
|
||||||
)
|
|
||||||
.into()
|
|
||||||
};
|
|
||||||
|
|
||||||
let fps_n = match info.fps().numer() {
|
if let Some((n_cpus, fps)) = n_cpus_and_fps {
|
||||||
0 => 30, // Pretend we're at 30fps if we don't know latency,
|
let mut upstream_latency = gst::query::Latency::new();
|
||||||
n => n,
|
|
||||||
};
|
|
||||||
|
|
||||||
let latency = frame_latency * (info.fps().denom() as u64).seconds()
|
if self.obj().sink_pad().peer_query(&mut upstream_latency) {
|
||||||
/ (fps_n as u64);
|
let (live, mut min, mut max) = upstream_latency.result();
|
||||||
|
// For autodetection: 1 if live, else whatever dav1d gives us
|
||||||
|
let frame_latency = if max_frame_delay < 0 && live {
|
||||||
|
1
|
||||||
|
} else {
|
||||||
|
self.estimate_frame_delay(max_frame_delay as u32, n_cpus as u32)
|
||||||
|
.into()
|
||||||
|
};
|
||||||
|
|
||||||
gst::debug!(CAT, imp = self, "Reporting latency of {}", latency);
|
let (fps_n, fps_d) = match (fps.numer(), fps.denom()) {
|
||||||
|
(0, _) => (30, 1), // Pretend we're at 30fps if we don't know latency
|
||||||
|
n => n,
|
||||||
|
};
|
||||||
|
|
||||||
min += latency;
|
let latency = frame_latency * (fps_d as u64).seconds() / (fps_n as u64);
|
||||||
max = max.opt_add(latency);
|
|
||||||
q.set(live, min, max);
|
|
||||||
|
|
||||||
true
|
gst::debug!(CAT, imp = self, "Reporting latency of {}", latency);
|
||||||
} else {
|
|
||||||
// peer latency query failed
|
min += latency;
|
||||||
false
|
max = max.opt_add(latency);
|
||||||
}
|
q.set(live, min, max);
|
||||||
}
|
|
||||||
// output info not available => fps unknown
|
true
|
||||||
None => false,
|
} else {
|
||||||
},
|
false
|
||||||
// no state yet
|
}
|
||||||
None => false,
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => VideoDecoderImplExt::parent_src_query(self, query),
|
_ => VideoDecoderImplExt::parent_src_query(self, query),
|
||||||
|
|
Loading…
Reference in a new issue