Skip to content

Commit

Permalink
h264: fix crash in DTSExtractor
Browse files Browse the repository at this point in the history
Check that SPS.VUI or SPS.VUI.TimingInfo are not nil
  • Loading branch information
aler9 committed Jan 5, 2023
1 parent 7f11619 commit 07ad994
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/codecs/h264/dtsextractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ func (d *DTSExtractor) extractInner(au [][]byte, pts time.Duration) (time.Durati
return 0, fmt.Errorf("SPS not received yet")
}

if d.spsp.VUI == nil || d.spsp.VUI.TimingInfo == nil {
return pts, nil
}

pocDiff, err := d.findPOCDiff(idrPresent, au)
if err != nil {
return 0, err
Expand Down
21 changes: 21 additions & 0 deletions pkg/codecs/h264/dtsextractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,27 @@ func TestDTSExtractor(t *testing.T) {
},
},
},
{
"no timing info",
[]sequenceSample{
{
[][]byte{
{ // SPS
0x27, 0x64, 0x00, 0x2a, 0xac, 0x52, 0x14, 0x07,
0x80, 0x22, 0x7e, 0x5f, 0xfc, 0x00, 0x04, 0x00,
0x05, 0xa8, 0x08, 0x08, 0x0d, 0xb6, 0x15, 0xaf,
0x7b, 0xe0, 0x20,
},
{
// IDR
byte(NALUTypeIDR),
},
},
1 * time.Second,
1 * time.Second,
},
},
},
} {
t.Run(ca.name, func(t *testing.T) {
ex := NewDTSExtractor()
Expand Down

0 comments on commit 07ad994

Please sign in to comment.