remove redundant variables

This commit is contained in:
aler9
2022-12-28 23:32:20 +01:00
parent da21f946e5
commit 33fe24eb6d
2 changed files with 14 additions and 23 deletions

View File

@@ -1,7 +1,6 @@
package h264 package h264
import ( import (
"bytes"
"fmt" "fmt"
"math" "math"
"time" "time"
@@ -163,7 +162,6 @@ func findSEITimingInfo(nalus [][]byte, sps *SPS) (*seiTimingInfo, bool) {
// DTSExtractor allows to extract DTS from PTS. // DTSExtractor allows to extract DTS from PTS.
type DTSExtractor struct { type DTSExtractor struct {
sps []byte
spsp *SPS spsp *SPS
prevPTS time.Duration prevPTS time.Duration
prevDTSFilled bool prevDTSFilled bool
@@ -185,13 +183,11 @@ func (d *DTSExtractor) extractInner(nalus [][]byte, pts time.Duration) (time.Dur
typ := NALUType(nalu[0] & 0x1F) typ := NALUType(nalu[0] & 0x1F)
switch typ { switch typ {
case NALUTypeSPS: case NALUTypeSPS:
if d.sps == nil || !bytes.Equal(d.sps, nalu) {
var spsp SPS var spsp SPS
err := spsp.Unmarshal(nalu) err := spsp.Unmarshal(nalu)
if err != nil { if err != nil {
return 0, 0, fmt.Errorf("invalid SPS: %v", err) return 0, 0, fmt.Errorf("invalid SPS: %v", err)
} }
d.sps = append([]byte(nil), nalu...)
d.spsp = &spsp d.spsp = &spsp
if d.spsp.VUI != nil && d.spsp.VUI.TimingInfo != nil && if d.spsp.VUI != nil && d.spsp.VUI.TimingInfo != nil &&
@@ -202,7 +198,6 @@ func (d *DTSExtractor) extractInner(nalus [][]byte, pts time.Duration) (time.Dur
} else { } else {
d.ptsDTSOffset = 0 d.ptsDTSOffset = 0
} }
}
case NALUTypeIDR: case NALUTypeIDR:
idrPresent = true idrPresent = true

View File

@@ -131,9 +131,7 @@ func getPictureOrderCountDiff(poc1 uint32, poc2 uint32, sps *SPS) int32 {
// DTSExtractor allows to extract DTS from PTS. // DTSExtractor allows to extract DTS from PTS.
type DTSExtractor struct { type DTSExtractor struct {
sps []byte
spsp *SPS spsp *SPS
pps []byte
ppsp *PPS ppsp *PPS
prevDTSFilled bool prevDTSFilled bool
prevDTS time.Duration prevDTS time.Duration
@@ -157,7 +155,6 @@ func (d *DTSExtractor) extractInner(nalus [][]byte, pts time.Duration) (time.Dur
if err != nil { if err != nil {
return 0, fmt.Errorf("invalid SPS: %v", err) return 0, fmt.Errorf("invalid SPS: %v", err)
} }
d.sps = append([]byte(nil), nalu...)
d.spsp = &spsp d.spsp = &spsp
case NALUType_PPS_NUT: case NALUType_PPS_NUT:
@@ -166,7 +163,6 @@ func (d *DTSExtractor) extractInner(nalus [][]byte, pts time.Duration) (time.Dur
if err != nil { if err != nil {
return 0, fmt.Errorf("invalid PPS: %v", err) return 0, fmt.Errorf("invalid PPS: %v", err)
} }
d.pps = append([]byte(nil), nalu...)
d.ppsp = &ppsp d.ppsp = &ppsp
case NALUType_IDR_W_RADL, NALUType_IDR_N_LP: case NALUType_IDR_W_RADL, NALUType_IDR_N_LP:
@@ -178,7 +174,7 @@ func (d *DTSExtractor) extractInner(nalus [][]byte, pts time.Duration) (time.Dur
return 0, fmt.Errorf("SPS not received yet") return 0, fmt.Errorf("SPS not received yet")
} }
if d.pps == nil { if d.ppsp == nil {
return 0, fmt.Errorf("PPS not received yet") return 0, fmt.Errorf("PPS not received yet")
} }