h264

package
v0.0.0-...-25516b2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2019 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NaCtxId            = 10000
	NA_SUFFIX          = -1
	MbAddrNotAvailable = 10000
)
View Source
const (
	NALU_TYPE_UNSPECIFIED = iota
	NALU_TYPE_SLICE_NON_IDR_PICTURE
	NALU_TYPE_SLICE_PART_A
	NALU_TYPE_SLICE_PART_B
	NALU_TYPE_SLICE_PART_C
	NALU_TYPE_SLICE_IDR_PICTURE
	NALU_TYPE_SEI_SINFO
	NALU_TYPE_SPS
	NALU_TYPE_PPS
	NALU_TYPE_ACCESS_UNIT_DELIMITER
	NALU_TYPE_END_OF_SEQUENCE
	NALU_TYPE_END_OF_STREAM
	NALU_TYPE_FILLER_DATA
	NALU_TYPE_SPS_EXTENSIONS
	NALU_TYPE_PREFIX_NALU
	NALU_TYPE_SUBSET_SPS
	NALU_TYPE_DEPTH_PARAM_SET
)
View Source
const (
	PROFILE_IDC_BASELINE            = 66
	PROFILE_IDC_MAIN                = 77
	PROFILE_IDC_EXTENDED            = 88
	PROFILE_IDC_HIGH                = 100
	PROFILE_IDC_HIGH_10             = 110
	PROFILE_IDC_HIGH_422            = 122
	PROFILE_IDC_HIGH_444_PREDICTIVE = 244
)
View Source
const MB_TYPE_INFERRED = 1000
View Source
const NoCabacInitIdc = -1

Variables

View Source
var (

	// Table 9-36, 9-37
	MbBinIdx = []int{1, 2, 3, 4, 5, 6}

	// Table 9-38
	SubMbBinIdx = []int{0, 1, 2, 3, 4, 5}
)

