hevc

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hevc holds the HEVC (H.265) bitstream helpers the containers share: parameter-set NAL units, the sequence parameter set fields a decoder configuration repeats, and the hvcC decoder configuration record (ISO/IEC 14496-15, 8.3.3). Inside goav, HEVC packets travel as Annex B, as H.264 ones do (see internal/h264).

Index

Constants

View Source
const (
	NALVPS = 32
	NALSPS = 33
	NALPPS = 34
)

The parameter-set NAL unit types.

Variables

View Source
var ErrInvalid = errors.New("hevc: invalid bitstream")

ErrInvalid reports a malformed parameter set or hvcC record.

Functions

func CompleteConfig

func CompleteConfig(record []byte) ([]byte, error)

CompleteConfig returns a copy of record as an hvc1 sample entry carries it, whose samples hold no parameter sets: 4-byte NAL lengths, and the parameter-set arrays marked complete.

func ConfigFromAnnexB

func ConfigFromAnnexB(data []byte) ([]byte, error)

ConfigFromAnnexB builds a complete hvcC record, with 4-byte NAL lengths, from the VPS, SPS, and PPS that Annex B data (a keyframe, or extradata) carries; the profile, tier, level, chroma format, and bit depths come from the first SPS.

func NALType

func NALType(nal []byte) byte

NALType is the type of a NAL unit, read from its two-byte header.

func ParameterSet

func ParameterSet(nalType byte) bool

ParameterSet reports a VPS, SPS, or PPS NAL unit type.

Types

type Config

type Config struct {
	// LengthSize is the byte width (1, 2, or 4) of each NAL length prefix.
	LengthSize int
	// ParameterSets are the record's VPS, SPS, and PPS units, aliasing it.
	ParameterSets [][]byte
}

Config is what the conversions need from an hvcC record.

func ParseConfig

func ParseConfig(record []byte) (Config, error)

ParseConfig parses an hvcC record.

type SPS

type SPS struct {
	// ProfileTierLevel is the general profile, tier, and level: the 12
	// bytes an hvcC record copies.
	ProfileTierLevel [12]byte
	TemporalLayers   byte
	TemporalIDNested byte
	// ChromaFormat is chroma_format_idc: 0 monochrome, 1 4:2:0, 2 4:2:2,
	// 3 4:4:4.
	ChromaFormat           byte
	LumaDepth, ChromaDepth byte
	// Width and Height are the picture size after the conformance window.
	Width, Height int
}

SPS is what a decoder configuration repeats from a sequence parameter set, and the picture size it declares.

func ParseSPS

func ParseSPS(nal []byte) (SPS, error)

ParseSPS reads an SPS NAL unit (H.265 7.3.2.2) up to its bit depths.

Jump to

Keyboard shortcuts

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