mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-22 10:06:29 +00:00
Clean up clippy warnings and CI configuration
Put clippy overrides into the sources files instead of the CI configuration, and fix various warnings / clean up code.
This commit is contained in:
parent
626df03961
commit
96d86eaa06
21 changed files with 104 additions and 99 deletions
|
@ -208,7 +208,7 @@ clippy:
|
|||
rules:
|
||||
- when: 'always'
|
||||
script:
|
||||
- cargo clippy --locked --color=always --all --all-features --all-targets -- -A clippy::single_match -A clippy::manual_range_contains -A clippy::upper_case_acronyms -A clippy::blocks-in-if-conditions -D warnings
|
||||
- cargo clippy --locked --color=always --all --all-features --all-targets -- -D warnings
|
||||
|
||||
deny:
|
||||
extends: .img-stable
|
||||
|
|
|
@ -1049,7 +1049,7 @@ impl State {
|
|||
|
||||
// Calculate the current position in the attack window
|
||||
let cur_pos = (current_gain_reduction - self.gain_reduction[0]) / old_slope;
|
||||
assert!(cur_pos >= 0.0 && cur_pos <= 1.0);
|
||||
assert!((0.0..=1.0).contains(&cur_pos));
|
||||
self.env_cnt = ((LIMITER_ATTACK_WINDOW as f64 - 1.0) * cur_pos) as usize;
|
||||
|
||||
// Need to sustain in any case for this many samples to actually
|
||||
|
@ -1684,6 +1684,7 @@ impl AudioLoudNorm {
|
|||
pad.event_default(Some(element), event)
|
||||
}
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
fn src_query(
|
||||
&self,
|
||||
pad: &gst::Pad,
|
||||
|
@ -1911,6 +1912,7 @@ impl ElementImpl for AudioLoudNorm {
|
|||
PAD_TEMPLATES.as_ref()
|
||||
}
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
fn change_state(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(clippy::single_match)]
|
||||
|
||||
use gst::glib;
|
||||
use gst::prelude::*;
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(clippy::single_match)]
|
||||
|
||||
use gst::glib;
|
||||
use gst::prelude::*;
|
||||
|
||||
|
|
|
@ -589,8 +589,7 @@ impl Transcriber {
|
|||
};
|
||||
|
||||
let transcribe = Self::from_instance(&element);
|
||||
match transcribe.loop_fn(&element, &mut receiver) {
|
||||
Err(err) => {
|
||||
if let Err(err) = transcribe.loop_fn(&element, &mut receiver) {
|
||||
element_error!(
|
||||
&element,
|
||||
gst::StreamError::Failed,
|
||||
|
@ -598,8 +597,6 @@ impl Transcriber {
|
|||
);
|
||||
let _ = transcribe.srcpad.pause_task();
|
||||
}
|
||||
Ok(_) => (),
|
||||
};
|
||||
});
|
||||
if res.is_err() {
|
||||
return Err(loggable_error!(CAT, "Failed to start pad task"));
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
// Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
|
||||
// Boston, MA 02110-1335, USA.
|
||||
|
||||
use gst::EventView;
|
||||
#![allow(clippy::single_match)]
|
||||
|
||||
fn init() {
|
||||
use std::sync::Once;
|
||||
|
@ -83,6 +83,8 @@ fn test_parse() {
|
|||
}
|
||||
|
||||
while h.events_in_queue() > 0 {
|
||||
use gst::EventView;
|
||||
|
||||
let ev = h.pull_event().unwrap();
|
||||
|
||||
match ev.view() {
|
||||
|
|
|
@ -201,13 +201,14 @@ impl TextWrap {
|
|||
let mut bufferlist = gst::BufferList::new();
|
||||
let n_lines = std::cmp::max(self.settings.lock().unwrap().lines, 1);
|
||||
|
||||
if state
|
||||
let add_buffer = state
|
||||
.start_ts
|
||||
.zip(Some(accumulate_time))
|
||||
.map_or(false, |(start_ts, accumulate_time)| {
|
||||
start_ts + accumulate_time < pts
|
||||
})
|
||||
{
|
||||
});
|
||||
|
||||
if add_buffer {
|
||||
let mut buf =
|
||||
gst::Buffer::from_mut_slice(mem::take(&mut state.current_text).into_bytes());
|
||||
{
|
||||
|
|
|
@ -128,6 +128,7 @@ impl Default for Settings {
|
|||
}
|
||||
|
||||
impl OutputState {
|
||||
#[allow(clippy::blocks_in_if_conditions)]
|
||||
fn health(
|
||||
&self,
|
||||
settings: &Settings,
|
||||
|
@ -301,12 +302,13 @@ impl FallbackSwitch {
|
|||
deadline.display(),
|
||||
);
|
||||
|
||||
if state.last_output_time.zip(running_time).map_or(
|
||||
let is_late = state.last_output_time.zip(running_time).map_or(
|
||||
false,
|
||||
|(last_output_time, running_time)| {
|
||||
last_output_time + settings.timeout <= running_time
|
||||
},
|
||||
) {
|
||||
);
|
||||
if is_late {
|
||||
/* This buffer arrived too late - we either already switched
|
||||
* to the other pad or there's no point outputting this anyway */
|
||||
gst_debug!(
|
||||
|
@ -429,13 +431,15 @@ impl FallbackSwitch {
|
|||
};
|
||||
|
||||
if !ignore_timeout {
|
||||
// Get the next one if this one is before the timeout
|
||||
if state.last_output_time.zip(running_time).map_or(
|
||||
let timed_out = !state.last_output_time.zip(running_time).map_or(
|
||||
false,
|
||||
|(last_output_time, running_time)| {
|
||||
last_output_time + settings.timeout > running_time
|
||||
},
|
||||
) {
|
||||
);
|
||||
|
||||
// Get the next one if this one is before the timeout
|
||||
if !timed_out {
|
||||
gst_debug!(
|
||||
CAT,
|
||||
obj: backup_pad,
|
||||
|
|
|
@ -599,6 +599,7 @@ impl ToggleRecord {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::blocks_in_if_conditions)]
|
||||
fn handle_secondary_stream<T: HandleData>(
|
||||
&self,
|
||||
element: &super::ToggleRecord,
|
||||
|
|
|
@ -177,9 +177,11 @@ impl CCDetect {
|
|||
);
|
||||
|
||||
if cc_packet.cc608 != settings.cc608 {
|
||||
if state.last_cc608_change.map_or(true, |last_cc608_change| {
|
||||
let changed = state.last_cc608_change.map_or(true, |last_cc608_change| {
|
||||
ts > last_cc608_change + settings.window
|
||||
}) {
|
||||
});
|
||||
|
||||
if changed {
|
||||
settings.cc608 = cc_packet.cc608;
|
||||
state.last_cc608_change = Some(ts);
|
||||
notify_cc608 = true;
|
||||
|
@ -189,9 +191,10 @@ impl CCDetect {
|
|||
}
|
||||
|
||||
if cc_packet.cc708 != settings.cc708 {
|
||||
if state.last_cc708_change.map_or(true, |last_cc708_change| {
|
||||
let changed = state.last_cc708_change.map_or(true, |last_cc708_change| {
|
||||
ts > last_cc708_change + settings.window
|
||||
}) {
|
||||
});
|
||||
if changed {
|
||||
settings.cc708 = cc_packet.cc708;
|
||||
state.last_cc708_change = Some(ts);
|
||||
notify_cc708 = true;
|
||||
|
|
|
@ -353,11 +353,10 @@ impl Cea608Overlay {
|
|||
}
|
||||
|
||||
if Some(cc_type) == state.selected_field {
|
||||
match state
|
||||
if let Ok(Status::Ready) = state
|
||||
.caption_frame
|
||||
.decode((triple[1] as u16) << 8 | triple[2] as u16, 0.0)
|
||||
{
|
||||
Ok(Status::Ready) => {
|
||||
let text = match state.caption_frame.to_text(true) {
|
||||
Ok(text) => text,
|
||||
Err(_) => {
|
||||
|
@ -372,8 +371,6 @@ impl Cea608Overlay {
|
|||
|
||||
self.overlay_text(element, &text, state);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
|
@ -406,27 +403,20 @@ impl Cea608Overlay {
|
|||
}
|
||||
|
||||
if Some(cc_type) == state.selected_field {
|
||||
match state
|
||||
if let Ok(Status::Ready) = state
|
||||
.caption_frame
|
||||
.decode((triple[1] as u16) << 8 | triple[2] as u16, 0.0)
|
||||
{
|
||||
Ok(Status::Ready) => {
|
||||
let text = match state.caption_frame.to_text(true) {
|
||||
Ok(text) => text,
|
||||
Err(_) => {
|
||||
gst_error!(
|
||||
CAT,
|
||||
obj: pad,
|
||||
"Failed to convert caption frame to text"
|
||||
);
|
||||
gst_error!(CAT, obj: pad, "Failed to convert caption frame to text");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
self.overlay_text(element, &text, state);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -468,11 +458,10 @@ impl Cea608Overlay {
|
|||
let data = meta.data();
|
||||
assert!(data.len() % 2 == 0);
|
||||
for i in 0..data.len() / 2 {
|
||||
match state
|
||||
if let Ok(Status::Ready) = state
|
||||
.caption_frame
|
||||
.decode((data[i * 2] as u16) << 8 | data[i * 2 + 1] as u16, 0.0)
|
||||
{
|
||||
Ok(Status::Ready) => {
|
||||
let text = match state.caption_frame.to_text(true) {
|
||||
Ok(text) => text,
|
||||
Err(_) => {
|
||||
|
@ -487,8 +476,6 @@ impl Cea608Overlay {
|
|||
|
||||
self.overlay_text(element, &text, &mut state);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -503,12 +490,10 @@ impl Cea608Overlay {
|
|||
state.video_info.as_ref().unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
match composition.blend(&mut frame) {
|
||||
Err(_) => {
|
||||
|
||||
if composition.blend(&mut frame).is_err() {
|
||||
gst_error!(CAT, obj: pad, "Failed to blend composition");
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
drop(state);
|
||||
|
|
|
@ -547,10 +547,9 @@ impl State {
|
|||
ret
|
||||
}
|
||||
Cea608Mode::PopOn => {
|
||||
#[allow(clippy::map_entry)]
|
||||
if !self.rows.contains_key(&self.cursor.row) {
|
||||
self.rows.insert(self.cursor.row, Row::new(self.cursor.row));
|
||||
}
|
||||
let row = self.cursor.row;
|
||||
self.rows.entry(row).or_insert_with(|| Row::new(row));
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@ -930,6 +929,7 @@ impl ElementImpl for Cea608ToJson {
|
|||
PAD_TEMPLATES.as_ref()
|
||||
}
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
fn change_state(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
|
|
|
@ -482,6 +482,7 @@ impl ElementImpl for Cea608ToTt {
|
|||
PAD_TEMPLATES.as_ref()
|
||||
}
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
fn change_state(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
|
|
|
@ -25,7 +25,7 @@ pub enum MccLine<'a> {
|
|||
Header,
|
||||
Comment,
|
||||
Empty,
|
||||
UUID(&'a [u8]),
|
||||
Uuid(&'a [u8]),
|
||||
Metadata(&'a [u8], &'a [u8]),
|
||||
TimeCodeRate(u8, bool),
|
||||
Caption(TimeCode, Option<Vec<u8>>),
|
||||
|
@ -96,7 +96,7 @@ fn uuid(s: &[u8]) -> IResult<&[u8], MccLine> {
|
|||
take_while1(|b| b != b'\n' && b != b'\r'),
|
||||
end_of_line,
|
||||
)),
|
||||
|(_, uuid, _)| MccLine::UUID(uuid),
|
||||
|(_, uuid, _)| MccLine::Uuid(uuid),
|
||||
),
|
||||
)(s)
|
||||
}
|
||||
|
@ -238,9 +238,9 @@ fn mcc_payload_item(s: &[u8]) -> IResult<&[u8], Either<u8, &'static [u8]>> {
|
|||
map(tag("Z"), |_| Either::Right([0x00].as_ref())),
|
||||
map(take_while_m_n(2, 2, is_hex_digit), |s: &[u8]| {
|
||||
let hex_to_u8 = |v: u8| match v {
|
||||
v if v >= b'0' && v <= b'9' => v - b'0',
|
||||
v if v >= b'A' && v <= b'F' => 10 + v - b'A',
|
||||
v if v >= b'a' && v <= b'f' => 10 + v - b'a',
|
||||
v if (b'0'..=b'9').contains(&v) => v - b'0',
|
||||
v if (b'A'..=b'F').contains(&v) => 10 + v - b'A',
|
||||
v if (b'a'..=b'f').contains(&v) => 10 + v - b'a',
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let val = (hex_to_u8(s[0]) << 4) | hex_to_u8(s[1]);
|
||||
|
@ -472,17 +472,17 @@ mod tests {
|
|||
fn test_uuid() {
|
||||
assert_eq!(
|
||||
uuid(b"UUID=1234".as_ref()),
|
||||
Ok((b"".as_ref(), MccLine::UUID(b"1234".as_ref())))
|
||||
Ok((b"".as_ref(), MccLine::Uuid(b"1234".as_ref())))
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
uuid(b"UUID=1234\n".as_ref()),
|
||||
Ok((b"".as_ref(), MccLine::UUID(b"1234".as_ref())))
|
||||
Ok((b"".as_ref(), MccLine::Uuid(b"1234".as_ref())))
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
uuid(b"UUID=1234\r\n".as_ref()),
|
||||
Ok((b"".as_ref(), MccLine::UUID(b"1234".as_ref())))
|
||||
Ok((b"".as_ref(), MccLine::Uuid(b"1234".as_ref())))
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
|
@ -697,10 +697,10 @@ mod tests {
|
|||
match line_cnt {
|
||||
0 => assert_eq!(res, MccLine::Header),
|
||||
1 | 37 | 43 => assert_eq!(res, MccLine::Empty),
|
||||
x if x >= 2 && x <= 36 => assert_eq!(res, MccLine::Comment),
|
||||
x if (2..=36).contains(&x) => assert_eq!(res, MccLine::Comment),
|
||||
38 => assert_eq!(
|
||||
res,
|
||||
MccLine::UUID(b"CA8BC94D-9931-4EEE-812F-2D68FA74F287".as_ref())
|
||||
MccLine::Uuid(b"CA8BC94D-9931-4EEE-812F-2D68FA74F287".as_ref())
|
||||
),
|
||||
39 => assert_eq!(
|
||||
res,
|
||||
|
|
|
@ -78,9 +78,9 @@ fn scc_payload_item(s: &[u8]) -> IResult<&[u8], (u8, u8)> {
|
|||
"invalid SCC payload item",
|
||||
map(take_while_m_n(4, 4, is_hex_digit), |s: &[u8]| {
|
||||
let hex_to_u8 = |v: u8| match v {
|
||||
v if v >= b'0' && v <= b'9' => v - b'0',
|
||||
v if v >= b'A' && v <= b'F' => 10 + v - b'A',
|
||||
v if v >= b'a' && v <= b'f' => 10 + v - b'a',
|
||||
v if (b'0'..=b'9').contains(&v) => v - b'0',
|
||||
v if (b'A'..=b'F').contains(&v) => 10 + v - b'A',
|
||||
v if (b'a'..=b'f').contains(&v) => 10 + v - b'a',
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
|
|
|
@ -398,6 +398,7 @@ impl TranscriberBin {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
fn src_query(
|
||||
&self,
|
||||
pad: &gst::Pad,
|
||||
|
@ -474,6 +475,7 @@ impl TranscriberBin {
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
fn video_sink_event(
|
||||
&self,
|
||||
pad: &gst::Pad,
|
||||
|
@ -815,6 +817,7 @@ impl ElementImpl for TranscriberBin {
|
|||
PAD_TEMPLATES.as_ref()
|
||||
}
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
fn change_state(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
|
|
|
@ -1217,6 +1217,7 @@ impl ElementImpl for TtToCea608 {
|
|||
PAD_TEMPLATES.as_ref()
|
||||
}
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
fn change_state(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
// Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
|
||||
// Boston, MA 02110-1335, USA.
|
||||
|
||||
#![allow(clippy::single_match)]
|
||||
|
||||
use gst::prelude::*;
|
||||
use gst::EventView;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
// Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
|
||||
// Boston, MA 02110-1335, USA.
|
||||
|
||||
#![allow(clippy::single_match)]
|
||||
|
||||
use gst::prelude::*;
|
||||
use gst::EventView;
|
||||
use gst_video::{ValidVideoTimeCode, VideoTimeCode};
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
// Reference used for implementation: https://en.wikipedia.org/wiki/HSL_and_HSV
|
||||
|
||||
#![allow(unstable_name_collisions)]
|
||||
|
||||
// Since the standard 'clamp' feature is still considered unstable, we provide
|
||||
// a subsititute implementaion here so we can still build with the stable toolchain.
|
||||
// Source: https://github.com/rust-lang/rust/issues/44095#issuecomment-624879262
|
||||
|
|
|
@ -151,7 +151,6 @@ pub struct WebPDec {
|
|||
}
|
||||
|
||||
impl WebPDec {
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
fn sink_chain(
|
||||
&self,
|
||||
pad: &gst::Pad,
|
||||
|
|
Loading…
Reference in a new issue