Table 9-36, 9-37 func BinIdx(mbType int, sliceTypeName string) []int { Map of SliceTypeName[MbType][]int{binString} {"SliceTypeName": {MbTypeCode: []BinString}}

View Source
var (
	// Refer to ITU-T H.264 4/10/2017
	// Specifieds the RBSP structure in the NAL unit
	NALUnitType = map[int]string{
		0: "unspecified",

		1: "coded slice of non-IDR picture",

		2: "coded slice data partition a",

		3: "coded slice data partition b",

		4: "coded slice data partition c",

		5: "coded IDR slice of picture",

		6: "sei suppl. enhancem. info",

		7: "sequence parameter set",

		8: "picture parameter set",

		9: "access unit delimiter",

		10: "end of sequence",

		11: "end of stream",

		12: "filler data",

		13: "sequence parameter set extensions",

		14: "prefix NAL unit",

		15: "subset SPS",

		16: "depth parameter set",

		17: "reserved",
		18: "reserved",

		19: "coded slice of aux coded pic w/o partit.",

		20: "coded slice extension",

		21: "slice ext. for depth of view or 3Davc view comp.",
		22: "reserved",
		23: "reserved",
	}
	// ITU-T H.265 Section 7.4.1 nal_ref_idc
	NALRefIDC = map[int]string{
		0: "only nal_unit_type 6, 9, 10, 11, or 12",
		1: "anything",
		2: "anything",
		3: "anything",
		4: "anything",
	}
)
View Source
var (
	ISliceMbType = map[int]string{
		0:  "I_NxN",
		1:  "I_16x16_0_0_0",
		2:  "I_16x16_1_0_0",
		3:  "I_16x16_2_0_0",
		4:  "I_16x16_3_0_0",
		5:  "I_16x16_0_1_0",
		6:  "I_16x16_1_1_0",
		7:  "I_16x16_2_1_0",
		8:  "I_16x16_3_1_0",
		9:  "I_16x16_0_2_0",
		10: "I_16x16_1_2_0",
		11: "I_16x16_2_2_0",
		12: "I_16x16_3_2_0",
		13: "I_16x16_0_0_1",
		14: "I_16x16_1_0_1",
		15: "I_16x16_2_0_1",
		16: "I_16x16_3_0_1",
		17: "I_16x16_0_1_1",
		18: "I_16x16_1_1_1",
		19: "I_16x16_2_1_1",
		20: "I_16x16_3_1_1",
		21: "I_16x16_0_2_1",
		22: "I_16x16_1_2_1",
		23: "I_16x16_2_2_1",
		24: "I_16x16_3_2_1",
		25: "I_PCM",
	}
	SISliceMbType = map[int]string{
		0: "SI",
	}
	PSliceMbType = map[int]string{
		0:                "P_L0_16x16",
		1:                "P_L0_16x8",
		2:                "P_L0_L0_8x16",
		3:                "P_8x8",
		4:                "P_8x8ref0",
		MB_TYPE_INFERRED: "P_Skip",
	}
	BSliceMbType = map[int]string{
		0:                "B_Direct_16x16",
		1:                "B_L0_16x16",
		2:                "B_L1_16x16",
		3:                "B_Bi_16x16",
		4:                "B_L0_L0_16x8",
		5:                "B_L0_L0_8x16",
		6:                "B_L1_L1_16x8",
		7:                "B_L1_L1_8x16",
		8:                "B_L0_L1_16x8",
		9:                "B_L0_L1_8x16",
		10:               "B_L1_L0_16x8",
		11:               "B_L1_L0_8x16",
		12:               "B_L0_Bi_16x8",
		13:               "B_L0_Bi_8x16",
		14:               "B_L1_Bi_16x8",
		15:               "B_L1_Bi_8x16",
		16:               "B_Bi_L0_16x8",
		17:               "B_Bi_L0_8x16",
		18:               "B_Bi_l1_16x8",
		19:               "B_Bi_L1_8x16",
		20:               "B_Bi_Bi_16x8",
		21:               "B_Bi_Bi_8x16",
		22:               "B_8x8",
		MB_TYPE_INFERRED: "B_Skip",
	}
)
View Source
var (
	InitialNALU   = []byte{0, 0, 0, 1}
	Initial3BNALU = []byte{0, 0, 1}
)

InitialNALU indicates the start of a h264 packet 0 - Forbidden 0 bit; always 0 1,2 - NRI 3,4,5,6,7 - Type

View Source
var (
	DefaultScalingMatrix4x4 = [][]int{
		[]int{6, 13, 20, 28, 13, 20, 28, 32, 20, 28, 32, 37, 28, 32, 37, 42},
		[]int{10, 14, 20, 24, 14, 20, 24, 27, 20, 24, 27, 30, 24, 27, 30, 34},
	}

	DefaultScalingMatrix8x8 = [][]int{
		[]int{6, 10, 13, 16, 18, 23, 25, 27,
			10, 11, 16, 18, 23, 25, 27, 29,
			13, 16, 18, 23, 25, 27, 29, 31,
			16, 18, 23, 25, 27, 29, 31, 33,
			18, 23, 25, 27, 29, 31, 33, 36,
			23, 25, 27, 29, 31, 33, 36, 38,
			25, 27, 29, 31, 33, 36, 38, 40,
			27, 29, 31, 33, 36, 38, 40, 42},
		[]int{9, 13, 15, 17, 19, 21, 22, 24,
			13, 13, 17, 19, 21, 22, 24, 25,
			15, 17, 19, 21, 22, 24, 25, 27,
			17, 19, 21, 22, 24, 25, 27, 28,
			19, 21, 22, 24, 25, 27, 28, 30,
			21, 22, 24, 25, 27, 28, 30, 32,
			22, 24, 25, 27, 28, 30, 32, 33,
			24, 25, 27, 28, 30, 32, 33, 35},
	}
	Default4x4IntraList = []int{6, 13, 13, 20, 20, 20, 38, 38, 38, 38, 32, 32, 32, 37, 37, 42}
	Default4x4InterList = []int{10, 14, 14, 20, 20, 20, 24, 24, 24, 24, 27, 27, 27, 30, 30, 34}
	Default8x8IntraList = []int{
		6, 10, 10, 13, 11, 13, 16, 16, 16, 16, 18, 18, 18, 18, 18, 23,
		23, 23, 23, 23, 23, 25, 25, 25, 25, 25, 25, 25, 27, 27, 27, 27,
		27, 27, 27, 27, 29, 29, 29, 29, 29, 29, 29, 31, 31, 31, 31, 31,
		31, 33, 33, 33, 33, 33, 36, 36, 36, 36, 38, 38, 38, 40, 40, 42}
	Default8x8InterList = []int{
		9, 13, 13, 15, 13, 15, 17, 17, 17, 17, 19, 19, 19, 19, 19, 21,
		21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 24, 24, 24, 24,
		24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 27, 27, 27, 27, 27,
		27, 28, 28, 28, 28, 28, 30, 30, 30, 30, 32, 32, 32, 33, 33, 35}
	ScalingList4x4 = map[int][]int{
		0:  Default4x4IntraList,
		1:  Default4x4IntraList,
		2:  Default4x4IntraList,
		3:  Default4x4InterList,
		4:  Default4x4InterList,
		5:  Default4x4InterList,
		6:  Default8x8IntraList,
		7:  Default8x8InterList,
		8:  Default8x8IntraList,
		9:  Default8x8InterList,
		10: Default8x8IntraList,
		11: Default8x8InterList,
	}
	ScalingList8x8 = ScalingList4x4
)
View Source
var (
	// 0-39 : MB_Type
	// Maybe mapping all values in the range -128 to 128 to
	// a list of tuples for input vars would be less verbose
	// map[ctxIdx]MN
	MNVars = map[int]map[int]MN{
		0:  map[int]MN{NoCabacInitIdc: MN{20, -15}},
		1:  map[int]MN{NoCabacInitIdc: MN{2, 54}},
		2:  map[int]MN{NoCabacInitIdc: MN{3, 74}},
		3:  map[int]MN{NoCabacInitIdc: MN{20, -15}},
		4:  map[int]MN{NoCabacInitIdc: MN{2, 54}},
		5:  map[int]MN{NoCabacInitIdc: MN{3, 74}},
		6:  map[int]MN{NoCabacInitIdc: MN{-28, 127}},
		7:  map[int]MN{NoCabacInitIdc: MN{-23, 104}},
		8:  map[int]MN{NoCabacInitIdc: MN{-6, 53}},
		9:  map[int]MN{NoCabacInitIdc: MN{-1, 54}},
		10: map[int]MN{NoCabacInitIdc: MN{7, 51}},
		11: map[int]MN{
			0: MN{23, 33},
			1: MN{22, 25},
			2: MN{29, 16},
		},
		12: map[int]MN{
			0: MN{23, 2},
			1: MN{34, 0},
			2: MN{25, 0},
		},
		13: map[int]MN{
			0: MN{21, 0},
			1: MN{16, 0},
			2: MN{14, 0},
		},
		14: map[int]MN{
			0: MN{1, 9},
			1: MN{-2, 9},
			2: MN{-10, 51},
		},
		15: map[int]MN{
			0: MN{0, 49},
			1: MN{4, 41},
			2: MN{-3, 62},
		},
		16: map[int]MN{
			0: MN{-37, 118},
			1: MN{-29, 118},
			2: MN{-27, 99},
		},
		17: map[int]MN{
			0: MN{5, 57},
			1: MN{2, 65},
			2: MN{26, 16},
		},
		18: map[int]MN{
			0: MN{-13, 78},
			1: MN{-6, 71},
			2: MN{-4, 85},
		},
		19: map[int]MN{
			0: MN{-11, 65},
			1: MN{-13, 79},
			2: MN{-24, 102},
		},
		20: map[int]MN{
			0: MN{1, 62},
			1: MN{5, 52},
			2: MN{5, 57},
		},
		21: map[int]MN{
			0: MN{12, 49},
			1: MN{9, 50},
			2: MN{6, 57},
		},
		22: map[int]MN{
			0: MN{-4, 73},
			1: MN{-3, 70},
			2: MN{-17, 73},
		},
		23: map[int]MN{
			0: MN{17, 50},
			1: MN{10, 54},
			2: MN{14, 57},
		},

		24: map[int]MN{
			0: MN{18, 64},
			1: MN{26, 34},
			2: MN{20, 40},
		},
		25: map[int]MN{
			0: MN{9, 43},
			1: MN{19, 22},
			2: MN{20, 10},
		},
		26: map[int]MN{
			0: MN{29, 0},
			1: MN{40, 0},
			2: MN{29, 0},
		},
		27: map[int]MN{
			0: MN{26, 67},
			1: MN{57, 2},
			2: MN{54, 0},
		},
		28: map[int]MN{
			0: MN{16, 90},
			1: MN{41, 36},
			2: MN{37, 42},
		},
		29: map[int]MN{
			0: MN{9, 104},
			1: MN{26, 59},
			2: MN{12, 97},
		},
		30: map[int]MN{
			0: MN{-4, 127},
			1: MN{-4, 127},
			2: MN{-3, 127},
		},
		31: map[int]MN{
			0: MN{-2, 104},
			1: MN{-1, 101},
			2: MN{-2, 117},
		},
		32: map[int]MN{
			0: MN{1, 67},
			1: MN{-4, 76},
			2: MN{-2, 74},
		},
		33: map[int]MN{
			0: MN{-1, 78},
			1: MN{-6, 71},
			2: MN{-4, 85},
		},
		34: map[int]MN{
			0: MN{-1, 65},
			1: MN{-1, 79},
			2: MN{-2, 102},
		},
		35: map[int]MN{
			0: MN{1, 62},
			1: MN{5, 52},
			2: MN{5, 57},
		},
		36: map[int]MN{
			0: MN{-6, 86},
			1: MN{6, 69},
			2: MN{-6, 93},
		},
		37: map[int]MN{
			0: MN{-1, 95},
			1: MN{-1, 90},
			2: MN{-1, 88},
		},
		38: map[int]MN{
			0: MN{-6, 61},
			1: MN{0, 52},
			2: MN{-6, 44},
		},
		39: map[int]MN{
			0: MN{9, 45},
			1: MN{8, 43},
			2: MN{4, 55},
		},
	}
)

tables 9-12 to 9-13

View Source
var (
	ProfileIDC = map[int]string{
		PROFILE_IDC_BASELINE:            "Baseline",
		PROFILE_IDC_MAIN:                "Main",
		PROFILE_IDC_EXTENDED:            "Extended",
		PROFILE_IDC_HIGH:                "High",
		PROFILE_IDC_HIGH_10:             "High 10",
		PROFILE_IDC_HIGH_422:            "High 4:2:2",
		PROFILE_IDC_HIGH_444_PREDICTIVE: "High 4:4:4",
	}
)

Functions

func ByteStreamReader

func ByteStreamReader(connection net.Conn)

func Clip1y

func Clip1y(x, bitDepthY int) int

func Clip3

func Clip3(x, y, z int) int

5-5

func Clipc

func Clipc(x, bitDepthC int) int

func CodedBlockPatternChroma

func CodedBlockPatternChroma(data *SliceData) int

func CodedBlockPatternLuma

func CodedBlockPatternLuma(data *SliceData) int

7-36

func CondTermFlag

func CondTermFlag(mbAddr, mbSkipFlag int) int

func CtxIdx

func CtxIdx(binIdx, maxBinIdxCtx, ctxIdxOffset int) int

9.3.3.1 Returns ctxIdx

func CurrMbAddr

func CurrMbAddr(sps *SPS, header *SliceHeader) int

func DQId

func DQId(nalUnit *NalUnit) int

dependencyId see Annex G.8.8.1 Also G7.3.1.1 nal_unit_header_svc_extension

func Decoder9_3_3_1_1_1

func Decoder9_3_3_1_1_1(condTermFlagA, condTermFlagB int) int

9.3.3.1.1 : returns ctxIdxInc

func FrameHeightInMbs

func FrameHeightInMbs(sps *SPS) int

func MNSecond

func MNSecond(ctxIdx, cabacInitIdc int)

TODO: MNSecond determine when to provide second

func MapUnitToSliceGroupMap

func MapUnitToSliceGroupMap(sps *SPS, pps *PPS, header *SliceHeader) []int

8.2.2.1

func MbAddr

func MbAddr(xd, yd, predPartWidth int)

6.4.11.1

func MbHeightC

func MbHeightC(sps *SPS) int

func MbPartPredMode

func MbPartPredMode(data *SliceData, sliceType string, mbType, partition int) string

func MbPred

func MbPred(sliceContext *SliceContext, b *BitReader, rbsp []byte)

func MbToSliceGroupMap

func MbToSliceGroupMap(sps *SPS, pps *PPS, header *SliceHeader) []int

8.2.2

func MbTypeName

func MbTypeName(sliceType string, mbType int) string

func MbWidthC

func MbWidthC(sps *SPS) int

func MbaffFrameFlag

func MbaffFrameFlag(sps *SPS, header *SliceHeader) int

func NalUnitHeader3davcExtension

func NalUnitHeader3davcExtension(nalUnit *NalUnit, b *BitReader)

func NalUnitHeaderMvcExtension

func NalUnitHeaderMvcExtension(nalUnit *NalUnit, b *BitReader)

func NalUnitHeaderSvcExtension

func NalUnitHeaderSvcExtension(nalUnit *NalUnit, b *BitReader)

func NewRBSP

func NewRBSP(frame []byte) []byte

func NumMbPart

func NumMbPart(nalUnit *NalUnit, sps *SPS, header *SliceHeader, data *SliceData) int

Annex G p527

func PicHeightInMapUnits

func PicHeightInMapUnits(sps *SPS) int

func PicHeightInMbs

func PicHeightInMbs(sps *SPS, header *SliceHeader) int

func PicSizeInMapUnits

func PicSizeInMapUnits(sps *SPS) int

func PicSizeInMbs

func PicSizeInMbs(sps *SPS, header *SliceHeader) int

func PicWidthInMbs

func PicWidthInMbs(sps *SPS) int

func PreCtxState

func PreCtxState(m, n, sliceQPy int) int

9-5

func RefMbH

func RefMbH(chromaFlag, refLayerMbHeightC int) int

refLayerMbHeightC is equal to MbHeightC for the reference layer representation

func RefMbW

func RefMbW(chromaFlag, refLayerMbWidthC int) int

G.7.4.3.4 via G.7.3.3.4 via 7.3.2.13 for NalUnitType 20 or 21 refLayerMbWidthC is equal to MbWidthC for the reference layer representation

func SliceQPy

func SliceQPy(pps *PPS, header *SliceHeader) int

9-5 7-30 p 112

func SubHeightC

func SubHeightC(sps *SPS) int

func SubWidthC

func SubWidthC(sps *SPS) int

table 6-1

func XOffset

func XOffset(xRefMin16, refMbW int) int

func Xd

func Xd(xr, refMbW int) int

G.8.6.2.2.2

func Xr

func Xr(x, xOffset, refMbW int) int

G.8.6.2.2.2

func YOffset

func YOffset(yRefMin16, refMbH int) int

func Ya

func Ya(yd, refMbH, signYd int) int

func Yd

func Yd(yr, refMbH int) int

func Yr

func Yr(y, yOffset, refMbH int) int

Types

type ArithmeticDecoding

type ArithmeticDecoding struct {
	Context      *SliceContext
	Binarization *Binarization
	BinVal       int
}

func NewArithmeticDecoding

func NewArithmeticDecoding(context *SliceContext, binarization *Binarization, ctxIdx, codIRange, codIOffset int) ArithmeticDecoding

9.3.3.2: output is value of the bin

func (ArithmeticDecoding) BinaryDecision

func (a ArithmeticDecoding) BinaryDecision(ctxIdx, codIRange, codIOffset int) (int, int, int)

9.3.3.2.1 returns: binVal, updated codIRange, updated codIOffset

func (ArithmeticDecoding) DecodeBypass

func (a ArithmeticDecoding) DecodeBypass(sliceData *SliceData, codIRange, codIOffset int) (int, int)

9.3.3.2.3 Invoked when bypassFlag is equal to 1

func (ArithmeticDecoding) DecodeTerminate

func (a ArithmeticDecoding) DecodeTerminate(sliceData *SliceData, codIRange, codIOffset int) (int, int, int)

9.3.3.2.4 Decodes endOfSliceFlag and I_PCM Returns codIRange, codIOffSet, decoded value of binVal

func (ArithmeticDecoding) RenormD

func (a ArithmeticDecoding) RenormD(sliceData *SliceData, codIRange, codIOffset int) (int, int)

9.3.3.2.2 Renormalization process of ADecEngine Returns codIRange, codIOffset

type Binarization

type Binarization struct {
	SyntaxElement string
	BinarizationType
	MaxBinIdxCtx
	CtxIdxOffset
	UseDecodeBypass int
	// contains filtered or unexported fields
}

Table 9-34

func NewBinarization

func NewBinarization(syntaxElement string, data *SliceData) *Binarization

9.3.2.5

func (*Binarization) Decode

func (bin *Binarization) Decode(sliceContext *SliceContext, b *BitReader, rbsp []byte)

s9.3.3 p 278: Returns the value of the syntax element

func (*Binarization) IsBinStringMatch

func (b *Binarization) IsBinStringMatch(bits []int) bool

type BinarizationType

type BinarizationType struct {
	PrefixSuffix   bool
	FixedLength    bool
	Unary          bool
	TruncatedUnary bool
	CMax           bool
	// 9.3.2.3
	UEGk      bool
	CMaxValue int
}

type BitReader

type BitReader struct {
	Debug bool
	// contains filtered or unexported fields
}

func (*BitReader) Bytes

func (b *BitReader) Bytes() []byte

func (*BitReader) Fastforward

func (b *BitReader) Fastforward(bits int)

func (*BitReader) HasMoreData

func (b *BitReader) HasMoreData() bool

func (*BitReader) IsByteAligned

func (b *BitReader) IsByteAligned() bool

func (*BitReader) LogStreamPosition

func (b *BitReader) LogStreamPosition()

func (*BitReader) MoreRBSPData

func (b *BitReader) MoreRBSPData() bool

TODO: MoreRBSPData Section 7.2 p 62

func (*BitReader) NextField

func (b *BitReader) NextField(name string, bits int) int

func (*BitReader) PeekBytes

func (b *BitReader) PeekBytes(n int) ([]byte, error)

Get bytes without advancing

func (*BitReader) Read

func (b *BitReader) Read(buf []int) (int, error)

func (*BitReader) ReadByte

func (b *BitReader) ReadByte() (byte, error)

io.ByteReader interface

func (*BitReader) ReadBytes

func (b *BitReader) ReadBytes(n int) ([]byte, error)

func (*BitReader) ReadOneBit

func (b *BitReader) ReadOneBit() int

func (*BitReader) RewindBits

func (b *BitReader) RewindBits(n int) error

func (*BitReader) RewindBytes

func (b *BitReader) RewindBytes(n int) error

func (*BitReader) StreamPosition

func (b *BitReader) StreamPosition() (int, int, int)

type CABAC

type CABAC struct {
	PStateIdx int
	ValMPS    int
	Context   *SliceContext
}

func (*CABAC) StateTransitionProcess

func (c *CABAC) StateTransitionProcess(binVal int)

9.3.3.2.1.1 Returns: pStateIdx, valMPS

type CtxIdxOffset

type CtxIdxOffset struct {
	// When false, Prefix is the MaxBinIdxCtx
	IsPrefixSuffix bool
	Prefix, Suffix int
}

type H264Reader

type H264Reader struct {
	IsStarted    bool
	Stream       io.Reader
	NalUnits     []*BitReader
	VideoStreams []*VideoStream
	DebugFile    *os.File
	*BitReader
}

func (*H264Reader) BufferToReader

func (h *H264Reader) BufferToReader(cntBytes int) error

func (*H264Reader) Discard

func (h *H264Reader) Discard(cntBytes int) error

type MN

type MN struct {
	M, N int
}

func CodedblockPatternMN

func CodedblockPatternMN(ctxIdx, cabacInitIdc int, sliceType string) MN

Table 9-18 Coded block pattern (luma y chroma) map[ctxIdx][cabacInitIdc]MN

type MaxBinIdxCtx

type MaxBinIdxCtx struct {
	// When false, Prefix is the MaxBinIdxCtx
	IsPrefixSuffix bool
	Prefix, Suffix int
}

Table 9-34

type NalUnit

type NalUnit struct {
	NumBytes                     int
	ForbiddenZeroBit             int
	RefIdc                       int
	Type                         int
	SvcExtensionFlag             int
	Avc3dExtensionFlag           int
	IdrFlag                      int
	PriorityId                   int
	NoInterLayerPredFlag         int
	DependencyId                 int
	QualityId                    int
	TemporalId                   int
	UseRefBasePicFlag            int
	DiscardableFlag              int
	OutputFlag                   int
	ReservedThree2Bits           int
	HeaderBytes                  int
	NonIdrFlag                   int
	ViewId                       int
	AnchorPicFlag                int
	InterViewFlag                int
	ReservedOneBit               int
	ViewIdx                      int
	DepthFlag                    int
	EmulationPreventionThreeByte byte
	// contains filtered or unexported fields
}

func NewNalUnit

func NewNalUnit(frame []byte, numBytesInNal int) *NalUnit

func (*NalUnit) RBSP

func (n *NalUnit) RBSP() []byte

type PPS

type PPS struct {
	ID, SPSID                         int
	EntropyCodingMode                 int
	NumSliceGroupsMinus1              int
	BottomFieldPicOrderInFramePresent bool
	NumSlicGroupsMinus1               int
	SliceGroupMapType                 int
	RunLengthMinus1                   []int
	TopLeft                           []int
	BottomRight                       []int
	SliceGroupChangeDirection         bool
	SliceGroupChangeRateMinus1        int
	PicSizeInMapUnitsMinus1           int
	SliceGroupId                      []int
	NumRefIdxL0DefaultActiveMinus1    int
	NumRefIdxL1DefaultActiveMinus1    int
	WeightedPred                      bool
	WeightedBipred                    int
	PicInitQpMinus26                  int
	PicInitQsMinus26                  int
	ChromaQpIndexOffset               int
	DeblockingFilterControlPresent    bool
	ConstrainedIntraPred              bool
	RedundantPicCntPresent            bool
	Transform8x8Mode                  int
	PicScalingMatrixPresent           bool
	PicScalingListPresent             []bool
	SecondChromaQpIndexOffset         int
}

func NewPPS

func NewPPS(sps *SPS, rbsp []byte, showPacket bool) *PPS

type SPS

type SPS struct {
	// 8 bits
	Profile int
	// 6 bits
	Constraint0, Constraint1 int
	Constraint2, Constraint3 int
	Constraint4, Constraint5 int
	// 2 bit reserved 0 bits
	// 8 bits
	Level int
	// Range 0 - 31 ; 6 bits
	ID                         int
	ChromaFormat               int
	UseSeparateColorPlane      bool
	BitDepthLumaMinus8         int
	BitDepthChromaMinus8       int
	QPrimeYZeroTransformBypass bool
	SeqScalingMatrixPresent    bool
	// Delta is (0-12)-1 ; 4 bits
	SeqScalingList []bool // se
	// Range 0 - 12; 4 bits
	Log2MaxFrameNumMinus4 int
	// Range 0 - 2; 2 bits
	PicOrderCountType int
	// Range 0 - 12; 4 bits
	Log2MaxPicOrderCntLSBMin4 int
	DeltaPicOrderAlwaysZero   bool
	// Range (-2^31)+1 to (2^31)-1 ; 31 bits
	OffsetForNonRefPic int // Value - 1 (se)
	// Range (-2^31)+1 to (2^31)-1 ; 31 bits
	OffsetForTopToBottomField int // Value - 1 (se)
	// Range 0 - 255 ; 8 bits
	NumRefFramesInPicOrderCntCycle int
	// Range (-2^31)+1 to (2^31)-1 ; 31 bits
	OffsetForRefFrameList []int // Value - 1 ([]se)
	// Range 0 - MaxDpbFrames
	MaxNumRefFrames            int
	GapsInFrameNumValueAllowed bool
	// Page 77
	PicWidthInMbsMinus1 int
	// Page 77
	PicHeightInMapUnitsMinus1          int
	FrameMbsOnly                       bool
	MBAdaptiveFrameField               bool
	Direct8x8Inference                 bool
	FrameCropping                      bool
	FrameCropLeftOffset                int
	FrameCropRightOffset               int
	FrameCropTopOffset                 int
	FrameCropBottomOffset              int
	VuiParametersPresent               bool
	VuiParameters                      []int
	AspectRatioInfoPresent             bool
	AspectRatio                        int
	SarWidth                           int
	SarHeight                          int
	OverscanInfoPresent                bool
	OverscanAppropriate                bool
	VideoSignalTypePresent             bool
	VideoFormat                        int
	VideoFullRange                     bool
	ColorDescriptionPresent            bool
	ColorPrimaries                     int
	TransferCharacteristics            int
	MatrixCoefficients                 int
	ChromaLocInfoPresent               bool
	ChromaSampleLocTypeTopField        int
	ChromaSampleLocTypeBottomField     int
	CpbCntMinus1                       int
	BitRateScale                       int
	CpbSizeScale                       int
	BitRateValueMinus1                 []int
	Cbr                                []bool
	InitialCpbRemovalDelayLengthMinus1 int
	CpbRemovalDelayLengthMinus1        int
	CpbSizeValueMinus1                 []int
	DpbOutputDelayLengthMinus1         int
	TimeOffsetLength                   int
	TimingInfoPresent                  bool
	NumUnitsInTick                     int
	TimeScale                          int
	NalHrdParametersPresent            bool
	FixedFrameRate                     bool
	VclHrdParametersPresent            bool
	LowHrdDelay                        bool
	PicStructPresent                   bool
	BitstreamRestriction               bool
	MotionVectorsOverPicBoundaries     bool
	MaxBytesPerPicDenom                int
	MaxBitsPerMbDenom                  int
	Log2MaxMvLengthHorizontal          int
	Log2MaxMvLengthVertical            int
	MaxDecFrameBuffering               int
	MaxNumReorderFrames                int
}

Specification Page 43 7.3.2.1.1 Range is always inclusive XRange is always exclusive

func NewSPS

func NewSPS(rbsp []byte, showPacket bool) *SPS

type Slice

type Slice struct {
	Header *SliceHeader
	Data   *SliceData
}

type SliceContext

type SliceContext struct {
	*NalUnit
	*SPS
	*PPS
	*Slice
}

func NewSliceContext

func NewSliceContext(videoStream *VideoStream, nalUnit *NalUnit, rbsp []byte, showPacket bool) *SliceContext

func (*SliceContext) Update

func (c *SliceContext) Update(header *SliceHeader, data *SliceData)

type SliceData

type SliceData struct {
	BitReader                *BitReader
	CabacAlignmentOneBit     int
	MbSkipRun                int
	MbSkipFlag               bool
	MbFieldDecodingFlag      bool
	EndOfSliceFlag           bool
	MbType                   int
	MbTypeName               string
	SliceTypeName            string
	PcmAlignmentZeroBit      int
	PcmSampleLuma            []int
	PcmSampleChroma          []int
	TransformSize8x8Flag     bool
	CodedBlockPattern        int
	MbQpDelta                int
	PrevIntra4x4PredModeFlag []int
	RemIntra4x4PredMode      []int
	PrevIntra8x8PredModeFlag []int
	RemIntra8x8PredMode      []int
	IntraChromaPredMode      int
	RefIdxL0                 []int
	RefIdxL1                 []int
	MvdL0                    [][][]int
	MvdL1                    [][][]int
}

func NewSliceData

func NewSliceData(sliceContext *SliceContext, b *BitReader) *SliceData

type SliceHeader

type SliceHeader struct {
	FirstMbInSlice                   int
	SliceType                        int
	PPSID                            int
	ColorPlaneID                     int
	FrameNum                         int
	FieldPic                         bool
	BottomField                      bool
	IDRPicID                         int
	PicOrderCntLsb                   int
	DeltaPicOrderCntBottom           int
	DeltaPicOrderCnt                 []int
	RedundantPicCnt                  int
	DirectSpatialMvPred              bool
	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
	LumaLog2WeightDenom              int
	ChromaLog2WeightDenom            int
	ChromaArrayType                  int
	LumaWeightL0Flag                 bool
	LumaWeightL0                     []int
	LumaOffsetL0                     []int
	ChromaWeightL0Flag               bool
	ChromaWeightL0                   [][]int
	ChromaOffsetL0                   [][]int
	LumaWeightL1Flag                 bool
	LumaWeightL1                     []int
	LumaOffsetL1                     []int
	ChromaWeightL1Flag               bool
	ChromaWeightL1                   [][]int
	ChromaOffsetL1                   [][]int
	NoOutputOfPriorPicsFlag          bool
	LongTermReferenceFlag            bool
	AdaptiveRefPicMarkingModeFlag    bool
	MemoryManagementControlOperation int
	DifferenceOfPicNumsMinus1        int
	LongTermFrameIdx                 int
	MaxLongTermFrameIdxPlus1         int
}

type StateTransx

type StateTransx struct {
	TransIdxLPS, TransIdxMPS int
}

type VideoStream

type VideoStream struct {
	SPS    *SPS
	PPS    *PPS
	Slices []*SliceContext
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL