codec/h264/decode: added ThreeDAVCExtenstion type and NewThreeDAVCExtension function

This commit is contained in:
Saxon 2019-07-19 17:50:45 +09:30
parent 0d9861c49e
commit e54bc234c8
1 changed files with 47 additions and 19 deletions

View File

@ -13,18 +13,57 @@ type NalUnit struct {
SvcExtensionFlag int SvcExtensionFlag int
Avc3dExtensionFlag int Avc3dExtensionFlag int
SVCExtension *SVCExtension SVCExtension *SVCExtension
HeaderBytes int ThreeDAVCExtension *ThreeDAVCExtension
NonIdrFlag int
ViewId int
AnchorPicFlag int
InterViewFlag int
ReservedOneBit int
ViewIdx int
DepthFlag int
EmulationPreventionThreeByte byte EmulationPreventionThreeByte byte
rbsp []byte rbsp []byte
} }
type ThreeDAVCExtension struct {
ViewIdx int
DepthFlag bool
NonIdrFlag bool
TemporalID int
AnchorPicFlag bool
InterViewFlag bool
}
func NewThreeDAVCExtension(br *bits.BitReader) (*ThreeDAVCExtension, error) {
e := &ThreeDAVCExtension{}
var err error
e.ViewIdx, err = br.ReadBitsInt(8)
if err != nil {
return nil, errors.Wrap(err, "could not read ViewIdx")
}
e.DepthFlag, err = br.ReadBool()
if err != nil {
return nil, errors.Wrap(err, "could not read DepthFlag")
}
e.NonIdrFlag, err = br.ReadBool()
if err != nil {
return nil, errors.Wrap(err, "could not read NonIdrFlag")
}
e.TemporalID, err = br.ReadBitsInt(3)
if err != nil {
return nil, errors.Wrap(err, "could not read TemporalId")
}
e.AnchorPicFlag, err = br.ReadBool()
if err != nil {
return nil, errors.Wrap(err, "could not read AnchorPicFlag")
}
e.InterViewFlag, err = br.ReadBool()
if err != nil {
return nil, errors.Wrap(err, "could not read InterViewFlag")
}
return e, nil
}
type SVCExtension struct { type SVCExtension struct {
IdrFlag bool IdrFlag bool
PriorityId int PriorityId int
@ -95,17 +134,6 @@ func NewSVCExtension(br *bits.BitReader) (*SVCExtension, error) {
return e, nil return e, nil
} }
func NalUnitHeader3davcExtension(nalUnit *NalUnit, br *bits.BitReader) error {
return readFields(br, []field{
{&nalUnit.ViewIdx, "ViewIdx", 8},
{&nalUnit.DepthFlag, "DepthFlag", 1},
{&nalUnit.NonIdrFlag, "NonIdrFlag", 1},
{&nalUnit.TemporalId, "TemporalId", 3},
{&nalUnit.AnchorPicFlag, "AnchorPicFlag", 1},
{&nalUnit.InterViewFlag, "InterViewFlag", 1},
})
}
func NalUnitHeaderMvcExtension(nalUnit *NalUnit, br *bits.BitReader) error { func NalUnitHeaderMvcExtension(nalUnit *NalUnit, br *bits.BitReader) error {
return readFields(br, []field{ return readFields(br, []field{
{&nalUnit.NonIdrFlag, "NonIdrFlag", 1}, {&nalUnit.NonIdrFlag, "NonIdrFlag", 1},