diff --git a/data_pes.go b/data_pes.go index fc91009..d3fbc15 100644 --- a/data_pes.go +++ b/data_pes.go @@ -1,5 +1,7 @@ package astits +import "github.com/asticode/go-astilog" + // P-STD buffer scales const ( PSTDBufferScale128Bytes = 0 @@ -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) diff --git a/data_psi.go b/data_psi.go index 5fa0980..64ff47a 100644 --- a/data_psi.go +++ b/data_psi.go @@ -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: