Fix various new clippy 1.86 warnings

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2174>
This commit is contained in:
Sebastian Dröge 2025-04-05 11:18:56 +03:00
parent b916b7db55
commit d1aec1e0d2
12 changed files with 33 additions and 30 deletions

View file

@ -185,7 +185,7 @@ impl AudioDecoderImpl for LewtonDec {
let state = state_guard.as_mut().ok_or(gst::FlowError::NotNegotiated)?;
// Ignore empty packets unless we have no headers yet
if inmap.len() == 0 {
if inmap.is_empty() {
self.obj().finish_frame(None, 1)?;
if state.headerset.is_some() {

View file

@ -118,7 +118,7 @@ impl Gop {
_ => None,
});
let first_pts = iter.next();
let last_pts = iter.last();
let last_pts = iter.next_back();
gst::debug!(
CAT,
"pushing gop with start pts {} end pts {}",

View file

@ -624,9 +624,9 @@ mod tests {
(15.seconds(), 1.seconds()),
];
let items = span_tokenize_items(input, ts_duration_list).into_iter();
let mut items = span_tokenize_items(input, ts_duration_list).into_iter();
let final_ = items.last().unwrap();
let final_ = items.next_back().unwrap();
// when all spans are consumed and punctuation remains as the content,
// don't join it with a space with the last item content (Christie .)

View file

@ -777,7 +777,9 @@ impl VideoFrame {
if (frame.plane_data(2).unwrap().as_ptr() as usize)
.checked_sub(frame.plane_data(1).unwrap().as_ptr() as usize)
!= Some((frame.height() as usize + 1) / 2 * frame.plane_stride()[1] as usize)
!= Some(
(frame.height() as usize).div_ceil(2) * frame.plane_stride()[1] as usize,
)
{
return Err(TryFromVideoFrameError);
}
@ -814,7 +816,9 @@ impl VideoFrame {
if (frame.plane_data(2).unwrap().as_ptr() as usize)
.checked_sub(frame.plane_data(1).unwrap().as_ptr() as usize)
!= Some((frame.height() as usize + 1) / 2 * frame.plane_stride()[1] as usize)
!= Some(
(frame.height() as usize).div_ceil(2) * frame.plane_stride()[1] as usize,
)
{
return Err(TryFromVideoFrameError);
}

View file

@ -1063,7 +1063,7 @@ impl NdiSrcDemux {
}
gst_video::VideoFormat::Yv12 | gst_video::VideoFormat::I420 => {
let src_stride = video_frame.line_stride_or_data_size_in_bytes() as usize;
let src_stride1 = (src_stride + 1) / 2;
let src_stride1 = src_stride.div_ceil(2);
if src_stride == info.stride()[0] as usize
&& src_stride1 == info.stride()[1] as usize
@ -1088,10 +1088,11 @@ impl NdiSrcDemux {
gst_video::VideoFrame::from_buffer_writable(buffer, info).unwrap();
let line_bytes = vframe.width() as usize;
let line_bytes1 = (line_bytes + 1) / 2;
let line_bytes1 = line_bytes.div_ceil(2);
let plane_size = video_frame.yres() as usize * src_stride;
let plane_size1 = ((video_frame.yres() as usize + 1) / 2) * src_stride1;
let plane_size1 =
(video_frame.yres() as usize).div_ceil(2) * src_stride1;
if src.len() < plane_size + 2 * plane_size1 || src_stride < line_bytes {
gst::error!(

View file

@ -56,11 +56,7 @@ pub fn request_stream(srcpad: &gst::Pad, priority: i32) -> Option<u64> {
if srcpad.peer_query(&mut query) {
if let Some(s) = query.structure() {
if let Ok(stream_id) = s.get::<u64>(QUIC_STREAM_ID) {
Some(stream_id)
} else {
None
}
s.get::<u64>(QUIC_STREAM_ID).ok()
} else {
None
}

View file

@ -6,9 +6,9 @@ packets. The receiver only needs:
- `K` of any repair or RTP packets to recover all the data with 99% probability
- `K + 1` of any repair or RTP packets to recover all the data with 99.99%
probability,
probability,
- `K + 2` of any repair or RTP packets to recover all the data with 99.9999%
probability etc.
probability etc.
Relevant documents:
- [RFC6363 - Forward Error Correction (FEC) Framework](https://datatracker.ietf.org/doc/html/rfc6363)

View file

@ -628,7 +628,7 @@ impl RtpBasePay2 {
};
// Round up to a multiple of 4 bytes
extension_size = ((extension_size + 3) / 4) * 4;
extension_size = extension_size.next_multiple_of(4);
// If there are extensions, write an empty extension area of the required size. If this is
// not filled then it would be considered as padding inside the extension because of the

View file

@ -82,7 +82,7 @@ impl PayloadParser {
headers_len = r.read::<u16>().context("AU-headers-length")?;
// Up to 7 bits of padding
let headers_len_bytes = (headers_len as usize + 7) / 8;
let headers_len_bytes = (headers_len as usize).div_ceil(8);
data_offset = 2 + headers_len_bytes;
if data_offset > payload.len() {
@ -119,7 +119,7 @@ impl PayloadParser {
let aux_len = r.read::<u16>().context("auxiliary-data-size")?;
// Up to 7 bits of padding
let aux_len_bytes = (aux_len as usize + 7) / 8;
let aux_len_bytes = (aux_len as usize).div_ceil(8);
data_offset += 2 + aux_len_bytes;
if data_offset > payload.len() {

View file

@ -476,7 +476,7 @@ impl RtpBasePay2Impl for RtpMpeg4GenericPay {
state.max_header_bit_len = mode.max_header_bit_len();
state.min_mtu = rtp_types::RtpPacket::MIN_RTP_PACKET_LEN
+ HEADERS_LEN_SIZE
+ (state.max_header_bit_len + 7) / 8
+ state.max_header_bit_len.div_ceil(8)
+ 1;
state.mode = mode;
state.clock_rate = clock_rate;
@ -697,7 +697,7 @@ impl RtpMpeg4GenericPay {
headers_buf.clear();
ctx.prev_index = None;
if front.buffer.len() + (state.max_header_bit_len + 7) / 8 > max_payload_size {
if front.buffer.len() + state.max_header_bit_len.div_ceil(8) > max_payload_size {
// AU needs to be fragmented
let au = state.pending_aus.pop_front().unwrap();
let mut data = au.buffer.as_slice();
@ -741,8 +741,10 @@ impl RtpMpeg4GenericPay {
let header_bit_len = c.written() as u16;
let left = au.buffer.len() - next_frag_offset;
let bytes_in_this_packet =
std::cmp::min(left, max_payload_size - (header_bit_len as usize + 7) / 8);
let bytes_in_this_packet = std::cmp::min(
left,
max_payload_size - (header_bit_len as usize).div_ceil(8),
);
next_frag_offset += bytes_in_this_packet;
is_final = next_frag_offset >= au.buffer.len();
@ -882,7 +884,9 @@ impl RtpMpeg4GenericPay {
c.build_with(&header, &ctx).unwrap();
let header_bit_len = c.written() as u16;
if acc_size + ((headers_len + header_bit_len) as usize + 7) / 8 + front.buffer.len()
if acc_size
+ ((headers_len + header_bit_len) as usize).div_ceil(8)
+ front.buffer.len()
> max_payload_size
|| (ctx.prev_index.is_some()
&& max_ptime

View file

@ -21,10 +21,8 @@
*
* ## Parameters:
*
* - `output-dir` (string, default: "tracer_pcaps"): The directory where to save
* `.pcap` files
* - `fake-protocol` (['udp', 'none'], default: "udp"): the fake headers to add
* to packets
* - `output-dir` (string, default: "tracer_pcaps"): The directory where to save `.pcap` files
* - `fake-protocol` (['udp', 'none'], default: "udp"): the fake headers to add to packets
*
* ## Example:
*

View file

@ -448,7 +448,7 @@ fn missing_file() {
false,
);
assert_error(
events.into_iter().last().unwrap(),
events.into_iter().next_back().unwrap(),
TestMedia::missing_file(),
);
assert!(!eos);
@ -467,7 +467,7 @@ fn missing_http() {
false,
);
assert_error(
events.into_iter().last().unwrap(),
events.into_iter().next_back().unwrap(),
TestMedia::missing_http(),
);
assert!(!eos);