Merged in fix-parse-calls (pull request #214)

codec/h264/decode: giving parsing function calls BitReaders instead of nil
This commit is contained in:
Saxon Milton 2019-07-19 05:09:19 +00:00
commit 38f5f983e8
3 changed files with 92 additions and 92 deletions

View File

@ -49,12 +49,12 @@ func NewPPS(sps *SPS, rbsp []byte, showPacket bool) (*PPS, error) {
br := bits.NewBitReader(nil)
var err error
pps.ID, err = readUe(nil)
pps.ID, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ID")
}
pps.SPSID, err = readUe(nil)
pps.SPSID, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse SPS ID")
}
@ -71,27 +71,27 @@ func NewPPS(sps *SPS, rbsp []byte, showPacket bool) (*PPS, error) {
}
pps.BottomFieldPicOrderInFramePresent = b == 1
pps.NumSliceGroupsMinus1, err = readUe(nil)
pps.NumSliceGroupsMinus1, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse NumSliceGroupsMinus1")
}
if pps.NumSliceGroupsMinus1 > 0 {
pps.SliceGroupMapType, err = readUe(nil)
pps.SliceGroupMapType, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse SliceGroupMapType")
}
if pps.SliceGroupMapType == 0 {
for iGroup := 0; iGroup <= pps.NumSliceGroupsMinus1; iGroup++ {
pps.RunLengthMinus1[iGroup], err = readUe(nil)
pps.RunLengthMinus1[iGroup], err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse RunLengthMinus1")
}
}
} else if pps.SliceGroupMapType == 2 {
for iGroup := 0; iGroup < pps.NumSliceGroupsMinus1; iGroup++ {
pps.TopLeft[iGroup], err = readUe(nil)
pps.TopLeft[iGroup], err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse TopLeft[iGroup]")
}
@ -99,7 +99,7 @@ func NewPPS(sps *SPS, rbsp []byte, showPacket bool) (*PPS, error) {
return nil, errors.Wrap(err, "could not parse TopLeft[iGroup]")
}
pps.BottomRight[iGroup], err = readUe(nil)
pps.BottomRight[iGroup], err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse BottomRight[iGroup]")
}
@ -111,12 +111,12 @@ func NewPPS(sps *SPS, rbsp []byte, showPacket bool) (*PPS, error) {
}
pps.SliceGroupChangeDirection = b == 1
pps.SliceGroupChangeRateMinus1, err = readUe(nil)
pps.SliceGroupChangeRateMinus1, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse SliceGroupChangeRateMinus1")
}
} else if pps.SliceGroupMapType == 6 {
pps.PicSizeInMapUnitsMinus1, err = readUe(nil)
pps.PicSizeInMapUnitsMinus1, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse PicSizeInMapUnitsMinus1")
}
@ -131,12 +131,12 @@ func NewPPS(sps *SPS, rbsp []byte, showPacket bool) (*PPS, error) {
}
}
pps.NumRefIdxL0DefaultActiveMinus1, err = readUe(nil)
pps.NumRefIdxL0DefaultActiveMinus1, err = readUe(br)
if err != nil {
return nil, errors.New("could not parse NumRefIdxL0DefaultActiveMinus1")
}
pps.NumRefIdxL1DefaultActiveMinus1, err = readUe(nil)
pps.NumRefIdxL1DefaultActiveMinus1, err = readUe(br)
if err != nil {
return nil, errors.New("could not parse NumRefIdxL1DefaultActiveMinus1")
}
@ -153,17 +153,17 @@ func NewPPS(sps *SPS, rbsp []byte, showPacket bool) (*PPS, error) {
}
pps.WeightedBipred = int(b)
pps.PicInitQpMinus26, err = readSe(nil)
pps.PicInitQpMinus26, err = readSe(br)
if err != nil {
return nil, errors.New("could not parse PicInitQpMinus26")
}
pps.PicInitQsMinus26, err = readSe(nil)
pps.PicInitQsMinus26, err = readSe(br)
if err != nil {
return nil, errors.New("could not parse PicInitQsMinus26")
}
pps.ChromaQpIndexOffset, err = readSe(nil)
pps.ChromaQpIndexOffset, err = readSe(br)
if err != nil {
return nil, errors.New("could not parse ChromaQpIndexOffset")
}
@ -222,7 +222,7 @@ func NewPPS(sps *SPS, rbsp []byte, showPacket bool) (*PPS, error) {
}
}
}
pps.SecondChromaQpIndexOffset, err = readSe(nil)
pps.SecondChromaQpIndexOffset, err = readSe(br)
if err != nil {
return nil, errors.New("could not parse SecondChromaQpIndexOffset")
}

