improve NALU size limit errors (#741)

This commit is contained in:
Alessandro Ros
2025-03-27 11:38:28 +01:00
committed by GitHub
parent 4b0fe4f7d2
commit abef977ad5
6 changed files with 12 additions and 9 deletions

View File

@@ -143,11 +143,12 @@ func (d *Decoder) Decode(pkt *rtp.Packet) ([][]byte, error) {
l := len(obus) l := len(obus)
if (d.frameBufferLen + l) > av1.MaxOBUsPerTemporalUnit { if (d.frameBufferLen + l) > av1.MaxOBUsPerTemporalUnit {
errCount := d.frameBufferLen + l
d.frameBuffer = nil d.frameBuffer = nil
d.frameBufferLen = 0 d.frameBufferLen = 0
d.frameBufferSize = 0 d.frameBufferSize = 0
return nil, fmt.Errorf("OBU count exceeds maximum allowed (%d)", return nil, fmt.Errorf("OBU count (%d) exceeds maximum allowed (%d)",
av1.MaxOBUsPerTemporalUnit) errCount, av1.MaxOBUsPerTemporalUnit)
} }
addSize := 0 addSize := 0

View File

@@ -52,7 +52,7 @@ func TestDecoderErrorLimit(t *testing.T) {
}) })
} }
require.EqualError(t, err, "OBU count exceeds maximum allowed (10)") require.EqualError(t, err, "OBU count (11) exceeds maximum allowed (10)")
} }
func TestDecodeErrorMissingPacket(t *testing.T) { func TestDecodeErrorMissingPacket(t *testing.T) {

View File

@@ -215,11 +215,12 @@ func (d *Decoder) Decode(pkt *rtp.Packet) ([][]byte, error) {
l := len(nalus) l := len(nalus)
if (d.frameBufferLen + l) > h264.MaxNALUsPerAccessUnit { if (d.frameBufferLen + l) > h264.MaxNALUsPerAccessUnit {
errCount := d.frameBufferLen + l
d.frameBuffer = nil d.frameBuffer = nil
d.frameBufferLen = 0 d.frameBufferLen = 0
d.frameBufferSize = 0 d.frameBufferSize = 0
return nil, fmt.Errorf("NALU count exceeds maximum allowed (%d)", return nil, fmt.Errorf("NALU count (%d) exceeds maximum allowed (%d)",
h264.MaxNALUsPerAccessUnit) errCount, h264.MaxNALUsPerAccessUnit)
} }
addSize := 0 addSize := 0

View File

@@ -241,7 +241,7 @@ func TestDecoderErrorLimit(t *testing.T) {
}) })
} }
require.EqualError(t, err, "NALU count exceeds maximum allowed (25)") require.EqualError(t, err, "NALU count (26) exceeds maximum allowed (25)")
} }
func TestDecodeErrorMissingPacket(t *testing.T) { func TestDecodeErrorMissingPacket(t *testing.T) {

View File

@@ -174,11 +174,12 @@ func (d *Decoder) Decode(pkt *rtp.Packet) ([][]byte, error) {
l := len(nalus) l := len(nalus)
if (d.frameBufferLen + l) > h265.MaxNALUsPerAccessUnit { if (d.frameBufferLen + l) > h265.MaxNALUsPerAccessUnit {
errCount := d.frameBufferLen + l
d.frameBuffer = nil d.frameBuffer = nil
d.frameBufferLen = 0 d.frameBufferLen = 0
d.frameBufferSize = 0 d.frameBufferSize = 0
return nil, fmt.Errorf("NALU count exceeds maximum allowed (%d)", return nil, fmt.Errorf("NALU count (%d) exceeds maximum allowed (%d)",
h265.MaxNALUsPerAccessUnit) errCount, h265.MaxNALUsPerAccessUnit)
} }
addSize := 0 addSize := 0

View File

@@ -58,7 +58,7 @@ func TestDecoderErrorLimit(t *testing.T) {
}) })
} }
require.EqualError(t, err, "NALU count exceeds maximum allowed (21)") require.EqualError(t, err, "NALU count (22) exceeds maximum allowed (21)")
} }
func TestDecodeErrorMissingPacket(t *testing.T) { func TestDecodeErrorMissingPacket(t *testing.T) {