mirror of https://bitbucket.org/ausocean/av.git
codec/h264/h264dec: created RefPicListModification type with constructors and separated from SliceHeader type
This commit is contained in:
parent
269b607606
commit
47d0c300fc
|
@ -32,6 +32,93 @@ type Slice struct {
|
|||
Header *SliceHeader
|
||||
Data *SliceData
|
||||
}
|
||||
|
||||
// RefPicListModification provides elements of a ref_pic_list_modification syntax
|
||||
// (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).
|
||||
type RefPicListModification struct {
|
||||
RefPicListModificationFlagL0 bool
|
||||
ModificationOfPicNums int
|
||||
AbsDiffPicNumMinus1 int
|
||||
LongTermPicNum int
|
||||
RefPicListModificationFlagL1 bool
|
||||
}
|
||||
|
||||
// TODO: need to complete this.
|
||||
// NewRefPicListMVCModification parses elements of a ref_pic_list_mvc_modification
|
||||
// following the syntax structure defined in section H.7.3.3.1.1, and returns as
|
||||
// a new RefPicListModification.
|
||||
func NewRefPicListMVCModifiation(br *bits.BitReader) (*RefPicListModification, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewRefPicListModification parses elements of a ref_pic_list_modification
|
||||
// following the syntax structure defined in section 7.3.3.1, and returns as
|
||||
// a new RefPicListModification.
|
||||
func NewRefPicListModification(br *bits.BitReader, h *SliceHeader) (*RefPicListModification, error) {
|
||||
r := &RefPicListModification{}
|
||||
// 7.3.3.1
|
||||
if h.SliceType%5 != 2 && h.SliceType%5 != 4 {
|
||||
b, err := br.ReadBits(1)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not read RefPicListModificationFlagL0")
|
||||
}
|
||||
r.RefPicListModificationFlagL0 = b == 1
|
||||
|
||||
if r.RefPicListModificationFlagL0 {
|
||||
for r.ModificationOfPicNums != 3 {
|
||||
r.ModificationOfPicNums, err = readUe(br)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse ModificationOfPicNums")
|
||||
}
|
||||
|
||||
if r.ModificationOfPicNums == 0 || r.ModificationOfPicNums == 1 {
|
||||
r.AbsDiffPicNumMinus1, err = readUe(br)
|
||||
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 h.SliceType%5 == 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 {
|
||||
for r.ModificationOfPicNums != 3 {
|
||||
r.ModificationOfPicNums, err = readUe(br)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse ModificationOfPicNums")
|
||||
}
|
||||
|
||||
if r.ModificationOfPicNums == 0 || r.ModificationOfPicNums == 1 {
|
||||
r.AbsDiffPicNumMinus1, err = readUe(br)
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// refPicListModification()
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type SliceHeader struct {
|
||||
FirstMbInSlice int
|
||||
SliceType int
|
||||
|
@ -49,19 +136,9 @@ type SliceHeader struct {
|
|||
NumRefIdxActiveOverride bool
|
||||
NumRefIdxL0ActiveMinus1 int
|
||||
NumRefIdxL1ActiveMinus1 int
|
||||
CabacInit int
|
||||
SliceQpDelta int
|
||||
SpForSwitch bool
|
||||
SliceQsDelta int
|
||||
DisableDeblockingFilter int
|
||||
SliceAlphaC0OffsetDiv2 int
|
||||
SliceBetaOffsetDiv2 int
|
||||
SliceGroupChangeCycle int
|
||||
RefPicListModificationFlagL0 bool
|
||||
ModificationOfPicNums int
|
||||
AbsDiffPicNumMinus1 int
|
||||
LongTermPicNum int
|
||||
RefPicListModificationFlagL1 bool
|
||||
RefPicListModification *RefPicListModification
|
||||
|
||||
// pred_weight_table
|
||||
LumaLog2WeightDenom int
|
||||
ChromaLog2WeightDenom int
|
||||
ChromaArrayType int
|
||||
|
@ -77,6 +154,8 @@ type SliceHeader struct {
|
|||
ChromaWeightL1Flag bool
|
||||
ChromaWeightL1 [][]int
|
||||
ChromaOffsetL1 [][]int
|
||||
|
||||
// dec_ref_pic_marking
|
||||
NoOutputOfPriorPicsFlag bool
|
||||
LongTermReferenceFlag bool
|
||||
AdaptiveRefPicMarkingModeFlag bool
|
||||
|
@ -84,6 +163,15 @@ type SliceHeader struct {
|
|||
DifferenceOfPicNumsMinus1 int
|
||||
LongTermFrameIdx int
|
||||
MaxLongTermFrameIdxPlus1 int
|
||||
|
||||
CabacInit int
|
||||
SliceQpDelta int
|
||||
SpForSwitch bool
|
||||
SliceQsDelta int
|
||||
DisableDeblockingFilter int
|
||||
SliceAlphaC0OffsetDiv2 int
|
||||
SliceBetaOffsetDiv2 int
|
||||
SliceGroupChangeCycle int
|
||||
}
|
||||
|
||||
type SliceData struct {
|
||||
|
@ -1075,65 +1163,10 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
|
|||
// H.7.3.3.1.1
|
||||
// refPicListMvcModifications()
|
||||
} else {
|
||||
// 7.3.3.1
|
||||
if header.SliceType%5 != 2 && header.SliceType%5 != 4 {
|
||||
b, err := br.ReadBits(1)
|
||||
header.RefPicListModification, err = NewRefPicListModification(br, &header)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not read RefPicListModificationFlagL0")
|
||||
return nil, errors.Wrap(err, "could not parse RefPicListModification")
|
||||
}
|
||||
header.RefPicListModificationFlagL0 = b == 1
|
||||
|
||||
if header.RefPicListModificationFlagL0 {
|
||||
for header.ModificationOfPicNums != 3 {
|
||||
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(br)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse AbsDiffPicNumMinus1")
|
||||
}
|
||||
} else if header.ModificationOfPicNums == 2 {
|
||||
header.LongTermPicNum, err = readUe(br)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse LongTermPicNum")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if header.SliceType%5 == 1 {
|
||||
b, err := br.ReadBits(1)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not read RefPicListModificationFlagL1")
|
||||
}
|
||||
header.RefPicListModificationFlagL1 = b == 1
|
||||
|
||||
if header.RefPicListModificationFlagL1 {
|
||||
for header.ModificationOfPicNums != 3 {
|
||||
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(br)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse AbsDiffPicNumMinus1")
|
||||
}
|
||||
} else if header.ModificationOfPicNums == 2 {
|
||||
header.LongTermPicNum, err = readUe(br)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse LongTermPicNum")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// refPicListModification()
|
||||
}
|
||||
|
||||
if (pps.WeightedPred && (sliceType == "P" || sliceType == "SP")) || (pps.WeightedBipred == 1 && sliceType == "B") {
|
||||
|
@ -1278,7 +1311,7 @@ func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, sh
|
|||
}
|
||||
}
|
||||
if header.MemoryManagementControlOperation == 2 {
|
||||
header.LongTermPicNum, err = readUe(br)
|
||||
header.RefPicListModification.LongTermPicNum, err = readUe(br)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not parse LongTermPicNum")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue