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)
if (d.frameBufferLen + l) > av1.MaxOBUsPerTemporalUnit {
errCount := d.frameBufferLen + l
d.frameBuffer = nil
d.frameBufferLen = 0
d.frameBufferSize = 0
return nil, fmt.Errorf("OBU count exceeds maximum allowed (%d)",
av1.MaxOBUsPerTemporalUnit)
return nil, fmt.Errorf("OBU count (%d) exceeds maximum allowed (%d)",
errCount, av1.MaxOBUsPerTemporalUnit)
}
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) {

View File

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

View File

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