Skip to content

Commit

Permalink
Fixed PES data parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
asticode committed Sep 17, 2019
1 parent af4a358 commit e47b3a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data_pes.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func parsePESData(i *astibyte.Iterator) (d *PESData, err error) {

// Parse data
if d.Header != nil && d.Header.PacketLength > 0 {
if d.Data, err = i.NextBytes(int(d.Header.PacketLength)); err != nil {
if d.Data, err = i.NextBytes(int(d.Header.PacketLength)-dataStart); err != nil {
err = errors.Wrap(err, "astits: getting next bytes failed")
return
}
Expand Down
4 changes: 2 additions & 2 deletions data_pes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ func TestParsePESSection(t *testing.T) {
// No optional header and specific packet length
d, err := parsePESData(astibyte.NewIterator(pesWithoutHeaderBytes()))
assert.NoError(t, err)
assert.Equal(t, d, pesWithoutHeader)
assert.Equal(t, pesWithoutHeader, d)

// Optional header and no specific header length
d, err = parsePESData(astibyte.NewIterator(pesWithHeaderBytes()))
assert.NoError(t, err)
assert.Equal(t, d, pesWithHeader)
assert.Equal(t, pesWithHeader, d)
}

0 comments on commit e47b3a7

Please sign in to comment.