// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package rtcp

// getPadding Returns the padding required to make the length a multiple of 4
func getPadding( int) int {
	if %4 == 0 {
		return 0
	}
	return 4 - ( % 4)
}

// setNBitsOfUint16 will truncate the value to size, left-shift to startIndex position and set
func setNBitsOfUint16(, , ,  uint16) (uint16, error) {
	if + > 16 {
		return 0, errInvalidSizeOrStartIndex
	}

	// truncate val to size bits
	 &= (1 << ) - 1

	return  | ( << (16 -  - )), nil
}

// appendBit32 will left-shift and append n bits of val
func appendNBitsToUint32(, ,  uint32) uint32 {
	return ( << ) | ( & (0xFFFFFFFF >> (32 - )))
}

// getNBit get n bits from 1 byte, begin with a position
func getNBitsFromByte( byte, ,  uint16) uint16 {
	 := 8 - ( + )
	 := (0xFF >> ) & uint8(0xFF<<)
	return uint16(&) >> 
}

// get24BitFromBytes get 24bits from `[3]byte` slice
func get24BitsFromBytes( []byte) uint32 {
	return uint32([0])<<16 + uint32([1])<<8 + uint32([2])
}