codec/h265: made test data more compact.

This commit is contained in:
Saxon 2019-05-01 23:19:16 +09:30
parent c15894dc12
commit 80ed0d2e1c
2 changed files with 43 additions and 79 deletions

View File

@ -155,7 +155,7 @@ func (l *Lexer) handleFragmentation(d []byte) {
case !s && !e: case !s && !e:
l.writeNoPrefix(_d) l.writeNoPrefix(_d)
default: default:
panic("bad fragmentation unit") panic("bad fragmentation packet")
} }
} }

View File

@ -58,7 +58,7 @@ func (d *destination) Write(p []byte) (int, error) {
return len(p), nil return len(p), nil
} }
func TestLex(t *testing.T) { func TestLexNo(t *testing.T) {
const rtpVer = 2 const rtpVer = 2
packets := []rtp.Pkt{ packets := []rtp.Pkt{
@ -66,23 +66,17 @@ func TestLex(t *testing.T) {
rtp.Pkt{ rtp.Pkt{
V: rtpVer, V: rtpVer,
Payload: []byte{ Payload: []byte{
// NAL header (type=32 VPS) 0x40, 0x00, // NAL header (type=32 VPS).
0x40, 0x00, 0x01, 0x02, 0x03, 0x04, // NAL Data.
// NAL data
0x01, 0x02, 0x03, 0x04,
}, },
}, },
// Fragmentation (start packet).
// Fragmentation (start packet)
rtp.Pkt{ rtp.Pkt{
V: rtpVer, V: rtpVer,
Payload: []byte{ Payload: []byte{
// NAL header (type 49) 0x62, 0x00, // NAL header (type49).
0x62, 0x00, 0x80, // FU header.
// FU header 0x01, 0x02, 0x03, // FU payload.
0x80,
// FU Payload
0x01, 0x02, 0x03,
}, },
}, },
@ -90,12 +84,9 @@ func TestLex(t *testing.T) {
rtp.Pkt{ rtp.Pkt{
V: rtpVer, V: rtpVer,
Payload: []byte{ Payload: []byte{
// NAL header (type 49) 0x62, 0x00, // NAL header (type 49).
0x62, 0x00, 0x00, // FU header.
// FU header 0x04, 0x05, 0x06, // FU payload.
0x00,
// FU Payload
0x04, 0x05, 0x06,
}, },
}, },
@ -103,31 +94,23 @@ func TestLex(t *testing.T) {
rtp.Pkt{ rtp.Pkt{
V: rtpVer, V: rtpVer,
Payload: []byte{ Payload: []byte{
// NAL header (type 49) 0x62, 0x00, // NAL header (type 49).
0x62, 0x00, 0x40, // FU header.
// FU header 0x07, 0x08, 0x09, // FU payload
0x40,
// FU Payload
0x07, 0x08, 0x09,
}, },
}, },
// Aggregation. // Aggregation.
// This is the last bit of data for the access unit, so set M true // Consider last packet of access unit - M true
rtp.Pkt{ rtp.Pkt{
V: rtpVer, V: rtpVer,
M: true, M: true,
Payload: []byte{ Payload: []byte{
// NAL header (type 49) 0x60, 0x00, // NAL header (type 49).
0x60, 0x00, 0x00, 0x04, // NAL 1 size.
// NAL1 Size 0x01, 0x02, 0x03, 0x04, // NAL 1 data.
0x00, 0x04, 0x00, 0x04, // NAL 2 size.
// NAL1 data 0x01, 0x02, 0x03, 0x04, // NAL 2 data.
0x01, 0x02, 0x03, 0x04,
// NAL2 Size
0x00, 0x04,
// NAL2 data
0x01, 0x02, 0x03, 0x04,
}, },
}, },
@ -135,10 +118,8 @@ func TestLex(t *testing.T) {
rtp.Pkt{ rtp.Pkt{
V: rtpVer, V: rtpVer,
Payload: []byte{ Payload: []byte{
// NAL header (type=32 VPS) 0x40, 0x00, // NAL header (type=32 VPS).
0x40, 0x00, 0x01, 0x02, 0x03, 0x04, // NAL data.
// NAL data
0x01, 0x02, 0x03, 0x04,
}, },
}, },
@ -147,62 +128,45 @@ func TestLex(t *testing.T) {
V: rtpVer, V: rtpVer,
M: true, M: true,
Payload: []byte{ Payload: []byte{
// NAL header (type=32 VPS) 0x40, 0x00, // NAL header (type=32 VPS).
0x40, 0x00, 0x01, 0x02, 0x03, 0x04, // NAL data.
// NAL data
0x01, 0x02, 0x03, 0x04,
}, },
}, },
} }
expect := [][]byte{ expect := [][]byte{
// First access unit.
{ {
// NAL 1 // NAL 1
// Start code 0x00, 0x00, 0x00, 0x01, // Start code.
0x00, 0x00, 0x00, 0x01, 0x40, 0x00, // NAL header (type=32 VPS).
// NAL header (type=32 VPS) 0x01, 0x02, 0x03, 0x04, // NAL data.
0x40, 0x00,
// NAL data
0x01, 0x02, 0x03, 0x04,
// NAL 2 // NAL 2
// Start code 0x00, 0x00, 0x00, 0x01, // Start code.
0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, // FU payload.
// FU Payload 0x04, 0x05, 0x06, // FU payload.
0x01, 0x02, 0x03, 0x07, 0x08, 0x09, // FU payload.
// FU Payload
0x04, 0x05, 0x06,
// FU Payload
0x07, 0x08, 0x09,
// NAL 3 // NAL 3
// Start code 0x00, 0x00, 0x00, 0x01, // Start code.
0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, // NAL data.
// NAL data
0x01, 0x02, 0x03, 0x04,
// NAL 4 // NAL 4
// Start code 0x00, 0x00, 0x00, 0x01, // Start code.
0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, // NAL 2 data
// NAL2 data
0x01, 0x02, 0x03, 0x04,
}, },
// Second access unit.
{ {
// NAL 1 // NAL 1
//Start code 0x00, 0x00, 0x00, 0x01, // Start code.
0x00, 0x00, 0x00, 0x01, 0x40, 0x00, // NAL header (type=32 VPS).
// NAL header (type=32 VPS) 0x01, 0x02, 0x03, 0x04, // Data.
0x40, 0x00,
// Data
0x01, 0x02, 0x03, 0x04,
// NAL 2 // NAL 2
//Start code 0x00, 0x00, 0x00, 0x01, // Start code.
0x00, 0x00, 0x00, 0x01, 0x40, 0x00, // NAL header (type=32 VPS).
// NAL header (type=32 VPS) 0x01, 0x02, 0x03, 0x04, // Data.
0x40, 0x00,
// Data
0x01, 0x02, 0x03, 0x04,
}, },
} }