Documentation
¶
Overview ¶
Package nal writes and reads H.264 and H.265 NAL units: the bit writer and reader with the Exp-Golomb codes the syntax uses, the escaping of start-code-like byte runs and its removal, the parameter sets an encoder that does not write its own (VA-API's, given packed headers) puts in the stream, and the parsing of the parameter sets and slice headers a decoder that manages its own reference pictures (Vulkan Video's) needs.
Index ¶
- Constants
- Variables
- func AnnexB(units ...[]byte) []byte
- func AppendAnnexB(dst []byte, units ...[]byte) []byte
- func H264HighProfile(idc uint8) bool
- func H264RefIdc(unit []byte) uint8
- func H264SkipSlice(s *H264SPS, pps *H264PPS, frameNum, pocLsb uint32) []byte
- func H264Type(unit []byte) uint8
- func HEVCTemporalID(unit []byte) uint8
- func HEVCType(unit []byte) uint8
- func Unescape(dst, nal []byte) []byte
- type H264
- type H264MMCO
- type H264PPS
- type H264SPS
- type H264ScalingLists
- type H264SliceHeader
- type H264VUI
- type HEVC
- type HEVCLongTerm
- type HEVCPPS
- type HEVCProfileTierLevel
- type HEVCSPS
- type HEVCScalingLists
- type HEVCShortTermRPS
- type HEVCSliceHeader
- type HEVCSubLayerOrdering
- type HEVCVPS
- type HEVCVUI
- type Reader
- func (r *Reader) Flag() bool
- func (r *Reader) MoreRBSPData() bool
- func (r *Reader) Pos() int
- func (r *Reader) SE() int32
- func (r *Reader) Short() bool
- func (r *Reader) Skip(n int)
- func (r *Reader) U(n int) uint32
- func (r *Reader) U8(n int) uint8
- func (r *Reader) U16(n int) uint16
- func (r *Reader) UE() uint32
- type Writer
- func (w *Writer) AppendPacked(dst []byte, header ...byte) (out []byte, bits int)
- func (w *Writer) AppendUnit(dst []byte, header ...byte) []byte
- func (w *Writer) Flag(b bool)
- func (w *Writer) Reset()
- func (w *Writer) SE(v int32)
- func (w *Writer) SEInt(v int)
- func (w *Writer) Trailing()
- func (w *Writer) U(n uint, v uint32)
- func (w *Writer) UE(v uint32)
- func (w *Writer) UEInt(v int)
- func (w *Writer) UInt(n uint, v int)
- func (w *Writer) Unit(header ...byte) []byte
Constants ¶
const ( H264NALSlice = 1 H264NALIDR = 5 H264NALSPS = 7 H264NALPPS = 8 H264NALAUD = 9 )
The H.264 NAL unit types a decoder acts on (Table 7-1).
const ( H264SliceP = 0 H264SliceB = 1 H264SliceI = 2 H264SliceSP = 3 H264SliceSI = 4 )
The H.264 slice types, slice_type modulo 5 (Table 7-6).
const ( HEVCNALRADLN = 6 HEVCNALRASLN = 8 HEVCNALRASLR = 9 HEVCNALBLAWLP = 16 HEVCNALIDRWRAD = 19 HEVCNALIDRNLP = 20 HEVCNALCRA = 21 HEVCNALIRAPMax = 23 HEVCNALVPS = 32 HEVCNALSPS = 33 HEVCNALPPS = 34 HEVCNALAUD = 35 )
The H.265 NAL unit types a decoder acts on (Table 7-1).
const ( HEVCSliceB = 0 HEVCSliceP = 1 HEVCSliceI = 2 )
The H.265 slice types (Table 7-7).
const H264MaxMMCO = 66
H264MaxMMCO bounds the memory management control operations a slice header carries: one per reference frame and field, and two more.
const HEVCMaxSubLayers = 7
HEVCMaxSubLayers is the sub-layers a stream may have.
Variables ¶
var ErrH264 = errors.New("nal: H.264")
ErrH264 is an H.264 header a decoder cannot read: malformed, or using syntax outside what it decodes, which wraps ErrUnsupported too. Errors wrap it with what was read.
var ErrHEVC = errors.New("nal: H.265")
ErrHEVC is an H.265 header a decoder cannot read: malformed, or using syntax outside what it decodes, which wraps ErrUnsupported too. Errors wrap it with what was read.
var ErrUnsupported = errors.New("coding tools that are not decoded")
ErrUnsupported marks a header that is well formed and uses coding tools the parser does not read, beside the ErrH264 or ErrHEVC it wraps: an unsupported stream, where those alone are a malformed one.
Functions ¶
func AppendAnnexB ¶
AppendAnnexB appends AnnexB to dst.
func H264HighProfile ¶
H264HighProfile reports whether an SPS of profile_idc carries the chroma format, bit depth and scaling matrix syntax.
func H264SkipSlice ¶
H264SkipSlice is the NAL unit of one P slice covering a frame of s (frame_mbs_only) in which every macroblock is skipped, with the deblocking filter off: decoded, it copies the first picture of its reference list. A decoder makes one for each frame a gap in frame_num leaves non-existing (8.2.5.2), so the frame has a picture as a decoder that conceals the gap with the frame before has. pps is an H264SkipPPS of s; frameNum and pocLsb are the slice's frame_num and, for pic_order_cnt_type 0, its pic_order_cnt_lsb.
func HEVCTemporalID ¶
HEVCTemporalID is an H.265 NAL unit's TemporalId; unit is at least its two header bytes.
Types ¶
type H264 ¶
type H264 struct {
// ProfileIdc is 77 (Main) or 100 (High).
ProfileIdc uint8
// LevelIdc is the level times ten.
LevelIdc uint8
// WidthMbs and HeightMbs are the coded size in macroblocks.
WidthMbs, HeightMbs int
// CropRight and CropBottom crop the coded size back to the
// frame's, in pairs of pixels.
CropRight, CropBottom int
// Log2MaxFrameNum is log2 of MaxFrameNum.
Log2MaxFrameNum int
// MaxNumRefFrames is how many reference frames the stream keeps.
MaxNumRefFrames int
// CABAC is entropy_coding_mode_flag.
CABAC bool
// Transform8x8 is transform_8x8_mode_flag (High only).
Transform8x8 bool
// InitQP is the picture's initial quantiser, 26 + pic_init_qp_minus26.
InitQP int
}
H264 is what an H.264 stream's sequence and picture parameter sets say, for the streams the encoder writes: frames only, 4:2:0 at 8 bits, picture order count type 2 (output order is decode order), no reordering, BT.709 limited range.
func (*H264) AppendSliceHeader ¶
func (h *H264) AppendSliceHeader(dst []byte, w *Writer, sinceIDR int, idrPicID uint16, qp int) (out []byte, bits int)
AppendSliceHeader appends to dst the slice header (7.3.3) of the picture sinceIDR frames into its key interval, the idrPicID-th IDR when sinceIDR is 0, at quantiser qp: one I slice for the IDR, one P slice predicting from the picture before otherwise, the reference list and marking as the parameter sets imply. It is a packed unit (Writer.AppendPacked), stopping where the slice data starts, written through w, which it resets: with a w kept between frames and room in dst it allocates nothing.
type H264MMCO ¶
type H264MMCO struct {
Op uint8
DifferenceOfPicNumsMinus1 uint32
LongTermPicNum uint32
LongTermFrameIdx uint32
MaxLongTermFrameIdxPlus1 uint32
}
H264MMCO is one memory_management_control_operation and its arguments (7.3.3.3).
type H264PPS ¶
type H264PPS struct {
ID, SPSID uint8
EntropyCodingMode bool
BottomFieldPicOrderInFramePresent bool
NumRefIdxL0DefaultActiveMinus1 uint8
NumRefIdxL1DefaultActiveMinus1 uint8
WeightedPred bool
WeightedBipredIdc uint8
PicInitQpMinus26 int8
PicInitQsMinus26 int8
ChromaQpIndexOffset int8
DeblockingFilterControlPresent bool
ConstrainedIntraPred bool
RedundantPicCntPresent bool
Transform8x8Mode bool
ScalingMatrixPresent bool
SecondChromaQpIndexOffset int8
// Scaling are the picture's scaling lists, resolved against its
// SPS's: meaningful when ScalingMatrixPresent.
Scaling H264ScalingLists
}
H264PPS is a picture parameter set (7.3.2.2).
func H264SkipPPS ¶
H264SkipPPS is the picture parameter set H264SkipSlice's slices name: id, of SPS spsID, with CAVLC, one active reference, no weighted prediction and the deblocking filter control present.
type H264SPS ¶
type H264SPS struct {
ProfileIdc uint8
// Constraints are constraint_set0_flag to constraint_set5_flag and
// reserved_zero_2bits as coded: constraint_set0_flag in bit 7.
Constraints uint8
LevelIdc uint8
ID uint8
ChromaFormatIdc uint8
SeparateColourPlane bool
BitDepthLumaMinus8 uint8
BitDepthChromaMinus8 uint8
QpprimeYZeroTransformBypass bool
ScalingMatrixPresent bool
// Scaling are the sequence's scaling lists, flat when it has none.
Scaling H264ScalingLists
Log2MaxFrameNum uint8
PicOrderCntType uint8
Log2MaxPicOrderCntLsb uint8
DeltaPicOrderAlwaysZero bool
OffsetForNonRefPic int32
OffsetForTopToBottomField int32
NumRefFramesInPicOrderCntCycle uint8
OffsetForRefFrame [255]int32
MaxNumRefFrames uint8
GapsInFrameNumAllowed bool
// WidthMbs and HeightMapUnits are the coded size in macroblocks
// and map units (macroblock pairs in a stream of fields).
WidthMbs, HeightMapUnits int
FrameMbsOnly bool
MbAdaptiveFrameField bool
Direct8x8Inference bool
FrameCropping bool
// Crop is frame_crop_left, right, top and bottom_offset.
Crop [4]uint32
VUIPresent bool
VUI H264VUI
}
H264SPS is a sequence parameter set (7.3.2.1.1).
func (*H264SPS) ChromaArrayType ¶
ChromaArrayType is ChromaArrayType: 0 for monochrome or separately coded planes, else chroma_format_idc.
func (*H264SPS) FrameHeightMbs ¶
FrameHeightMbs is the frame's height in macroblocks.
type H264ScalingLists ¶
H264ScalingLists are the 4x4 and 8x8 scaling lists in the order the bitstream codes them (zig-zag), every list resolved: present, a default, or what the fall-back rules carry over.
type H264SliceHeader ¶
type H264SliceHeader struct {
FirstMbInSlice uint32
// SliceType is slice_type modulo 5.
SliceType uint8
PPSID uint8
FrameNum uint32
FieldPic, BottomField bool
IDRPicID uint16
PicOrderCntLsb uint32
DeltaPicOrderCntBottom int32
DeltaPicOrderCnt [2]int32
NoOutputOfPriorPics bool
LongTermReference bool
AdaptiveRefPicMarking bool
NumMMCO int
MMCO [H264MaxMMCO]H264MMCO
}
H264SliceHeader is what a slice header (7.3.3) says that a decoder managing the reference pictures uses.
func (*H264SliceHeader) Parse ¶
func (h *H264SliceHeader) Parse(rbsp []byte, header byte, pps *[256]*H264PPS, sps *[32]*H264SPS) error
Parse reads the slice header from rbsp, the slice NAL unit's payload after its header byte (unit[0]) with emulation prevention removed, as far as its reference picture marking: a prefix of the payload holding the header is enough. pps and sps are the parameter sets by ID.
func (*H264SliceHeader) ParseType ¶
func (h *H264SliceHeader) ParseType(rbsp []byte) error
ParseType reads only first_mb_in_slice, slice_type and pic_parameter_set_id: enough to tell a picture's slices apart.
type H264VUI ¶
type H264VUI struct {
AspectRatioInfoPresent bool
AspectRatioIdc uint8
SarWidth, SarHeight uint16
OverscanInfoPresent bool
OverscanAppropriate bool
VideoSignalTypePresent bool
VideoFormat uint8
FullRange bool
ColourDescriptionPresent bool
ColourPrimaries uint8
TransferCharacteristics uint8
MatrixCoefficients uint8
ChromaLocInfoPresent bool
ChromaSampleLocTypeTop uint8
ChromaSampleLocTypeBot uint8
TimingInfoPresent bool
NumUnitsInTick uint32
TimeScale uint32
FixedFrameRate bool
BitstreamRestriction bool
MaxNumReorderFrames uint8
MaxDecFrameBuffering uint8
}
H264VUI is what an SPS's video usability information says that a decoder uses.
type HEVC ¶
type HEVC struct {
// LevelIdc is the level times thirty.
LevelIdc uint8
// Width and Height are the coded size in luma samples.
Width, Height int
// ConfRight and ConfBottom crop the coded size back to the frame's,
// in chroma samples.
ConfRight, ConfBottom int
// Log2MaxPocLsb is log2 of MaxPicOrderCntLsb.
Log2MaxPocLsb int
// Log2MinCb, Log2Ctb, Log2MinTb and Log2MaxTb are the coding block,
// coding tree block and transform block sizes, as log2.
Log2MinCb, Log2Ctb, Log2MinTb, Log2MaxTb int
// TransformDepth is max_transform_hierarchy_depth, inter and intra.
TransformDepth int
// AMP, SAO and TemporalMVP are the SPS's tools of those names.
AMP, SAO, TemporalMVP bool
// InitQP is the picture's initial quantiser, 26 + init_qp_minus26.
InitQP int
// CuQPDelta is cu_qp_delta_enabled_flag, which rate control needs.
CuQPDelta bool
}
HEVC is what an H.265 stream's video, sequence and picture parameter sets say, for the streams the encoder writes: Main profile, frames only, one temporal layer, one short-term reference picture set (the picture before), no reordering, BT.709 limited range.
func (*HEVC) AppendSliceHeader ¶
func (h *HEVC) AppendSliceHeader(dst []byte, w *Writer, sinceIDR int, gpb bool, qp int) (out []byte, bits int)
AppendSliceHeader appends to dst the slice segment header (7.3.6.1) of the picture sinceIDR frames into its key interval at quantiser qp: one IDR_W_RADL I slice, or one TRAIL_R slice predicting from the picture before through the sequence's short-term reference set, a P slice or, with gpb, a B slice with the same picture in both lists. It ends byte-aligned, where the slice data starts, written through w, which it resets: with a w kept between frames and room in dst it allocates nothing.
type HEVCLongTerm ¶
type HEVCLongTerm struct {
PocLsb uint32
UsedByCurrPic bool
MsbPresent bool
DeltaPocMsbCycle uint32
}
HEVCLongTerm is one long-term reference picture a slice header names.
type HEVCPPS ¶
type HEVCPPS struct {
ID, SPSID uint8
DependentSliceSegments bool
OutputFlagPresent bool
NumExtraSliceHeaderBits uint8
SignDataHiding bool
CabacInitPresent bool
NumRefIdxL0DefaultActiveMinus1 uint8
NumRefIdxL1DefaultActiveMinus1 uint8
InitQpMinus26 int8
ConstrainedIntraPred bool
TransformSkipEnabled bool
CuQpDeltaEnabled bool
DiffCuQpDeltaDepth uint8
CbQpOffset, CrQpOffset int8
SliceChromaQpOffsetsPresent bool
WeightedPred, WeightedBipred bool
TransquantBypassEnabled bool
TilesEnabled bool
EntropyCodingSyncEnabled bool
NumTileColumnsMinus1 uint8
NumTileRowsMinus1 uint8
UniformSpacing bool
ColumnWidthMinus1 [19]uint16
RowHeightMinus1 [21]uint16
LoopFilterAcrossTiles bool
LoopFilterAcrossSlices bool
DeblockingFilterControlPresent bool
DeblockingFilterOverrideEnabled bool
DeblockingFilterDisabled bool
BetaOffsetDiv2, TcOffsetDiv2 int8
ScalingListDataPresent bool
// Scaling are the picture's coded lists: meaningful when
// ScalingListDataPresent.
Scaling HEVCScalingLists
ListsModificationPresent bool
Log2ParallelMergeLevelMinus2 uint8
SliceSegmentHeaderExtension bool
ExtensionPresent bool
RangeExtension bool
Log2MaxTransformSkipBlockMinus2 uint8
CrossComponentPrediction bool
ChromaQpOffsetListEnabled bool
DiffCuChromaQpOffsetDepth uint8
ChromaQpOffsetListLenMinus1 uint8
CbQpOffsetList, CrQpOffsetList [6]int8
Log2SaoOffsetScaleLuma uint8
Log2SaoOffsetScaleChroma uint8
}
HEVCPPS is a picture parameter set (7.3.2.3.1).
type HEVCProfileTierLevel ¶
type HEVCProfileTierLevel struct {
ProfileSpace uint8
Tier bool
ProfileIdc uint8
// Compatibility is general_profile_compatibility_flag, flag 0 in
// bit 31.
Compatibility uint32
Progressive bool
Interlaced bool
NonPacked bool
FrameOnly bool
LevelIdc uint8
}
HEVCProfileTierLevel is a profile_tier_level's general part (7.3.3).
type HEVCSPS ¶
type HEVCSPS struct {
VPSID uint8
MaxSubLayersMinus1 uint8
TemporalIDNesting bool
PTL HEVCProfileTierLevel
ID uint8
ChromaFormatIdc uint8
SeparateColourPlane bool
Width, Height int
ConformanceWindow bool
Conf [4]uint32
BitDepthLumaMinus8 uint8
BitDepthChromaMinus8 uint8
Log2MaxPocLsb uint8
SubLayerOrderingInfoPresent bool
Ordering HEVCSubLayerOrdering
Log2MinCbMinus3 uint8
Log2DiffMaxMinCb uint8
Log2MinTbMinus2 uint8
Log2DiffMaxMinTb uint8
MaxTransformDepthInter uint8
MaxTransformDepthIntra uint8
ScalingListEnabled bool
ScalingListDataPresent bool
// Scaling are the sequence's lists: coded, else the defaults.
Scaling HEVCScalingLists
AMP, SAO bool
PCM bool
PCMBitDepthLumaMinus1 uint8
PCMBitDepthChromaMinus1 uint8
Log2MinPCMCbMinus3 uint8
Log2DiffMaxMinPCMCb uint8
PCMLoopFilterDisabled bool
NumShortTermRPS uint8
ShortTermRPS [64]HEVCShortTermRPS
LongTermRefPicsPresent bool
NumLongTermRefPicsSPS uint8
LtRefPicPocLsbSPS [32]uint32
// UsedByCurrPicLtSPS marks entry i in bit i.
UsedByCurrPicLtSPS uint32
TemporalMVP bool
StrongIntraSmoothing bool
VUIPresent bool
VUI HEVCVUI
ExtensionPresent bool
RangeExtension bool
TransformSkipRotation bool
TransformSkipContext bool
ImplicitRDPCM bool
ExplicitRDPCM bool
ExtendedPrecision bool
IntraSmoothingDisabled bool
HighPrecisionOffsets bool
PersistentRiceAdaptation bool
CabacBypassAlignment bool
}
HEVCSPS is a sequence parameter set (7.3.2.2.1).
type HEVCScalingLists ¶
type HEVCScalingLists struct {
List4x4 [6][16]uint8
List8x8 [6][64]uint8
List16x16 [6][64]uint8
List32x32 [2][64]uint8
DC16x16 [6]uint8
DC32x32 [2]uint8
}
HEVCScalingLists are a scaling_list_data's lists in the order the bitstream codes them (up-right diagonal), every list resolved: coded, a default, or copied from the list it names. List32x32 holds matrices 0 and 3 of size 3.
func (*HEVCScalingLists) Defaults ¶
func (l *HEVCScalingLists) Defaults()
Defaults sets every list to its default: what a stream that enables scaling lists without coding them uses.
type HEVCShortTermRPS ¶
type HEVCShortTermRPS struct {
InterRPSPred bool
DeltaIdxMinus1 uint32
DeltaRPSSign bool
AbsDeltaRPSMinus1 uint32
// UsedByCurrPicFlag and UseDeltaFlag are the flags of each entry of
// the set it predicts from, entry j in bit j.
UsedByCurrPicFlag uint32
UseDeltaFlag uint32
NumNegative uint8
NumPositive uint8
DeltaPocS0 [16]int32
DeltaPocS1 [16]int32
// UsedS0 and UsedS1 mark the pictures the current one references,
// entry i in bit i.
UsedS0, UsedS1 uint16
}
HEVCShortTermRPS is a short-term reference picture set (st_ref_pic_set, 7.3.7): its syntax and the delta POCs it works out to (7.4.8).
func (*HEVCShortTermRPS) NumDeltaPocs ¶
func (s *HEVCShortTermRPS) NumDeltaPocs() int
NumDeltaPocs is how many pictures the set names.
type HEVCSliceHeader ¶
type HEVCSliceHeader struct {
FirstSliceSegmentInPic bool
NoOutputOfPriorPics bool
PPSID uint8
Dependent bool
SliceType uint8
PicOutput bool
PicOrderCntLsb uint32
ShortTermRefPicSetSPS bool
ShortTermRefPicSetIdx uint8
// RPS is the short-term set the header codes, STRPSBits its
// length.
RPS HEVCShortTermRPS
STRPSBits int
NumLongTermSPS uint8
NumLongTermPics uint8
LongTerm [32]HEVCLongTerm
}
HEVCSliceHeader is what a slice segment header (7.3.6.1) says that a decoder managing the reference pictures uses.
func (*HEVCSliceHeader) Parse ¶
func (h *HEVCSliceHeader) Parse(rbsp []byte, nalType uint8, pps *[64]*HEVCPPS, sps *[16]*HEVCSPS) error
Parse reads the first slice segment header of a picture from rbsp, the NAL unit's payload after its two header bytes with emulation prevention removed, as far as its reference pictures: a prefix of the payload holding them is enough. nalType is its nal_unit_type; pps and sps the parameter sets by ID.
func (*HEVCSliceHeader) ShortTermRPS ¶
func (h *HEVCSliceHeader) ShortTermRPS(s *HEVCSPS) *HEVCShortTermRPS
ShortTermRPS is the short-term reference picture set the slice uses.
type HEVCSubLayerOrdering ¶
type HEVCSubLayerOrdering struct {
MaxDecPicBufferingMinus1 [HEVCMaxSubLayers]uint8
MaxNumReorderPics [HEVCMaxSubLayers]uint8
MaxLatencyIncreasePlus1 [HEVCMaxSubLayers]uint32
}
HEVCSubLayerOrdering is the DPB size, reordering and latency of each sub-layer, the ones not coded filled in from the highest.
type HEVCVPS ¶
type HEVCVPS struct {
ID uint8
MaxSubLayersMinus1 uint8
TemporalIDNesting bool
PTL HEVCProfileTierLevel
SubLayerOrderingInfoPresent bool
Ordering HEVCSubLayerOrdering
TimingInfoPresent bool
NumUnitsInTick, TimeScale uint32
PocProportionalToTiming bool
NumTicksPocDiffOneMinus1 uint32
}
HEVCVPS is a video parameter set (7.3.2.1), as far as its timing.
type HEVCVUI ¶
type HEVCVUI struct {
AspectRatioInfoPresent bool
AspectRatioIdc uint8
SarWidth, SarHeight uint16
OverscanInfoPresent bool
OverscanAppropriate bool
VideoSignalTypePresent bool
VideoFormat uint8
FullRange bool
ColourDescriptionPresent bool
ColourPrimaries uint8
TransferCharacteristics uint8
MatrixCoeffs uint8
ChromaLocInfoPresent bool
ChromaSampleLocTypeTop uint8
ChromaSampleLocTypeBot uint8
NeutralChromaIndication bool
FieldSeq bool
FrameFieldInfoPresent bool
DefaultDisplayWindow bool
DefDispWin [4]uint16
TimingInfoPresent bool
NumUnitsInTick, TimeScale uint32
PocProportionalToTiming bool
NumTicksPocDiffOneMinus1 uint32
HRDParametersPresent bool
BitstreamRestriction bool
TilesFixedStructure bool
MotionVectorsOverPicBoundaries bool
RestrictedRefPicLists bool
MinSpatialSegmentationIdc uint16
MaxBytesPerPicDenom uint8
MaxBitsPerMinCuDenom uint8
Log2MaxMvLengthHorizontal uint8
Log2MaxMvLengthVertical uint8
}
HEVCVUI is what an SPS's video usability information says (E.2.1), its HRD parameters read past.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads an RBSP's bits, most significant first, with the Exp-Golomb codes the syntax uses. Reading past the end yields zeros and marks the reader Short, which a parser checks once at the end.
func (*Reader) MoreRBSPData ¶
MoreRBSPData is more_rbsp_data(): whether syntax remains before the RBSP's trailing bits, the last one bit and the zeros after it.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer collects a NAL unit's RBSP bits, most significant first.
func (*Writer) AppendPacked ¶
AppendPacked appends to dst the NAL unit of header bytes and the bits written so far for a driver to continue (a slice header before its slice data): escaped, its last byte zero-padded. It returns dst so grown and how many of the bits appended are the unit's.
func (*Writer) AppendUnit ¶
AppendUnit appends Unit to dst.
func (*Writer) Reset ¶
func (w *Writer) Reset()
Reset empties the writer for another unit, keeping its storage: a Writer kept between units writes them without allocating.
func (*Writer) SEInt ¶
SEInt writes v as se(v) where the syntax element is held as a Go int; a v outside int32 is a caller bug, and panics.
func (*Writer) Trailing ¶
func (w *Writer) Trailing()
Trailing writes rbsp_trailing_bits: a one, then zeros to the byte.
func (*Writer) UEInt ¶
UEInt writes v as ue(v) where the syntax element is held as a Go int; a v below 0 or above 2^32-2 is a caller bug, and panics.