View File

@ -373,7 +373,7 @@ func MbPred(sliceContext *SliceContext, br *bits.BitReader, rbsp []byte) error {
logger.Printf("TODO: ae for IntraChromaPredMode\n")
} else {
var err error
sliceContext.Slice.Data.IntraChromaPredMode, err = readUe(nil)
sliceContext.Slice.Data.IntraChromaPredMode, err = readUe(br)
if err != nil {
return errors.Wrap(err, "could not parse IntraChromaPredMode")
}
@ -406,12 +406,12 @@ func MbPred(sliceContext *SliceContext, br *bits.BitReader, rbsp []byte) error {
// then the value should be 0
if MbaffFrameFlag(sliceContext.SPS, sliceContext.Slice.Header) == 0 || !sliceContext.Slice.Data.MbFieldDecodingFlag {
sliceContext.Slice.Data.RefIdxL0[mbPartIdx], _ = readTe(
nil,
br,
uint(sliceContext.Slice.Header.NumRefIdxL0ActiveMinus1))
} else {
rangeMax := 2*sliceContext.Slice.Header.NumRefIdxL0ActiveMinus1 + 1
sliceContext.Slice.Data.RefIdxL0[mbPartIdx], _ = readTe(
nil,
br,
uint(rangeMax))
}
}
@ -451,7 +451,7 @@ func MbPred(sliceContext *SliceContext, br *bits.BitReader, rbsp []byte) error {
}
logger.Printf("TODO: ae for MvdL0[%d][0][%d]\n", mbPartIdx, compIdx)
} else {
sliceContext.Slice.Data.MvdL0[mbPartIdx][0][compIdx], _ = readSe(nil)
sliceContext.Slice.Data.MvdL0[mbPartIdx][0][compIdx], _ = readSe(br)
}
}
}
@ -491,7 +491,7 @@ func MbPred(sliceContext *SliceContext, br *bits.BitReader, rbsp []byte) error {
// TODO: se(v) or ae(v)
logger.Printf("TODO: ae for MvdL1[%d][0][%d]\n", mbPartIdx, compIdx)
} else {
sliceContext.Slice.Data.MvdL1[mbPartIdx][0][compIdx], _ = readSe(nil)
sliceContext.Slice.Data.MvdL1[mbPartIdx][0][compIdx], _ = readSe(br)
}
}
}
@ -645,7 +645,7 @@ func NewSliceData(sliceContext *SliceContext, br *bits.BitReader) (*SliceData, e
if sliceContext.Slice.Data.SliceTypeName != "I" && sliceContext.Slice.Data.SliceTypeName != "SI" {
logger.Printf("debug: \tNonI/SI slice, processing moreData\n")
if sliceContext.PPS.EntropyCodingMode == 0 {
sliceContext.Slice.Data.MbSkipRun, err = readUe(nil)
sliceContext.Slice.Data.MbSkipRun, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse MbSkipRun")
}
@ -762,7 +762,7 @@ func NewSliceData(sliceContext *SliceContext, br *bits.BitReader) (*SliceData, e
logger.Printf("TODO: ae for MBType\n")
} else {
sliceContext.Slice.Data.MbType, err = readUe(nil)
sliceContext.Slice.Data.MbType, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse MbType")
}
@ -867,7 +867,7 @@ func NewSliceData(sliceContext *SliceContext, br *bits.BitReader) (*SliceData, e
logger.Printf("TODO: ae for CodedBlockPattern\n")
} else {
me, _ := readMe(
nil,
br,
uint(sliceContext.Slice.Header.ChromaArrayType),
// TODO: fix this
//MbPartPredMode(sliceContext.Slice.Data, sliceContext.Slice.Data.SliceTypeName, sliceContext.Slice.Data.MbType, 0)))
@ -908,7 +908,7 @@ func NewSliceData(sliceContext *SliceContext, br *bits.BitReader) (*SliceData, e
logger.Printf("TODO: ae for MbQpDelta\n")
} else {
sliceContext.Slice.Data.MbQpDelta, _ = readSe(nil)
sliceContext.Slice.Data.MbQpDelta, _ = readSe(br)
}
}
@ -963,19 +963,19 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
}
br := bits.NewBitReader(bytes.NewReader(rbsp))
header.FirstMbInSlice, err = readUe(nil)
header.FirstMbInSlice, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse FirstMbInSlice")
}
header.SliceType, err = readUe(nil)
header.SliceType, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse SliceType")
}
sliceType := sliceTypeMap[header.SliceType]
logger.Printf("debug: %s (%s) slice of %d bytes\n", NALUnitType[nalUnit.Type], sliceType, len(rbsp))
header.PPSID, err = readUe(nil)
header.PPSID, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse PPSID")
}
@ -1004,7 +1004,7 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
}
}
if idrPic {
header.IDRPicID, err = readUe(nil)
header.IDRPicID, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse IDRPicID")
}
@ -1017,27 +1017,27 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
header.PicOrderCntLsb = int(b)
if pps.BottomFieldPicOrderInFramePresent && !header.FieldPic {
header.DeltaPicOrderCntBottom, err = readSe(nil)
header.DeltaPicOrderCntBottom, err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse DeltaPicOrderCntBottom")
}
}
}
if sps.PicOrderCountType == 1 && !sps.DeltaPicOrderAlwaysZero {
header.DeltaPicOrderCnt[0], err = readSe(nil)
header.DeltaPicOrderCnt[0], err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse DeltaPicOrderCnt")
}
if pps.BottomFieldPicOrderInFramePresent && !header.FieldPic {
header.DeltaPicOrderCnt[1], err = readSe(nil)
header.DeltaPicOrderCnt[1], err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse DeltaPicOrderCnt")
}
}
}
if pps.RedundantPicCntPresent {
header.RedundantPicCnt, err = readUe(nil)
header.RedundantPicCnt, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse RedundantPicCnt")
}
@ -1057,12 +1057,12 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
header.NumRefIdxActiveOverride = b == 1
if header.NumRefIdxActiveOverride {
header.NumRefIdxL0ActiveMinus1, err = readUe(nil)
header.NumRefIdxL0ActiveMinus1, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse NumRefIdxL0ActiveMinus1")
}
if sliceType == "B" {
header.NumRefIdxL1ActiveMinus1, err = readUe(nil)
header.NumRefIdxL1ActiveMinus1, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse NumRefIdxL1ActiveMinus1")
}
@ -1085,18 +1085,18 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
if header.RefPicListModificationFlagL0 {
for header.ModificationOfPicNums != 3 {
header.ModificationOfPicNums, err = readUe(nil)
header.ModificationOfPicNums, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ModificationOfPicNums")
}
if header.ModificationOfPicNums == 0 || header.ModificationOfPicNums == 1 {
header.AbsDiffPicNumMinus1, err = readUe(nil)
header.AbsDiffPicNumMinus1, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse AbsDiffPicNumMinus1")
}
} else if header.ModificationOfPicNums == 2 {
header.LongTermPicNum, err = readUe(nil)
header.LongTermPicNum, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse LongTermPicNum")
}
@ -1114,18 +1114,18 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
if header.RefPicListModificationFlagL1 {
for header.ModificationOfPicNums != 3 {
header.ModificationOfPicNums, err = readUe(nil)
header.ModificationOfPicNums, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ModificationOfPicNums")
}
if header.ModificationOfPicNums == 0 || header.ModificationOfPicNums == 1 {
header.AbsDiffPicNumMinus1, err = readUe(nil)
header.AbsDiffPicNumMinus1, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse AbsDiffPicNumMinus1")
}
} else if header.ModificationOfPicNums == 2 {
header.LongTermPicNum, err = readUe(nil)
header.LongTermPicNum, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse LongTermPicNum")
}
@ -1138,13 +1138,13 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
if (pps.WeightedPred && (sliceType == "P" || sliceType == "SP")) || (pps.WeightedBipred == 1 && sliceType == "B") {
// predWeightTable()
header.LumaLog2WeightDenom, err = readUe(nil)
header.LumaLog2WeightDenom, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse LumaLog2WeightDenom")
}
if header.ChromaArrayType != 0 {
header.ChromaLog2WeightDenom, err = readUe(nil)
header.ChromaLog2WeightDenom, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ChromaLog2WeightDenom")
}
@ -1157,13 +1157,13 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
header.LumaWeightL0Flag = b == 1
if header.LumaWeightL0Flag {
se, err := readSe(nil)
se, err := readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse LumaWeightL0")
}
header.LumaWeightL0 = append(header.LumaWeightL0, se)
se, err = readSe(nil)
se, err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse LumaOffsetL0")
}
@ -1180,13 +1180,13 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
header.ChromaWeightL0 = append(header.ChromaWeightL0, []int{})
header.ChromaOffsetL0 = append(header.ChromaOffsetL0, []int{})
for j := 0; j < 2; j++ {
se, err := readSe(nil)
se, err := readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ChromaWeightL0")
}
header.ChromaWeightL0[i] = append(header.ChromaWeightL0[i], se)
se, err = readSe(nil)
se, err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ChromaOffsetL0")
}
@ -1204,13 +1204,13 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
header.LumaWeightL1Flag = b == 1
if header.LumaWeightL1Flag {
se, err := readSe(nil)
se, err := readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse LumaWeightL1")
}
header.LumaWeightL1 = append(header.LumaWeightL1, se)
se, err = readSe(nil)
se, err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse LumaOffsetL1")
}
@ -1227,13 +1227,13 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
header.ChromaWeightL1 = append(header.ChromaWeightL1, []int{})
header.ChromaOffsetL1 = append(header.ChromaOffsetL1, []int{})
for j := 0; j < 2; j++ {
se, err := readSe(nil)
se, err := readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ChromaWeightL1")
}
header.ChromaWeightL1[i] = append(header.ChromaWeightL1[i], se)
se, err = readSe(nil)
se, err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ChromaOffsetL1")
}
@ -1266,31 +1266,31 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
header.AdaptiveRefPicMarkingModeFlag = b == 1
if header.AdaptiveRefPicMarkingModeFlag {
header.MemoryManagementControlOperation, err = readUe(nil)
header.MemoryManagementControlOperation, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse MemoryManagementControlOperation")
}
for header.MemoryManagementControlOperation != 0 {
if header.MemoryManagementControlOperation == 1 || header.MemoryManagementControlOperation == 3 {
header.DifferenceOfPicNumsMinus1, err = readUe(nil)
header.DifferenceOfPicNumsMinus1, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse MemoryManagementControlOperation")
}
}
if header.MemoryManagementControlOperation == 2 {
header.LongTermPicNum, err = readUe(nil)
header.LongTermPicNum, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse LongTermPicNum")
}
}
if header.MemoryManagementControlOperation == 3 || header.MemoryManagementControlOperation == 6 {
header.LongTermFrameIdx, err = readUe(nil)
header.LongTermFrameIdx, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse LongTermFrameIdx")
}
}
if header.MemoryManagementControlOperation == 4 {
header.MaxLongTermFrameIdxPlus1, err = readUe(nil)
header.MaxLongTermFrameIdxPlus1, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse MaxLongTermFrameIdxPlus1")
}
@ -1300,12 +1300,12 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
} // end decRefPicMarking
}
if pps.EntropyCodingMode == 1 && sliceType != "I" && sliceType != "SI" {
header.CabacInit, err = readUe(nil)
header.CabacInit, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse CabacInit")
}
}
header.SliceQpDelta, err = readSe(nil)
header.SliceQpDelta, err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse SliceQpDelta")
}
@ -1318,24 +1318,24 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
}
header.SpForSwitch = b == 1
}
header.SliceQsDelta, err = readSe(nil)
header.SliceQsDelta, err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse SliceQsDelta")
}
}
if pps.DeblockingFilterControlPresent {
header.DisableDeblockingFilter, err = readUe(nil)
header.DisableDeblockingFilter, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse DisableDeblockingFilter")
}
if header.DisableDeblockingFilter != 1 {
header.SliceAlphaC0OffsetDiv2, err = readSe(nil)
header.SliceAlphaC0OffsetDiv2, err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse SliceAlphaC0OffsetDiv2")
}
header.SliceBetaOffsetDiv2, err = readSe(nil)
header.SliceBetaOffsetDiv2, err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse SliceBetaOffsetDiv2")
}

