Documentation
¶
Overview ¶
Package nal writes H.264 and H.265 NAL units: the bit writer with Exp-Golomb codes the syntax uses, the escaping of start-code-like byte runs, and the parameter sets an encoder that does not write its own (VA-API's, given packed headers) puts in the stream.
Index ¶
- func AnnexB(units ...[]byte) []byte
- type H264
- type HEVC
- type Writer
- func (w *Writer) Flag(b bool)
- func (w *Writer) Packed(header ...byte) (unit []byte, bits int)
- 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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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) SliceHeader ¶
SliceHeader is 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, stopping where the slice data starts.
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) SliceHeader ¶
SliceHeader is 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.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer collects a NAL unit's RBSP bits, most significant first.
func (*Writer) Packed ¶
Packed is 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, and how many of its bits are the unit's.
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.