pgs

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 4 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 pgs reads Blu-ray subtitles (Presentation Graphic Streams): their display sets made into the pictures they show, and when.

Index

Constants

View Source
const (
	SegPDS = 0x14 // palette definition
	SegODS = 0x15 // object definition
	SegPCS = 0x16 // presentation composition
	SegWDS = 0x17 // window definition
	SegEND = 0x80
)

Segment types.

Variables

This section is empty.

Functions

func DecodeRLE

func DecodeRLE(b []byte, w, h int) ([]byte, error)

DecodeRLE expands PGS run-length data to w*h palette indices.

func ReadSup

func ReadSup(r io.Reader, fn func(pts int64, seg []byte) error) error

ReadSup reads a .sup file (each segment behind "PG", its PTS and DTS), calling fn with each segment.

Types

type Composition

type Composition struct {
	PTS     int64 // 90 kHz
	W, H    int   // the plane's size
	Objects []Placed
	Palette *Palette
}

Composition is what a display set shows from its time on: nothing (it clears the screen) or objects in a palette.

func (*Composition) Draw

func (c *Composition) Draw() *Picture

Draw draws a composition's objects into the smallest picture holding them.

func (*Composition) Empty

func (c *Composition) Empty() bool

Empty reports whether the composition shows nothing.

func (*Composition) Forced

func (c *Composition) Forced() bool

Forced reports whether everything it shows is forced (shown with the subtitles off: foreign dialogue, signs).

type Decoder

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

Decoder follows a stream's display sets.

func NewDecoder

func NewDecoder() *Decoder

NewDecoder starts following a stream.

func (*Decoder) Segment

func (d *Decoder) Segment(pts int64, seg []byte) (*Composition, bool)

Segment takes a segment (its type, length and payload) at its PTS; at a display set's end it gives the set's composition.

type Object

type Object struct {
	W, H int
	Pix  []byte
}

Object is a picture object, its pixels palette indices.

type Palette

type Palette [256][4]byte

Palette is a palette's entries: Y, Cr, Cb, alpha.

type Picture

type Picture struct {
	X, Y, W, H int
	Luma, A    []byte
}

Picture is a composition drawn: its pixels' luma and alpha over the part of the plane it covers.

type Placed

type Placed struct {
	Obj      *Object
	X, Y     int
	CX, CY   int // the part shown (all of it when not cropped)
	CW, CH   int
	ObjectID uint16
	WindowID byte
	Forced   bool
}

Placed is an object as a composition shows it: where on the plane, and the part of it shown.

Jump to

Keyboard shortcuts

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