Skip to content

Commit befb70e

Browse files
HITGIFrainliu
authored andcommitted
fix clippy
1 parent 83e6926 commit befb70e

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

rtp/src/codecs/av1/av1_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::error::Result;
66

77
use super::*;
88

9-
const OBU_EXTENSION_S1T1: u8 = 0b001_01_000;
9+
const OBU_EXTENSION_S1T1: u8 = 0b0010_1000;
1010
const NEW_CODED_VIDEO_SEQUENCE_BIT: u8 = 0b00_00_1000;
1111

1212
struct Av1Obu {
@@ -395,8 +395,8 @@ fn test_split_single_obu_into_many_packets() -> Result<()> {
395395
ret.extend(vec![27; 98]);
396396
ret
397397
});
398-
for i in 1..12 {
399-
assert_eq!(result[i], {
398+
for packet in result.iter().take(12).skip(1) {
399+
assert_eq!(packet.to_vec(), {
400400
let mut ret = vec![
401401
0b11_01_0000, // aggregation header
402402
];

rtp/src/codecs/av1/obu.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use crate::codecs::av1::leb128::read_leb128;
77
use crate::error::Result;
88
use crate::Error::{ErrPayloadTooSmallForObuExtensionHeader, ErrPayloadTooSmallForObuPayloadSize};
99

10-
pub const OBU_HAS_EXTENSION_BIT: u8 = 0b0_0000_100;
11-
pub const OBU_HAS_SIZE_BIT: u8 = 0b0_0000_010;
12-
pub const OBU_TYPE_MASK: u8 = 0b0_1111_000;
10+
pub const OBU_HAS_EXTENSION_BIT: u8 = 0b0000_0100;
11+
pub const OBU_HAS_SIZE_BIT: u8 = 0b0000_0010;
12+
pub const OBU_TYPE_MASK: u8 = 0b0111_1000;
1313

1414
pub const OBU_TYPE_SEQUENCE_HEADER: u8 = 1;
1515
pub const OBU_TYPE_TEMPORAL_DELIMITER: u8 = 2;

rtp/src/codecs/av1/packetizer.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,7 @@ pub fn packetize(obus: &Vec<Obu>, mtu: usize) -> Vec<PacketMetadata> {
176176

177177
/// Returns the aggregation header for the packet.
178178
/// Reference: https://aomediacodec.github.io/av1-rtp-spec/#44-av1-aggregation-header
179-
pub fn get_aggregation_header(
180-
obus: &Vec<Obu>,
181-
packets: &Vec<PacketMetadata>,
182-
packet_index: usize,
183-
) -> u8 {
179+
pub fn get_aggregation_header(obus: &[Obu], packets: &[PacketMetadata], packet_index: usize) -> u8 {
184180
let packet = &packets[packet_index];
185181
let mut header: u8 = 0;
186182

@@ -233,11 +229,9 @@ pub fn get_aggregation_header(
233229
/// Returns the number of additional bytes needed to store the previous OBU
234230
/// element if an additional OBU element is added to the packet.
235231
fn additional_bytes_for_previous_obu_element(packet: &PacketMetadata) -> usize {
236-
if packet.packet_size == 0 {
237-
// Packet is still empty => no last OBU element, no need to reserve space
238-
// for it.
239-
0
240-
} else if packet.num_obu_elements > MAX_NUM_OBUS_TO_OMIT_SIZE {
232+
if packet.packet_size == 0 || packet.num_obu_elements > MAX_NUM_OBUS_TO_OMIT_SIZE {
233+
// Packet is still empty => no last OBU element, no need to reserve space for it.
234+
// OR
241235
// There are so many obu elements in the packet, all of them must be
242236
// prepended with the length field. That imply space for the length of the
243237
// last obu element is already reserved.
@@ -256,7 +250,7 @@ fn max_fragment_size(remaining_bytes: usize) -> usize {
256250
}
257251
let mut i = 1;
258252
loop {
259-
if remaining_bytes < (1 << 7 * i) + i {
253+
if remaining_bytes < (1 << (7 * i)) + i {
260254
return remaining_bytes - i;
261255
}
262256
i += 1;

0 commit comments

Comments
 (0)