View File

@ -175,12 +175,12 @@ func debugPacket(name string, packet interface{}) {
logger.Printf("debug: \t%#v\n", line)
}
}
func scalingList(b *bits.BitReader, scalingList []int, sizeOfScalingList int, defaultScalingMatrix []int) error {
func scalingList(br *bits.BitReader, scalingList []int, sizeOfScalingList int, defaultScalingMatrix []int) error {
lastScale := 8
nextScale := 8
for i := 0; i < sizeOfScalingList; i++ {
if nextScale != 0 {
deltaScale, err := readSe(nil)
deltaScale, err := readSe(br)
if err != nil {
return errors.Wrap(err, "could not parse deltaScale")
}
@ -206,7 +206,7 @@ func NewSPS(rbsp []byte, showPacket bool) (*SPS, error) {
br := bits.NewBitReader(bytes.NewReader(rbsp))
var err error
hrdParameters := func() error {
sps.CpbCntMinus1, err = readUe(nil)
sps.CpbCntMinus1, err = readUe(br)
if err != nil {
return errors.Wrap(err, "could not parse CpbCntMinus1")
}
@ -221,13 +221,13 @@ func NewSPS(rbsp []byte, showPacket bool) (*SPS, error) {
// SchedSelIdx E1.2
for sseli := 0; sseli <= sps.CpbCntMinus1; sseli++ {
ue, err := readUe(nil)
ue, err := readUe(br)
if err != nil {
return errors.Wrap(err, "could not parse BitRateValueMinus1")
}
sps.BitRateValueMinus1 = append(sps.BitRateValueMinus1, ue)
ue, err = readUe(nil)
ue, err = readUe(br)
if err != nil {
return errors.Wrap(err, "could not parse CpbSizeValueMinus1")
}
@ -278,12 +278,12 @@ func NewSPS(rbsp []byte, showPacket bool) (*SPS, error) {
sps.Level = int(b)
// sps.ID = b.NextField("SPSID", 6) // proper
sps.ID, err = readUe(nil)
sps.ID, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ID")
}
sps.ChromaFormat, err = readUe(nil)
sps.ChromaFormat, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ChromaFormat")
}
@ -301,12 +301,12 @@ func NewSPS(rbsp []byte, showPacket bool) (*SPS, error) {
sps.UseSeparateColorPlane = b == 1
}
sps.BitDepthLumaMinus8, err = readUe(nil)
sps.BitDepthLumaMinus8, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse BitDepthLumaMinus8")
}
sps.BitDepthChromaMinus8, err = readUe(nil)
sps.BitDepthChromaMinus8, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse BitDepthChromaMinus8")
}
@ -360,18 +360,18 @@ func NewSPS(rbsp []byte, showPacket bool) (*SPS, error) {
// showSPS()
// return sps
// Possibly wrong due to no scaling list being built
sps.Log2MaxFrameNumMinus4, err = readUe(nil)
sps.Log2MaxFrameNumMinus4, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse Log2MaxFrameNumMinus4")
}
sps.PicOrderCountType, err = readUe(nil)
sps.PicOrderCountType, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse PicOrderCountType")
}
if sps.PicOrderCountType == 0 {
sps.Log2MaxPicOrderCntLSBMin4, err = readUe(nil)
sps.Log2MaxPicOrderCntLSBMin4, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse Log2MaxPicOrderCntLSBMin4")
}
@ -382,23 +382,23 @@ func NewSPS(rbsp []byte, showPacket bool) (*SPS, error) {
}
sps.DeltaPicOrderAlwaysZero = b == 1
sps.OffsetForNonRefPic, err = readSe(nil)
sps.OffsetForNonRefPic, err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse OffsetForNonRefPic")
}
sps.OffsetForTopToBottomField, err = readSe(nil)
sps.OffsetForTopToBottomField, err = readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse OffsetForTopToBottomField")
}
sps.NumRefFramesInPicOrderCntCycle, err = readUe(nil)
sps.NumRefFramesInPicOrderCntCycle, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse NumRefFramesInPicOrderCntCycle")
}
for i := 0; i < sps.NumRefFramesInPicOrderCntCycle; i++ {
se, err := readSe(nil)
se, err := readSe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse OffsetForRefFrameList")
}
@ -409,7 +409,7 @@ func NewSPS(rbsp []byte, showPacket bool) (*SPS, error) {
}
sps.MaxNumRefFrames, err = readUe(nil)
sps.MaxNumRefFrames, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse MaxNumRefFrames")
}
@ -420,12 +420,12 @@ func NewSPS(rbsp []byte, showPacket bool) (*SPS, error) {
}
sps.GapsInFrameNumValueAllowed = b == 1
sps.PicWidthInMbsMinus1, err = readUe(nil)
sps.PicWidthInMbsMinus1, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse PicWidthInMbsMinus1")
}
sps.PicHeightInMapUnitsMinus1, err = readUe(nil)
sps.PicHeightInMapUnitsMinus1, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse PicHeightInMapUnitsMinus1")
}
@ -453,22 +453,22 @@ func NewSPS(rbsp []byte, showPacket bool) (*SPS, error) {
}
if sps.FrameCropping {
sps.FrameCropLeftOffset, err = readUe(nil)
sps.FrameCropLeftOffset, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse FrameCropLeftOffset")
}
sps.FrameCropRightOffset, err = readUe(nil)
sps.FrameCropRightOffset, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse FrameCropRightOffset")
}
sps.FrameCropTopOffset, err = readUe(nil)
sps.FrameCropTopOffset, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse FrameCropTopOffset")
}
sps.FrameCropBottomOffset, err = readUe(nil)
sps.FrameCropBottomOffset, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse FrameCropBottomOffset")
}
@ -573,12 +573,12 @@ func NewSPS(rbsp []byte, showPacket bool) (*SPS, error) {
sps.ChromaLocInfoPresent = b == 1
if sps.ChromaLocInfoPresent {
sps.ChromaSampleLocTypeTopField, err = readUe(nil)
sps.ChromaSampleLocTypeTopField, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ChromaSampleLocTypeTopField")
}
sps.ChromaSampleLocTypeBottomField, err = readUe(nil)
sps.ChromaSampleLocTypeBottomField, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse ChromaSampleLocTypeBottomField")
}
@ -651,32 +651,32 @@ func NewSPS(rbsp []byte, showPacket bool) (*SPS, error) {
}
sps.MotionVectorsOverPicBoundaries = b == 1
sps.MaxBytesPerPicDenom, err = readUe(nil)
sps.MaxBytesPerPicDenom, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse MaxBytesPerPicDenom")
}
sps.MaxBitsPerMbDenom, err = readUe(nil)
sps.MaxBitsPerMbDenom, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse MaxBitsPerMbDenom")
}
sps.Log2MaxMvLengthHorizontal, err = readUe(nil)
sps.Log2MaxMvLengthHorizontal, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse Log2MaxMvLengthHorizontal")
}
sps.Log2MaxMvLengthVertical, err = readUe(nil)
sps.Log2MaxMvLengthVertical, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse Log2MaxMvLengthVertical")
}
sps.MaxNumReorderFrames, err = readUe(nil)
sps.MaxNumReorderFrames, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse MaxNumReorderFrames")
}
sps.MaxDecFrameBuffering, err = readUe(nil)
sps.MaxDecFrameBuffering, err = readUe(br)
if err != nil {
return nil, errors.Wrap(err, "could not parse MaxDecFrameBuffering")
}