From e499af91cc429a8808a56b305a3ec75728875cd7 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Wed, 8 May 2019 13:34:04 -0700 Subject: [PATCH 1/2] pts: flesh out tests --- pts_test.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pts_test.go b/pts_test.go index 487ebb9..faf73ee 100644 --- a/pts_test.go +++ b/pts_test.go @@ -35,7 +35,7 @@ func TestPTSIsAfterWithoutRollover(t *testing.T) { func TestPTSIsAfterWithRollover(t *testing.T) { p := PTS(1) - other := PTS(8589934591) // MaxPtsValue + other := PTS(MaxPtsValue) if !p.After(other) { t.Errorf("PTS=%v, not After other=%v", p, other) } @@ -125,8 +125,15 @@ func TestAdd(t *testing.T) { func TestInsertPTS(t *testing.T) { var pts uint64 = 0x1DEADBEEF b := make([]byte, 5) + + InsertPTS(b, pts) + if ots := ExtractTime(b); ots != pts { + t.Errorf("Insert PTS test 1 failed: %v != %v", ots, pts) + } + + pts = MaxPtsValue InsertPTS(b, pts) - if ExtractTime(b) != 0x1DEADBEEF { - t.Error("Insert PTS test 1 failed") + if ots := ExtractTime(b); ots != pts { + t.Errorf("Insert PTS test 2 failed: %v != %v", ots, pts) } } From 553f7a4b554284d33fddfee4e57ea9bb2fd98ab9 Mon Sep 17 00:00:00 2001 From: Aman Gupta Date: Wed, 8 May 2019 13:34:18 -0700 Subject: [PATCH 2/2] pts: ensure only one bit is set during marking --- pts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pts.go b/pts.go index b47be3b..75f3f40 100644 --- a/pts.go +++ b/pts.go @@ -129,7 +129,7 @@ func InsertPTS(b []byte, pts uint64) { b[4] = byte(pts&0xff) << 1 // PTS[7..0] // Set the marker bits as appropriate - b[0] |= 0x21 + b[0] |= 0x01 b[2] |= 0x01 b[4] |= 0x01 }