Documentation
¶
Overview ¶
Package decode defines the hardware video decoder contract shared by the platform backends: Media Foundation on Direct3D 11 (Windows) and VideoToolbox (macOS). Decoded pictures stay on the GPU.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoFrame = errors.New("decode: no picture for this access unit")
ErrNoFrame means the access unit produced no picture yet (the decoder needs more input). It is not a failure.
var ErrUnsupported = errors.New("decode: unsupported by this decoder")
ErrUnsupported means no hardware decoder takes this codec or format.
Functions ¶
Types ¶
type Backend ¶
type Backend struct {
Name string
Codec encode.Codec
Open func(t Target, cfg Config) (Decoder, error)
}
Backend opens a decoder for one codec on a Target.
type Config ¶
type Config struct {
Codec encode.Codec
Width, Height int
FPS int
// Chroma and ChunkLen describe a PyroWave stream: its sampling and
// depth, and the transport shard size its chunks are framed in.
Chroma encode.Chroma
ChunkLen int
// HDR10 says the pictures are BT.2020 PQ, for the sink that shows
// them; decoders ignore it.
HDR10 bool
}
Config is what the caller knows of the stream before the first access unit. Width and Height are hints; the bitstream's own size wins.
type Decoder ¶
type Decoder interface {
// Decode decodes one access unit (Annex B for HEVC, a temporal unit of
// OBUs for AV1) and returns its picture.
Decode(au []byte, pts int64) (Frame, error)
// Release gives a picture back to the decoder's pool.
Release(Frame)
Close() error
}
Decoder turns access units into GPU pictures.
type Finisher ¶
type Finisher interface {
Finish(f *Frame)
}
Finisher is a Decoder whose Decode returns before the GPU has written the picture, so that presenting it overlaps decoding. Finish blocks until the picture is written and sets f.Latency to the time from Decode's call, for callers that measure decoding.
type Frame ¶
type Frame struct {
// Surface is the picture: an ID3D11Texture2D* on Windows, an
// IOSurfaceRef on macOS.
Surface uintptr
// Slice is the array slice of Surface that holds the picture; Windows
// decoders write into texture arrays. 0 on macOS.
Slice int
// Format is NV12, P010 or BGRA8.
Format capture.Format
// Width and Height are the picture's visible size; the surface may be
// larger (coded size, aligned).
Width, Height int
PTS int64
// Latency is the time from Decode's call to the picture being ready.
Latency time.Duration
// Ref is the backend's handle that keeps Surface alive (an IMFSample*,
// a CVPixelBufferRef). Callers leave it alone.
Ref uintptr
}
Frame is a decoded picture owned by the decoder until Release.
type Target ¶
type Target struct {
// Device is an ID3D11Device* on Windows, an id<MTLDevice> on macOS.
Device uintptr
// Queue is the surface's id<MTLCommandQueue> on macOS, shared so decode
// and present run in order without a fence. 0 on Windows.
Queue uintptr
Adapter gpu.Adapter
}
Target is the GPU a decoder writes its pictures on: the presenting surface's, so pictures never leave it.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package d3d11 decodes HEVC and AV1 on the GPU of a Direct3D 11 device through a Media Foundation decoder transform made aware of the device (DXVA).
|
Package d3d11 decodes HEVC and AV1 on the GPU of a Direct3D 11 device through a Media Foundation decoder transform made aware of the device (DXVA). |
|
Package vt decodes HEVC and AV1 with Apple VideoToolbox through purego, with no cgo.
|
Package vt decodes HEVC and AV1 with Apple VideoToolbox through purego, with no cgo. |