mirror of https://bitbucket.org/ausocean/av.git
codec/h264/h264dec: fixed newRefPicListModification
This commit is contained in:
parent
3f1c09a671
commit
a94109e286
|
@ -37,11 +37,10 @@ type Slice struct {
|
||||||
// (defined in 7.3.3.1 of specifications) and a ref_pic_list_mvc_modification
|
// (defined in 7.3.3.1 of specifications) and a ref_pic_list_mvc_modification
|
||||||
// (defined in H.7.3.3.1.1 of specifications).
|
// (defined in H.7.3.3.1.1 of specifications).
|
||||||
type RefPicListModification struct {
|
type RefPicListModification struct {
|
||||||
RefPicListModificationFlagL0 bool
|
RefPicListModificationFlag [2]bool
|
||||||
ModificationOfPicNums int
|
ModificationOfPicNums [2][]int
|
||||||
AbsDiffPicNumMinus1 int
|
AbsDiffPicNumMinus1 [2][]int
|
||||||
LongTermPicNum int
|
LongTermPicNum [2][]int
|
||||||
RefPicListModificationFlagL1 bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: need to complete this.
|
// TODO: need to complete this.
|
||||||
|
@ -55,68 +54,57 @@ func NewRefPicListMVCModifiation(br *bits.BitReader) (*RefPicListModification, e
|
||||||
// NewRefPicListModification parses elements of a ref_pic_list_modification
|
// NewRefPicListModification parses elements of a ref_pic_list_modification
|
||||||
// following the syntax structure defined in section 7.3.3.1, and returns as
|
// following the syntax structure defined in section 7.3.3.1, and returns as
|
||||||
// a new RefPicListModification.
|
// a new RefPicListModification.
|
||||||
func NewRefPicListModification(br *bits.BitReader, h *SliceHeader) (*RefPicListModification, error) {
|
func NewRefPicListModification(br *bits.BitReader, p *PPS, s *SliceHeader) (*RefPicListModification, error) {
|
||||||
r := &RefPicListModification{}
|
r := &RefPicListModification{}
|
||||||
|
r.ModificationOfPicNums[0] = make([]int, p.NumRefIdxL0DefaultActiveMinus1+2)
|
||||||
|
r.ModificationOfPicNums[1] = make([]int, p.NumRefIdxL1DefaultActiveMinus1+2)
|
||||||
|
r.AbsDiffPicNumMinus1[0] = make([]int, p.NumRefIdxL1DefaultActiveMinus1+2)
|
||||||
|
r.AbsDiffPicNumMinus1[1] = make([]int, p.NumRefIdxL1DefaultActiveMinus1+2)
|
||||||
|
r.LongTermPicNum[0] = make([]int, p.NumRefIdxL1DefaultActiveMinus1+2)
|
||||||
|
r.LongTermPicNum[1] = make([]int, p.NumRefIdxL1DefaultActiveMinus1+2)
|
||||||
|
fr := newFieldReader(br)
|
||||||
|
|
||||||
// 7.3.3.1
|
// 7.3.3.1
|
||||||
if h.SliceType%5 != 2 && h.SliceType%5 != 4 {
|
if s.SliceType%5 != 2 && s.SliceType%5 != 4 {
|
||||||
b, err := br.ReadBits(1)
|
r.RefPicListModificationFlag[0] = fr.readBits(1) == 1
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "could not read RefPicListModificationFlagL0")
|
|
||||||
}
|
|
||||||
r.RefPicListModificationFlagL0 = b == 1
|
|
||||||
|
|
||||||
if r.RefPicListModificationFlagL0 {
|
if r.RefPicListModificationFlag[0] {
|
||||||
for r.ModificationOfPicNums != 3 {
|
for i := 0; ; i++ {
|
||||||
r.ModificationOfPicNums, err = readUe(br)
|
r.ModificationOfPicNums[0][i] = fr.readUe()
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "could not parse ModificationOfPicNums")
|
if r.ModificationOfPicNums[0][i] == 0 || r.ModificationOfPicNums[0][i] == 1 {
|
||||||
|
r.AbsDiffPicNumMinus1[0][i] = fr.readUe()
|
||||||
|
} else if r.ModificationOfPicNums[0][i] == 2 {
|
||||||
|
r.LongTermPicNum[0][i] = fr.readUe()
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.ModificationOfPicNums == 0 || r.ModificationOfPicNums == 1 {
|
if r.ModificationOfPicNums[0][i] == 3 {
|
||||||
r.AbsDiffPicNumMinus1, err = readUe(br)
|
break
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "could not parse AbsDiffPicNumMinus1")
|
|
||||||
}
|
|
||||||
} else if r.ModificationOfPicNums == 2 {
|
|
||||||
r.LongTermPicNum, err = readUe(br)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "could not parse LongTermPicNum")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
if s.SliceType%5 == 1 {
|
||||||
if h.SliceType%5 == 1 {
|
r.RefPicListModificationFlag[1] = fr.readBits(1) == 1
|
||||||
b, err := br.ReadBits(1)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "could not read RefPicListModificationFlagL1")
|
|
||||||
}
|
|
||||||
r.RefPicListModificationFlagL1 = b == 1
|
|
||||||
|
|
||||||
if r.RefPicListModificationFlagL1 {
|
if r.RefPicListModificationFlag[1] {
|
||||||
for r.ModificationOfPicNums != 3 {
|
for i := 0; ; i++ {
|
||||||
r.ModificationOfPicNums, err = readUe(br)
|
r.ModificationOfPicNums[1][i] = fr.readUe()
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "could not parse ModificationOfPicNums")
|
if r.ModificationOfPicNums[1][i] == 0 || r.ModificationOfPicNums[1][i] == 1 {
|
||||||
|
r.AbsDiffPicNumMinus1[1][i] = fr.readUe()
|
||||||
|
} else if r.ModificationOfPicNums[1][i] == 2 {
|
||||||
|
r.LongTermPicNum[1][i] = fr.readUe()
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.ModificationOfPicNums == 0 || r.ModificationOfPicNums == 1 {
|
if r.ModificationOfPicNums[1][i] == 3 {
|
||||||
r.AbsDiffPicNumMinus1, err = readUe(br)
|
break
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "could not parse AbsDiffPicNumMinus1")
|
|
||||||
}
|
|
||||||
} else if r.ModificationOfPicNums == 2 {
|
|
||||||
r.LongTermPicNum, err = readUe(br)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "could not parse LongTermPicNum")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return r, nil
|
||||||
// refPicListModification()
|
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PredWeightTable provides elements of a pred_weight_table syntax structure
|
// PredWeightTable provides elements of a pred_weight_table syntax structure
|
||||||
|
@ -262,6 +250,7 @@ type DecRefPicMarking struct {
|
||||||
AdaptiveRefPicMarkingModeFlag bool
|
AdaptiveRefPicMarkingModeFlag bool
|
||||||
MemoryManagementControlOperation int
|
MemoryManagementControlOperation int
|
||||||
DifferenceOfPicNumsMinus1 int
|
DifferenceOfPicNumsMinus1 int
|
||||||
|
LongTermPicNum int
|
||||||
LongTermFrameIdx int
|
LongTermFrameIdx int
|
||||||
MaxLongTermFrameIdxPlus1 int
|
MaxLongTermFrameIdxPlus1 int
|
||||||
}
|
}
|
||||||
|
@ -303,7 +292,7 @@ func NewDecRefPicMarking(br *bits.BitReader, idrPic bool, h *SliceHeader) (*DecR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if d.MemoryManagementControlOperation == 2 {
|
if d.MemoryManagementControlOperation == 2 {
|
||||||
h.RefPicListModification.LongTermPicNum, err = readUe(br)
|
d.LongTermPicNum, err = readUe(br)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not parse LongTermPicNum")
|
return nil, errors.Wrap(err, "could not parse LongTermPicNum")
|
||||||
}
|
}
|
||||||
|
@ -1345,7 +1334,7 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NALUnit, rbsp []byte, sh
|
||||||
// H.7.3.3.1.1
|
// H.7.3.3.1.1
|
||||||
// refPicListMvcModifications()
|
// refPicListMvcModifications()
|
||||||
} else {
|
} else {
|
||||||
header.RefPicListModification, err = NewRefPicListModification(br, &header)
|
header.RefPicListModification, err = NewRefPicListModification(br, pps, &header)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not parse RefPicListModification")
|
return nil, errors.Wrap(err, "could not parse RefPicListModification")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue