From c4e2ca64a95e52d1de8baba5128633b1eaabb035 Mon Sep 17 00:00:00 2001 From: saxon Date: Sat, 12 Jan 2019 17:51:39 +1030 Subject: [PATCH] psi: modified addPadding to only do one resize --- stream/mts/psi/helpers.go | 7 +++++-- stream/mts/psi/psi.go | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/stream/mts/psi/helpers.go b/stream/mts/psi/helpers.go index 42f0c5fd..9beecab4 100644 --- a/stream/mts/psi/helpers.go +++ b/stream/mts/psi/helpers.go @@ -132,8 +132,11 @@ func trimTo(d []byte, t byte) []byte { // addPadding adds an appropriate amount of padding to a pat or pmt table for // addition to an mpegts packet func addPadding(d []byte) []byte { - for len(d) < PktSize { - d = append(d, 0xff) + t := make([]byte, PacketSize) + copy(t, d) + padding := t[len(d):] + for i := range padding { + padding[i] = 0xff } return d } diff --git a/stream/mts/psi/psi.go b/stream/mts/psi/psi.go index 4d76110d..09028ba6 100644 --- a/stream/mts/psi/psi.go +++ b/stream/mts/psi/psi.go @@ -26,9 +26,8 @@ LICENSE package psi -// Misc consts const ( - PktSize = 184 + PacketSize = 184 // packet size of a psi. ) // Lengths of section definitions