Skip to content

Commit

Permalink
Add test case for broken second nalu in STAP-A
Browse files Browse the repository at this point in the history
  • Loading branch information
HyeockJinKim authored and Sean-Der committed Aug 2, 2024
1 parent f7f1a05 commit 378ef6f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions codecs/h264_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ func TestH264Packet_Unmarshal(t *testing.T) {
singlePayloadMultiNALU := []byte{0x78, 0x00, 0x0f, 0x67, 0x42, 0xc0, 0x1f, 0x1a, 0x32, 0x35, 0x01, 0x40, 0x7a, 0x40, 0x3c, 0x22, 0x11, 0xa8, 0x00, 0x05, 0x68, 0x1a, 0x34, 0xe3, 0xc8}
singlePayloadMultiNALUUnmarshaled := []byte{0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0xc0, 0x1f, 0x1a, 0x32, 0x35, 0x01, 0x40, 0x7a, 0x40, 0x3c, 0x22, 0x11, 0xa8, 0x00, 0x00, 0x00, 0x01, 0x68, 0x1a, 0x34, 0xe3, 0xc8}
singlePayloadMultiNALUUnmarshaledAVC := []byte{0x00, 0x00, 0x00, 0x0f, 0x67, 0x42, 0xc0, 0x1f, 0x1a, 0x32, 0x35, 0x01, 0x40, 0x7a, 0x40, 0x3c, 0x22, 0x11, 0xa8, 0x00, 0x00, 0x00, 0x05, 0x68, 0x1a, 0x34, 0xe3, 0xc8}
singlePayloadWithBrokenSecondNALU := []byte{0x78, 0x00, 0x0f, 0x67, 0x42, 0xc0, 0x1f, 0x1a, 0x32, 0x35, 0x01, 0x40, 0x7a, 0x40, 0x3c, 0x22, 0x11, 0xa8, 0x00}
singlePayloadWithBrokenSecondNALUUnmarshaled := []byte{0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0xc0, 0x1f, 0x1a, 0x32, 0x35, 0x01, 0x40, 0x7a, 0x40, 0x3c, 0x22, 0x11, 0xa8}
singlePayloadWithBrokenSecondUnmarshaledAVC := []byte{0x00, 0x00, 0x00, 0x0f, 0x67, 0x42, 0xc0, 0x1f, 0x1a, 0x32, 0x35, 0x01, 0x40, 0x7a, 0x40, 0x3c, 0x22, 0x11, 0xa8}

incompleteSinglePayloadMultiNALU := []byte{0x78, 0x00, 0x0f, 0x67, 0x42, 0xc0, 0x1f, 0x1a, 0x32, 0x35, 0x01, 0x40, 0x7a, 0x40, 0x3c, 0x22, 0x11}

Expand Down Expand Up @@ -189,6 +192,20 @@ func TestH264Packet_Unmarshal(t *testing.T) {
} else if !reflect.DeepEqual(res, singlePayloadMultiNALUUnmarshaledAVC) {
t.Fatal("Failed to unmarshal a single packet with multiple NALUs into avc stream")
}

res, err = pkt.Unmarshal(singlePayloadWithBrokenSecondNALU)
if err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(res, singlePayloadWithBrokenSecondNALUUnmarshaled) {
t.Fatal("Failed to unmarshal a single packet with broken second NALUs")
}

res, err = avcPkt.Unmarshal(singlePayloadWithBrokenSecondNALU)
if err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(res, singlePayloadWithBrokenSecondUnmarshaledAVC) {
t.Fatal("Failed to unmarshal a single packet with broken second NALUs into avc stream")
}
}

func TestH264IsPartitionHead(t *testing.T) {
Expand Down

0 comments on commit 378ef6f

Please sign in to comment.