Skip to content

Commit

Permalink
Suppress linter warning
Browse files Browse the repository at this point in the history
  • Loading branch information
y-kawawa committed Jan 11, 2025
1 parent 99f5ac5 commit ab77ba5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion codecs/h265_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ type H265Payloader struct {
}

// Payload fragments a H265 packet across one or more byte arrays.
func (p *H265Payloader) Payload(mtu uint16, payload []byte) [][]byte { //nolint: gocognit
func (p *H265Payloader) Payload(mtu uint16, payload []byte) [][]byte { //nolint: gocognit,cyclop,funlen
var payloads [][]byte
if len(payload) == 0 || mtu == 0 {
return payloads
Expand Down Expand Up @@ -928,6 +928,9 @@ func (p *H265Payloader) Payload(mtu uint16, payload []byte) [][]byte { //nolint:
index++
}
}

// Since the type of mtu is uint16, len(nalu) fits in as well, so it is safe.
// #nosec
binary.BigEndian.PutUint16(buf[index:index+2], uint16(len(nalu)))
index += 2
index += copy(buf[index:], nalu)
Expand Down
4 changes: 3 additions & 1 deletion codecs/h265_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ func TestH265_Packet_Real(t *testing.T) {
}
}

func TestH265Payloader_Payload(t *testing.T) {
func TestH265Payloader_Payload(t *testing.T) { // nolint: funlen
tt := []struct {
Name string
Data []byte
Expand Down Expand Up @@ -1141,6 +1141,8 @@ func TestH265Payloader_Real(t *testing.T) {
// curl -LO "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h265/1080/Big_Buck_Bunny_1080_10s_1MB.mp4"
// ffmpeg -i Big_Buck_Bunny_1080_10s_1MB.mp4 -c:v copy Big_Buck_Bunny_1080_10s_1MB.h265
// hexdump -v -e '1/1 "0x%02x, "' Big_Buck_Bunny_1080_10s_1MB.h265 > aaa

// nolint: lll
payload := []byte{
0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x78, 0x95, 0x98, 0x09,
0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x78, 0xa0, 0x03, 0xc0, 0x80, 0x10, 0xe5, 0x96, 0x56, 0x69, 0x24, 0xca, 0xf0, 0x10, 0x10, 0x00, 0x00, 0x03, 0x00, 0x10, 0x00, 0x00, 0x03, 0x01, 0xe0, 0x80,
Expand Down

0 comments on commit ab77ba5

Please sign in to comment.