mirror of
https://github.com/aler9/gortsplib
synced 2025-10-21 06:09:33 +08:00
remove redundant variables
This commit is contained in:
@@ -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,23 +183,20 @@ 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.spsp = &spsp
|
||||||
d.sps = append([]byte(nil), nalu...)
|
|
||||||
d.spsp = &spsp
|
|
||||||
|
|
||||||
if d.spsp.VUI != nil && d.spsp.VUI.TimingInfo != nil &&
|
if d.spsp.VUI != nil && d.spsp.VUI.TimingInfo != nil &&
|
||||||
d.spsp.VUI.BitstreamRestriction != nil {
|
d.spsp.VUI.BitstreamRestriction != nil {
|
||||||
d.ptsDTSOffset = time.Duration(math.Round(float64(
|
d.ptsDTSOffset = time.Duration(math.Round(float64(
|
||||||
time.Duration(d.spsp.VUI.BitstreamRestriction.MaxNumReorderFrames)*time.Second*
|
time.Duration(d.spsp.VUI.BitstreamRestriction.MaxNumReorderFrames)*time.Second*
|
||||||
time.Duration(d.spsp.VUI.TimingInfo.NumUnitsInTick)*2) / float64(d.spsp.VUI.TimingInfo.TimeScale)))
|
time.Duration(d.spsp.VUI.TimingInfo.NumUnitsInTick)*2) / float64(d.spsp.VUI.TimingInfo.TimeScale)))
|
||||||
} else {
|
} else {
|
||||||
d.ptsDTSOffset = 0
|
d.ptsDTSOffset = 0
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case NALUTypeIDR:
|
case NALUTypeIDR:
|
||||||
|
@@ -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")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user