@@ -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.
235231fn 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