Skip to content

Commit

Permalink
Fixing incomplete PES data
Browse files Browse the repository at this point in the history
  • Loading branch information
asticode committed Nov 25, 2017
1 parent beda8c6 commit d5909e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions data_pes.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package astits

import "github.com/asticode/go-astilog"

// P-STD buffer scales
const (
PSTDBufferScale128Bytes = 0
Expand Down Expand Up @@ -134,6 +136,13 @@ func parsePESHeader(i []byte, offset *int) (h *PESHeader, dataStart, dataEnd int
dataEnd = len(i)
}

// Check for incomplete data
// TODO Throw away the data?
if dataEnd > len(i) {
astilog.Debug("PES dataEnd > len(i), needs fixing")
dataEnd = len(i)
}

// Optional header
if hasPESOptionalHeader(h.StreamID) {
h.OptionalHeader, dataStart = parsePESOptionalHeader(i, offset)
Expand Down
1 change: 1 addition & 0 deletions data_psi.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func hasCRC32(tableType string) bool {
}

// psiTableType returns the psi table type based on the table id
// Page: 28 | https://www.dvb.org/resources/public/standards/a38_dvb-si_specification.pdf
func psiTableType(tableID int) string {
switch {
case tableID == 0x4a:
Expand Down

0 comments on commit d5909e8

Please sign in to comment.