vt

package
v0.2.0 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: 8 Imported by: ? 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

Rendered for darwin/amd64

Overview

Package vt drives Apple VideoToolbox hardware HEVC encode and decode through purego, with no cgo. Output and decode callbacks arrive on VideoToolbox's own threads and hand off to Go over channels.

Index

Constants

View Source
const (
	PixelBGRA = 0x42475241 // 'BGRA'
	Pixel420v = 0x34323076 // '420v' NV12 video range
	PixelX420 = 0x78343230 // 'x420' 10-bit 4:2:0 video range (P010 layout)
	PixelL10r = 0x6c313072 // 'l10r' ARGB 2:10:10:10 little endian
)

Variables

This section is empty.

Functions

func FillPixelBuffer

func FillPixelBuffer(pb uintptr, planes [][]byte, rowBytes []int)

FillPixelBuffer copies tightly packed planes into the buffer, row by row.

func HardwareDecode

func HardwareDecode() bool

HardwareDecode reports whether the GPU decodes HEVC.

func NewPixelBuffer

func NewPixelBuffer(w, h int, format uint32) (uintptr, error)

NewPixelBuffer allocates an IOSurface-backed CVPixelBuffer.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder is a hardware HEVC decompression session.

func NewDecoder

func NewDecoder(sample uintptr) (*Decoder, error)

NewDecoder opens a hardware decoder for the format of an encoded sample.

func (*Decoder) Close

func (d *Decoder) Close()

func (*Decoder) Decode

func (d *Decoder) Decode(sample uintptr) (int64, error)

Decode decodes one sample synchronously and returns when the decoded image callback fired, in mach-clock nanoseconds.

type Encoder

type Encoder struct {

	// Keep is set by callers that want the CMSampleBuffer of the last packet
	// (to feed a decoder); they release it.
	Keep       bool
	LastSample uintptr
	LastDone   int64
	LowLatency bool
	// contains filtered or unexported fields
}

func Open

func Open(cfg encode.Config) (*Encoder, error)

Open creates a hardware HEVC compression session. 4:4:4 is refused: Apple silicon exposes HEVC 4:2:0 and 4:2:2 only. Frames passed to Encode are CVPixelBuffers backed by IOSurfaces.

func (*Encoder) Caps

func (e *Encoder) Caps() encode.Caps

func (*Encoder) Close

func (e *Encoder) Close() error

func (*Encoder) Encode

func (e *Encoder) Encode(f capture.Frame, forceKey bool, dst []byte) (encode.Packet, error)

Encode submits a CVPixelBuffer (frame.Surface) and waits for its output.

func (*Encoder) SetBitrate

func (e *Encoder) SetBitrate(kbps int) error

Jump to

Keyboard shortcuts

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