Documentation
¶
Overview ¶
Package dovi reads Dolby Vision metadata without decoding video pictures.
Index ¶
- Variables
- func NitsToPQ(n float64) (float64, error)
- func PQToNits(p float64) (float64, error)
- func Render(ctx context.Context, a *Analysis, o PlotOptions) (image.Image, error)
- type ActiveAreaRange
- type Analysis
- type AnalysisOptions
- type BaseDM
- type Block
- type Counts
- type Coverage
- type DM
- type EnhancementInventory
- type Header
- type Inventory
- type L1
- type L1Statistics
- type L5
- type L6
- type Mastering
- type MasteringL6
- type MetadataInventory
- type ParseError
- type ParseOptions
- type Picture
- type PlotOptions
- type RPU
- type Raster
- type StreamKey
- type Summary
- type SummaryOptions
- type Timeline
- type Timestamp
- type TrimTarget
- type Warning
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidBitstream = errors.New("invalid Dolby Vision bitstream") ErrUnsupported = errors.New("unsupported syntax or input") ErrIncomplete = errors.New("incomplete input") ErrLimit = errors.New("resource limit exceeded") ErrNoL1 = errors.New("no L1 metadata") ErrInvalidMetadata = errors.New("invalid caller metadata") ErrInvalidOptions = errors.New("invalid options") )
Functions ¶
func Render ¶
Render returns an opaque 3000×1200 dovi_tool-style L1 plot in PQ coordinates. Missing samples remain gaps rather than synthetic brightness measurements.
Example ¶
package main
import (
"bytes"
"context"
"fmt"
dovi "github.com/Audionut/go-dovi-extract"
"github.com/Audionut/go-dovi-extract/extract"
f "github.com/Audionut/go-dovi-extract/internal/testfixture"
"image/png"
)
func main() {
ctx := context.Background()
e, err := extract.ReadRPU(ctx, bytes.NewReader(f.File(f.Options{Max: 3000, Avg: 1500})), extract.Options{})
if err != nil {
panic(err)
}
a, err := e.Analysis(dovi.AnalysisOptions{})
if err != nil {
panic(err)
}
s, err := dovi.Summarize(a, dovi.SummaryOptions{})
if err != nil {
panic(err)
}
img, err := dovi.Render(ctx, a, dovi.PlotOptions{})
if err != nil {
panic(err)
}
var encoded bytes.Buffer
if err := png.Encode(&encoded, img); err != nil {
panic(err)
}
fmt.Println(s.Coverage, img.Bounds().Dx(), img.Bounds().Dy())
}
Output: unknown 3000 1200
Types ¶
type ActiveAreaRange ¶
type ActiveAreaRange struct {
Start, End uint64
Offsets *L5
Geometry string
ActiveWidth, ActiveHeight uint32
CoordinateBasis string
}
ActiveAreaRange is an inclusive interval of original timeline indices with equal L5 offsets. Nil Offsets means missing metadata; active dimensions require an applicable Raster.
type Analysis ¶
type Analysis struct {
SchemaVersion int `json:"schema_version"`
Timeline Timeline `json:"timeline"`
Complete bool `json:"complete"`
TrackID uint64 `json:"track_id"`
Records []RPU `json:"records"`
Pictures []Picture `json:"pictures"`
ObservedRPUs uint64 `json:"observed_rpus"`
SuppressedRPUs uint64 `json:"suppressed_rpus"`
}
Analysis is a complete, owned metadata timeline: schema 1 for files and RPU sequences, schema 2 for playlist frames. Counts and inventories are derived by Summarize, never trusted from a serialized report. Standalone sequences have no Pictures. Raw bytes are intentionally separate.
func (*Analysis) Clone ¶
func (a *Analysis) Clone(opts AnalysisOptions) (*Analysis, error)
Clone returns independently owned data after a finite-budget preflight.
func (*Analysis) RetainedBytes ¶
func (a *Analysis) RetainedBytes(opts AnalysisOptions) (int64, error)
RetainedBytes validates the complete model and reports its conservative owned storage bound. It excludes caller aliases and Go runtime overhead.
func (*Analysis) Validate ¶
func (a *Analysis) Validate(opts AnalysisOptions) error
Validate preflights caller-visible sizes and validates the full timeline. Complete sparse scans are valid; interrupted scans never are.
type AnalysisOptions ¶
AnalysisOptions bounds newly owned storage per call, not process RSS.
type BaseDM ¶
type BaseDM struct {
YCCToRGB [9]int16
YCCOffsets [3]uint32
RGBToLMS [9]int16
EOTF, EOTFParam0, EOTFParam1 uint16
EOTFParam2 uint32
BitDepth, ColorSpace, ChromaFormat, FullRange uint8
SourceMinPQ, SourceMaxPQ, SourceDiagonal uint16
}
BaseDM is absent for compressed DM, whose omitted values are unknown.
type Block ¶
Block retains validated extension fields in their documented wire order. Length distinguishes optional absent fields from encoded zero values. L2's final signed 13-bit field is sign extended into Values.
type Counts ¶
type Counts struct {
OutputPictures uint64 `json:"output_pictures"`
PicturesWithRPU uint64 `json:"pictures_with_rpu"`
RetainedRPUs uint64 `json:"retained_rpus"`
L1Samples uint64 `json:"l1_samples"`
MissingPictures uint64 `json:"missing_rpu_pictures"`
ObservedRPUs uint64 `json:"observed_source_rpus"`
SuppressedRPUs uint64 `json:"suppressed_picture_rpus"`
}
Counts separates retained output metadata from observed and suppressed source RPUs.
type Coverage ¶
type Coverage string
Coverage describes RPU presence on the output picture timeline; standalone sequences have unknown coverage.
type DM ¶
type DM struct {
Compressed bool
AffectedID, CurrentID, SceneRefresh uint64
Base *BaseDM
CM29, CM40 bool
Blocks []Block
L1 *L1
L5 *L5
L6 *L6
}
DM owns display-management metadata for one RPU. Nil level pointers mean absent metadata; compressed records do not inherit missing fields from earlier records.
type EnhancementInventory ¶
type Header ¶
type Header struct {
Format uint16
Profile, Level uint8
SequenceInfo, ChromaFilter bool
CoefficientType uint8
CoefficientDenominator uint8
NormalizedIDC uint8
FullRange bool
BLBitDepth, ELBitDepth, VDRBitDepth uint8
ExtendedMapping uint8
SpatialFilter, ELSpatialFilter, DisableResidual bool
Reserved uint8
DMPresent, ReuseMapping bool
PreviousID uint64
}
Header preserves the evidence used to infer the coarse Dolby Vision profile. Profile 8 does not establish a base-layer compatibility subprofile.
type L1 ¶
type L1 struct{ MinPQ, MaxPQ, AvgPQ uint16 }
L1 contains metadata luminance codes on the 12-bit PQ scale, not decoded-pixel measurements.
type L1Statistics ¶
type L1Statistics struct {
Samples uint64 `json:"samples"`
MinimumNits float64 `json:"minimum_nits"`
PeakNits float64 `json:"peak_nits"`
MaximumAverageNits float64 `json:"maximum_average_nits"`
PQMeanPeakNits float64 `json:"pq_mean_peak_nits"`
PQMeanAverageNits float64 `json:"pq_mean_average_nits"`
}
L1Statistics summarizes native L1 metadata in nits. PQMean fields average PQ codes before conversion; they are not arithmetic means of linear luminance.
type L5 ¶
type L5 struct{ Left, Right, Top, Bottom uint16 }
L5 contains active-area offsets in the metadata's pixel coordinate basis. Applying them to a raster requires an independently established coordinate relationship.
type L6 ¶
type L6 struct{ MaxMastering, MinMastering, MaxCLL, MaxFALL uint16 }
L6 units are those encoded on the wire: maximum luminance/CLL/FALL in cd/m² and minimum mastering luminance in 0.0001 cd/m².
type MasteringL6 ¶
type MetadataInventory ¶
type ParseError ¶
ParseError supplies a field and zero-based bit offset in the unescaped RPU. OffsetKnown is false for errors without a single syntactic location.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type ParseOptions ¶
type ParseOptions struct{ MaxBytes, MaxBlocks int }
ParseOptions selects finite per-record limits. Zero selects the defaults.
type Picture ¶
type Picture struct {
Stream StreamKey
OccurrenceOrdinal uint64
AUOrdinal, DecodeOrdinal uint64
POC int64
POCKnown bool
PTS Timestamp
RPUIndex uint32
HasRPU bool
}
Picture maps one output presentation entry to source syntax and optional RPU metadata. RPUIndex is meaningful only when HasRPU is true. Playlist occurrences may repeat source pictures.
type PlotOptions ¶
type PlotOptions struct {
Title string
Start, End *uint64
MaxBytes int64
MaxInputBytes int64
MaxRecords int
}
PlotOptions uses inclusive original timeline indices; nil End differs from an explicit zero. The displayed crop begins at frame zero, like dovi_tool. MaxBytes bounds rendering allocations, excluding input and caller PNG encoding. MaxInputBytes bounds the input model's conservative accounting separately. Zero limits choose 48 MiB for rendering and 512 MiB for input.
type RPU ¶
type RPU struct {
Header Header
Profile uint8
EnhancementLayer string
MappingID uint64
DM *DM
Remaining []byte
CRC uint32
}
RPU owns all its metadata. Unknown enhancement-layer classification is ""; reuse does not inherit metadata or mapping state from an earlier record.
func ParseNAL ¶
func ParseNAL(nal []byte, opts ParseOptions) (RPU, error)
ParseNAL reads an escaped type-62 NAL, including its two-byte HEVC header, without a start code. Caller memory is borrowed only for this call.
func ParseRPU ¶
func ParseRPU(data []byte, opts ParseOptions) (RPU, error)
ParseRPU reads one unescaped payload beginning with 0x19 and ending with CRC-32/MPEG-2 and 0x80. Permitted trailing zero bytes are discarded.
Example ¶
package main
import (
"fmt"
dovi "github.com/Audionut/go-dovi-extract"
f "github.com/Audionut/go-dovi-extract/internal/testfixture"
)
func main() {
r, err := dovi.ParseRPU(f.RPU(f.Options{Max: 3000, Avg: 1500}), dovi.ParseOptions{})
if err != nil {
panic(err)
}
fmt.Println(r.Profile, r.DM.L1.MaxPQ, r.DM.Base == nil)
}
Output: 8 3000 true
type Raster ¶
Raster is supplied only when the L5 coordinate relationship is established. Display aspect ratio or container display dimensions do not establish it.
type StreamKey ¶
StreamKey distinguishes a source/clip stream using its container-owned track identity.
type Summary ¶
type Summary struct {
ProfileEvidence string `json:"profile_evidence"`
EnhancementLayers []EnhancementInventory `json:"enhancement_layers"`
DisplayAndContent []MetadataInventory `json:"display_and_content_metadata"`
SchemaVersion int `json:"schema_version"`
Timeline Timeline `json:"timeline"`
Complete bool `json:"complete"`
TrackID uint64 `json:"track_id"`
Coverage Coverage `json:"coverage"`
Counts Counts `json:"counts"`
Profiles []Inventory `json:"profiles"`
CMVersions []Inventory `json:"cm_versions"`
Levels []Inventory `json:"levels"`
Trims []TrimTarget `json:"trim_targets"`
SceneMarkers []uint64 `json:"scene_refresh_indices"`
SourceMastering []Mastering `json:"source_mastering_pq"`
L6Mastering []MasteringL6 `json:"l6_mastering"`
ActiveAreas []ActiveAreaRange `json:"l5_ranges"`
L1 *L1Statistics `json:"l1,omitempty"`
Warnings []Warning `json:"warnings"`
}
Summary contains derived observations from validated retained output metadata. Scene markers and luminance describe metadata, not independently decoded pictures.
type SummaryOptions ¶
SummaryOptions bounds input validation and derived-output accounting and optionally supplies an established L5 raster. Zero limits use the finite AnalysisOptions defaults.
type Timeline ¶
type Timeline string
Timeline identifies whether indices address standalone RPUs, presentation pictures or playlist occurrences.
type Timestamp ¶
Timestamp is an exact rational time Value/Timescale. Valid false means unknown; a known timestamp requires a nonzero timescale and may have a negative value.
type TrimTarget ¶
type TrimTarget struct {
Level uint8 `json:"level"`
Target uint16 `json:"target"`
Count uint64 `json:"count"`
}
TrimTarget counts encoded L2 target-PQ values or L8 target indices without converting their units.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
SPDX-License-Identifier: MIT Playlist assembly adapted from go-hdr10-plus, Copyright (c) 2026 Audionut.
|
SPDX-License-Identifier: MIT Playlist assembly adapted from go-hdr10-plus, Copyright (c) 2026 Audionut. |
|
internal
|
|
|
testfixture
Package testfixture authors synthetic syntax, not encoded video pictures.
|
Package testfixture authors synthetic syntax, not encoded video pictures. |