wittybluray

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

README

WittyBluray

A Blu-ray engine in pure Go.
Plays a Blu-ray image or BDMV folder the way a player does: first-play, interactive and pop-up menus, titles, subtitles, 4K and HDR.

No cgo Fuzzed

Quick start · Command-line tool · Library · Design · Limits · Blu-ray guide

Read-only mirror of modules/wittybluray in WittyMediaServer, where development happens. Please open issues and pull requests there.

WittyBluray is the Blu-ray engine of WittyMediaServer, and a library and tool for anyone building a player. It is an original implementation of the public Blu-ray Disc structure (the HDMV navigation model).

What it does

Capability Details
💿 Reads discs without mounting .iso/.img images (UDF 2.50 with its metadata partition) and BDMV folders, through WittyDisc
📋 Parses the disc's program index.bdmv, MovieObject.bdmv, playlists (.mpls: items, angles, streams, sub-paths, chapters) and clip information (.clpi: entry-point maps from time to byte)
⚙️ Runs the disc's commands the HDMV virtual machine: 4096 general and 128 player registers; branch, compare, set and system commands
🧭 Navigates like a player first play, titles, menus, calls and resumes, chapter marks, the navigation timer, direct playlist play
🔘 Decodes menus interactive graphics: pages, button groups, buttons with their arrow neighbours and commands, normal/selected/activated pictures, animated highlights and pop-up menus
💬 Decodes subtitles presentation graphics, read in windows so a 20 GB film is never scanned whole
🌈 4K and HDR 2160p HEVC with HDR10, HDR10+ and Dolby Vision flags, so a player can tone-map for SDR screens
🔒 Knows its limits AACS-encrypted discs are refused (nothing is decrypted); BD-J (Java) discs fall back to their titles; 3D (MVC) is reported
🛠️ Diagnoses discs the wittybluray tool reports all of the above, simulates the menus, and renders menu pages

What it leaves to the player: decoding the video and audio. WittyBluray tells a player which bytes to play, when, and what to draw over them.

Quick start

go install github.com/wittywilla/wittybluray/cmd/wittybluray@latest
wittybluray info THE_LORAX.iso

Needs Go 1.26 or newer; the tool lands in $(go env GOPATH)/bin. To use the library in your own program: go get github.com/wittywilla/wittybluray@latest.

The command-line tool

Command What it shows
wittybluray info <disc> titles, the disc's program, playlists, clips and streams, 3D and HDR flags
wittybluray playlist <disc> <n> every item, stream and chapter of one playlist
wittybluray menu <disc> <playlist> a playlist's menu: pages, buttons, every command
wittybluray walk <disc> [button…] simulates inserting the disc, then pressing menu buttons by id
wittybluray render <disc> <dir> the first menu's pages as PNG files

The output holds no video or artwork, so it's safe to attach to a bug report. The same commands are built into WittyMediaServer as wms bluray ….

Using the library

import "github.com/wittywilla/wittybluray"

d, err := wittybluray.Open("THE_LORAX.iso")   // an image, or a folder holding BDMV
if err != nil { return err }
defer d.Close()
if d.Encrypted { return errors.New("AACS") }

nav := wittybluray.NewNav(d, wittybluray.NavOptions{})
step := nav.Start()                            // what to play first
for step.Kind == wittybluray.StepPlay {
    if step.Menu {                             // the playlist carries a menu
        menu, _ := d.LoadMenu(step.IGClip, step.IGPID, 0)
        page := &menu.Pages[0]
        img := menu.Render(page, page.Visible(nil, nil), page.DefaultSelected)
        _ = img                                // show the video with img over it; on OK:
        step = nav.PressButton(page.Button(page.DefaultSelected).Commands)
        continue
    }
    // play step.Playlist from step.Item at step.Time (byte ranges from d.ClipExtents
    // and the clip's entry-point map), then:
    step = nav.PlaylistEnded()
}
The navigator and decoders at a glance
Call Does
Start, PlaylistEnded first play; what comes after a playlist
PressButton, MenuCall, Resume menus and returning to the film
PlayTitle, PlayPlaylist, SetTime, SetChapter titles, playlists and chapters
SetAudio, SetSubtitle, SetAngle streams
NavTimerFired the navigation timer
LoadMenu, Menu.Render, Menu.DrawFrame, Popup menus, animation frames, pop-ups
Subtitles, ReadPID subtitle pictures; any stream's packets

Requirements: Go 1.26 or newer, no cgo. Its only dependency is WittyDisc.

Design

flowchart LR
  I[Disc image] --> D[WittyDisc<br/>UDF 2.50]
  D --> P[index · mobj · mpls · clpi<br/>parsers]
  P --> N[nav.go + vm.go<br/>navigator + HDMV VM]
  N --> S{Step}
  S -->|menu| M[playlist video + IG pages<br/>ig.go · graphics.go]
  S -->|title| T[playlist video + PG subtitles<br/>pg.go]
  D -.-> X[ts.go<br/>one PID out of a clip]
File What it does
open.go opens images and folders; detects AACS, BD-J and 3D; finds the main feature
index.go, mobj.go index.bdmv and MovieObject.bdmv
mpls.go, clpi.go playlists and clip information, with entry-point lookups
vm.go, nav.go the HDMV virtual machine and the navigator
ts.go, graphics.go the transport-stream demuxer; palettes, pictures, windows
ig.go, pg.go menus (interactive graphics) and subtitles (presentation graphics)
cli/ the command-line tool

Safe with untrusted discs: every read is bounds-checked, counts are limited, a disc's program can't loop for ever (100 000 commands per run), and the parsers are fuzz-tested.

Limits

Not yet What happens instead
AACS-encrypted discs refused; make decrypted images of discs you own with a tool that is legal where you live
BD-J (Java) menus the disc plays its titles without the menu
MVC 3D the 2D view plays; the second view is reported, not decoded
Page transition effects skipped (button animations play)

Tested on custom-authored discs; retail discs exercise more of the format and may show problems not seen yet. Reports with wittybluray info and walk output are very welcome.

The Witty family

Project Role
WittyMediaServer the media server these engines power
WittyDVD · WittyBluray the DVD and Blu-ray engines
WittyDisc disc image reader

Licence

Apache-2.0, the same licence as WittyMediaServer. © 2026 WittyWilla and contributors. Use, change and share it; if you redistribute it or build on it, keep the NOTICE attribution, “WittyBluray, developed by WittyWilla”, in your NOTICE file, documentation or About screen.

Documentation

Index

Constants

View Source
const (
	UOMenuCall       = 1 << 63
	UOTitleSearch    = 1 << 62
	UOChapterSearch  = 1 << 61
	UOTimeSearch     = 1 << 60
	UOSkipToNext     = 1 << 59
	UOSkipBack       = 1 << 58
	UOPlay           = 1 << 57
	UOStop           = 1 << 56
	UOPauseOn        = 1 << 55
	UOStill          = 1 << 53
	UOForward        = 1 << 52
	UOBackward       = 1 << 51
	UOResume         = 1 << 50
	UOMoveUp         = 1 << 49
	UOMoveDown       = 1 << 48
	UOMoveLeft       = 1 << 47
	UOMoveRight      = 1 << 46
	UOSelect         = 1 << 45
	UOActivate       = 1 << 44
	UOSelectActivate = 1 << 43
	UOPrimaryAudio   = 1 << 42
	UOAngle          = 1 << 40
	UOPopup          = 1 << 39
	UOPGSelect       = 1 << 38
	UOPGEnable       = 1 << 37
	UOSecVideo       = 1 << 36
	UOSecAudio       = 1 << 34
	UOPiPPG          = 1 << 32
)

User operation mask bits (UOMask). A set bit means the operation is forbidden while the playlist or item plays.

View Source
const (
	PSRIGStream       = 0  // selected IG (menu) stream, 1-based
	PSRAudio          = 1  // selected primary audio stream, 1-based
	PSRPG             = 2  // bits 0..11: PG/text subtitle stream, 1-based; bit 31: subtitles shown
	PSRAngle          = 3  // selected angle, 1-based
	PSRTitle          = 4  // current title, 1-based (0xffff while first play runs)
	PSRChapter        = 5  // current chapter, 1-based (0xffff when unknown)
	PSRPlaylist       = 6  // current playlist number
	PSRPlayItem       = 7  // current play item
	PSRTime           = 8  // presentation time, 45 kHz
	PSRNavTimer       = 9  // navigation timer, seconds
	PSRButton         = 10 // selected button id
	PSRPage           = 11 // current menu page id
	PSRStyle          = 12 // user style number
	PSRParental       = 13 // parental level
	PSRSecondary      = 14 // secondary audio/video selection
	PSRVideoCap       = 15 // player video capability
	PSRAudioLang      = 16 // preferred audio language, three letters packed
	PSRPGLang         = 17 // preferred subtitle language
	PSRMenuLang       = 18 // preferred menu language
	PSRCountry        = 19 // country code
	PSRRegion         = 20 // region: 1 = A, 2 = B, 4 = C
	PSROutputPref     = 21 // bit 0: the user prefers 3D output
	PSRStereoStatus   = 22 // bit 0: 3D output is on now
	PSRDisplayCap     = 23
	PSR3DCap          = 24
	PSRProfile        = 29 // player profile (bit 0: BD-ROM, bit 4: 3D, ...)
	PSRVersion        = 30
	PSRProfileVer     = 31
	PSRBackupTitle    = 36
	PSRBackupChapter  = 37
	PSRBackupPlaylist = 38
	PSRBackupItem     = 39
	PSRBackupTime     = 40
	PSRBackupButton   = 42
	PSRBackupPage     = 43
	PSRBackupStyle    = 44
)

Player status registers the engine uses.

View Source
const MaxStructureBytes = 16 << 20

MaxStructureBytes bounds how much of any .bdmv/.mpls/.clpi file is read.

View Source
const NoButton = 0xffff

NoButton means "none" in button references.

Variables

This section is empty.

Functions

This section is empty.

Types

type AngleClip

type AngleClip struct {
	Clip  string
	Codec string
	STCID int
}

AngleClip is one angle's clip.

type BOG

type BOG struct {
	DefaultValid int
	Buttons      []Button
}

BOG is a button overlap group: buttons that share a place on screen, of which one (the valid one) is shown at a time.

type Button

type Button struct {
	ID             int
	NumericSelect  int // the number key that selects it, or NoButton
	AutoAction     bool
	X, Y           int
	Up, Down       int // neighbours by button id, NoButton when none
	Left, Right    int
	Normal         StateImages
	Selected       StateImages
	Activated      StateImages
	SelectedSound  int
	ActivatedSound int
	Commands       []Command
}

Button is one menu button.

type ButtonPage

type ButtonPage struct {
	Button, Page  uint32
	SetButton     bool
	SetPage       bool
	PageEffectOff bool
}

ButtonPage is SET_BUTTON_PAGE: change the menu's page and/or button.

type ButtonState

type ButtonState int

ButtonState picks which picture of a button to draw.

const (
	ButtonNormal ButtonState = iota
	ButtonSelected
	ButtonActivated
)

type Clip

type Clip struct {
	Name    string // five digits
	Version string
	// StreamType: 1 = a normal transport stream. ApplicationType: 1 = main
	// movie, 2 = time-based slideshow, 3 = browsable slideshow, 4 = sub-path
	// (secondary audio or text subtitles), 5 = IG menu, 6 = ...
	StreamType, ApplicationType int
	TSRate                      int    // bytes per second of the transport stream
	Packets                     uint32 // source packets (192 bytes each)
	STC                         []STCSequence
	Programs                    []Program
	EPMaps                      []EPMap
}

Clip is one .clpi file.

func ParseClip

func ParseClip(name string, b []byte) (*Clip, error)

ParseClip parses one .clpi file.

func (*Clip) Duration

func (c *Clip) Duration() float64

Duration is the clip's length in seconds from its time bases.

func (*Clip) SPNAt

func (c *Clip) SPNAt(pid uint16, pts uint32) (e EPEntry, ok bool)

SPNAt returns the entry point at or before the time (45 kHz) in the stream, so a player can start reading there. ok is false when the clip has no entry-point map for that stream.

func (*Clip) Size

func (c *Clip) Size() int64

Size is the clip's length in bytes.

func (*Clip) Stream

func (c *Clip) Stream(pid uint16) *ClipStream

Stream finds a stream by PID.

func (*Clip) VideoPID

func (c *Clip) VideoPID() uint16

VideoPID is the clip's main video stream, or 0.

type ClipStream

type ClipStream struct {
	PID    uint16
	Coding byte
	Format int
	Rate   int
	Aspect int // video: 2 = 4:3, 3 = 16:9
	Lang   string
	// HEVC video: DynamicRange 0 = SDR, 1 = HDR10, 2 = Dolby Vision; ColorSpace 1 = BT.709, 2 = BT.2020.
	DynamicRange, ColorSpace int
}

ClipStream is one elementary stream as the clip describes it.

type Command

type Command struct {
	Op       uint32
	Dst, Src uint32
}

Command is one 12-byte HDMV navigation command, as stored.

type Disc

type Disc struct {
	Source       Source
	Label        string
	Index        *Index
	MovieObjects []MovieObject
	Playlists    map[int]*Playlist
	Clips        map[string]*Clip
	// Encrypted is set when the disc carries AACS (an AACS folder, or
	// scrambled packets in its streams). The engine never decrypts
	// anything: such discs are refused for playback.
	Encrypted bool
	// Stereo3D: the disc has 3D (MVC) content: an SSIF folder, a dependent
	// view stream, or the index's 3D flag.
	Stereo3D bool
	// BDJ: the disc's first play, top menu or a title is a BD-J (Java)
	// program, which this engine cannot run; such entries are played as
	// plain titles where possible.
	BDJ bool
}

Disc is an opened Blu-ray.

func Open

func Open(p string) (*Disc, error)

Open opens an image file or a disc folder (the folder that contains BDMV, or BDMV itself).

func (*Disc) Clip

func (d *Disc) Clip(name string) *Clip

Clip returns a clip's information by name.

func (*Disc) ClipExtents

func (d *Disc) ClipExtents(name string) ([]FileExtent, error)

ClipExtents returns the byte extents of a clip's stream file.

func (*Disc) Close

func (d *Disc) Close() error

Close releases the image.

func (*Disc) LoadMenu

func (d *Disc) LoadMenu(clip string, pid uint16, limit uint32) (*Menu, error)

LoadMenu reads the IG stream with the PID from a clip. For in-mux menus (the IG stream inside the title's clip) `limit` packets are scanned (0 = the whole clip); menu clips are small and read whole.

func (*Disc) MainPlaylist

func (d *Disc) MainPlaylist() *Playlist

MainPlaylist guesses the feature: the longest playlist whose clips are not all shared with a longer one (so a "play all" of the extras does not win), with a video stream.

func (*Disc) Playlist

func (d *Disc) Playlist(n int) *Playlist

Playlist returns a playlist by number.

func (*Disc) PlaylistDuration

func (d *Disc) PlaylistDuration(pl *Playlist) float64

PlaylistDuration is the playlist's length in seconds.

func (*Disc) ReadPID

func (d *Disc) ReadPID(clip string, pid uint16, from, to uint32, fn PESHandler) error

ReadPID reads the PES packets of one PID from a clip, from source packet `from` up to (not including) `to` (0 = the end).

func (*Disc) Subtitles

func (d *Disc) Subtitles(clip string, pid uint16, from, to uint32) (*SubtitleWindow, error)

Subtitles decodes the PG stream `pid` of a clip between two times (45 kHz; to = 0 means the end). The clip is read from the entry point at or before `from`, so a long movie is never scanned whole.

type EPEntry

type EPEntry struct {
	PTS uint32 // 45 kHz
	SPN uint32 // source packet number; byte offset = SPN * 192
	// AngleChange marks the packet as a point where a seamless angle change
	// may happen.
	AngleChange bool
}

EPEntry is one entry point: a packet at which decoding can start.

type EPMap

type EPMap struct {
	PID     uint16
	Entries []EPEntry // in time order
}

EPMap maps presentation times to source packet numbers for one stream.

type Effects

type Effects struct {
	NavTimer      *NavTimer
	ButtonPage    *ButtonPage
	EnableButton  []uint32
	DisableButton []uint32
	PopupOff      bool
	Still         *bool
	OutputMode3D  *bool
	StreamChange  bool // audio, subtitle, IG or angle registers changed
}

Effects collects what SET_SYSTEM commands asked for during a run; the player applies them.

type FileExtent

type FileExtent struct {
	Path   string `json:"path"`
	Offset int64  `json:"offset"`
	Length int64  `json:"length"`
}

FileExtent is a byte range of a stream file: inside the image, or a file on disk when the disc is a folder.

type Group

type Group int

Group is a command's group.

const (
	GroupBranch Group = iota
	GroupCompare
	GroupSet
)

type Index

type Index struct {
	Version    string
	Stereo3D   bool // the disc prefers 3D output when the player can
	HasContent bool
	// VideoFormat and FrameRate are the disc's main video, as its menus
	// expect: 1 = 480i, 2 = 576i, 3 = 480p, 4 = 1080i, 5 = 720p, 6 = 1080p,
	// 7 = 576p; frame rates 1 = 23.976, 2 = 24, 3 = 25, 4 = 29.97, 6 = 50, 7 = 59.94.
	VideoFormat, FrameRate int
	FirstPlay, TopMenu     IndexObject
	Titles                 []Title
}

Index is BDMV/index.bdmv.

func ParseIndex

func ParseIndex(b []byte) (*Index, error)

ParseIndex parses index.bdmv.

type IndexObject

type IndexObject struct {
	Kind        ObjectKind
	Interactive bool   // the object has a menu (an IG stream or BD-J UI) rather than just playing
	MovieObject int    // HDMV: the movie object to run
	BDJName     string // BD-J: the object's name (BDMV/BDJO/<name>.bdjo)
}

IndexObject is one entry of the index: first play, top menu or a title.

type Instr

type Instr struct {
	Raw      Command
	Group    Group
	Sub      int // branch: 0 goto, 1 jump, 2 play; set: 0 set, 1 set system
	Opt      int // branch option, compare option or set option
	Operands int
	ImmDst   bool
	ImmSrc   bool
	Dst, Src uint32
}

Instr is a decoded command.

func Decode

func Decode(c Command) Instr

Decode decodes a command.

func (Instr) Name

func (in Instr) Name() string

Name is the command's mnemonic.

func (Instr) String

func (in Instr) String() string

String is a readable form, e.g. "EQ GPR4094, 3".

type Mark

type Mark struct {
	Type     int
	Item     int    // index into Items
	Time     uint32 // 45 kHz ticks into the clip, in the item's time base
	PID      uint16 // the stream it applies to, 0xffff for all
	Duration uint32
}

Mark is a chapter (Type 1, "entry mark") or a link point (Type 2).

type Menu struct {
	Width, Height int
	// Popup menus (UIModel 1) stay hidden until the user's Popup key; always-on
	// menus (0) show at once.
	Popup bool
	// Timeouts, in seconds (0 = none): the whole composition, and how long a
	// selection waits before the default activated button runs.
	Timeout, SelectionTimeout, UserTimeout float64
	Pages                                  []Page
	// contains filtered or unexported fields
}

Menu is one IG stream.

func (m *Menu) Draw(img *image.NRGBA, page *Page, b *Button, state ButtonState) bool

Draw paints one button in a state into img (the menu's full frame): the first picture of the state's animation.

func (m *Menu) DrawFrame(img *image.NRGBA, page *Page, b *Button, state ButtonState, frame int) bool

DrawFrame paints picture `frame` of a button state's animation (frames wrap, so a looping highlight can be drawn for any frame number).

func (m *Menu) Objects() int

Objects and Palettes count what the stream carried (for diagnostics).

func (m *Menu) Page(id int) *Page

Page returns a page by id.

func (m *Menu) Palettes() int
func (m *Menu) Rect(b *Button) image.Rectangle

Rect is a button's place on screen, from its picture.

func (m *Menu) Render(page *Page, buttons []*Button, selected int) *image.NRGBA

Render draws a whole page with one button selected. Buttons are those Visible returns; the result is transparent where there are no buttons.

type MovieObject

type MovieObject struct {
	ResumeIntention bool // playback resumes in this object after a menu call
	MenuCallMask    bool // the user's menu key is ignored while it runs
	TitleSearchMask bool // the user's title search is ignored while it runs
	Commands        []Command
}

MovieObject is one program.

func ParseMovieObjects

func ParseMovieObjects(b []byte) ([]MovieObject, error)

ParseMovieObjects parses MovieObject.bdmv.

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

Nav runs a disc.

func NewNav

func NewNav(d *Disc, o NavOptions) *Nav

NewNav makes a navigator for the disc.

func (n *Nav) Clone() *Nav

Clone copies the navigator, to explore a disc without disturbing it.

func (n *Nav) MenuCall() *Step

MenuCall is the user's Menu key: the top menu, remembering where the title was so RESUME can return.

func (n *Nav) NavTimerFired() *Step

NavTimerFired is called by the player when the SET_NV_TIMER timeout of the last Step has passed with no user action.

func (n *Nav) PlayPlaylist(pl *Playlist, item int, t uint32) *Step

PlayPlaylist plays a playlist directly, outside the disc's program: for "play the movie" from a library, and for discs whose program needs BD-J. When the playlist ends, nothing follows (PlaylistEnded stops).

func (n *Nav) PlayTitle(t int) *Step

PlayTitle starts a title from the title list (1-based), as the user's title search does.

func (n *Nav) PlaylistEnded() *Step

PlaylistEnded is called by the player when the playlist of the last Step has played to its end: the disc's program continues after PLAY_PL.

func (n *Nav) PressButton(cmds []Command) *Step

PressButton runs a menu button's commands (from the IG stream). A button may change the menu (page, selected button), start another playlist, end the menu (TERMINATE_PL) or jump elsewhere.

func (n *Nav) Registers() *Registers

Registers exposes the player's registers (read, or set by the player for stream choices through SetAudio and friends).

func (n *Nav) Resume() *Step

Resume returns to the title a menu call interrupted, at the saved time.

func (n *Nav) SetAngle(a int)
func (n *Nav) SetAudio(s int)

SetAudio and SetSubtitle record the user's stream choices (1-based; a subtitle stream of 0 hides subtitles).

func (n *Nav) SetChapter(c int)

SetChapter records the chapter the player is in (1-based).

func (n *Nav) SetSubtitle(s int, shown bool)
func (n *Nav) SetTime(item int, t uint32)

SetTime tells the navigator where playback is, for resume and the disc's own program (PSR8).

func (n *Nav) Start() *Step

Start begins as if the disc were just inserted: the first-play object.

type NavOptions struct {
	Registers RegisterOptions
}

NavOptions configure the player the navigator simulates.

type NavTimer struct {
	Seconds uint32
	Object  int
}

NavTimer is SET_NV_TIMER: run a movie object after some seconds.

type Object

type Object struct {
	ID            int
	Width, Height int
	Pixels        []byte // Width*Height palette indexes
}

Object is one run-length-coded picture, as indexes into a palette.

type ObjectKind

type ObjectKind int

ObjectKind says what kind of program an index entry runs.

const (
	ObjectNone ObjectKind = iota
	ObjectHDMV            // a movie object in MovieObject.bdmv
	ObjectBDJ             // a BD-J (Java) object: not supported
)

func (ObjectKind) String

func (k ObjectKind) String() string

type PESHandler

type PESHandler func(payload []byte, pts uint64) bool

PESHandler receives one PES packet's payload and 90 kHz presentation time; it returns false to stop reading.

type Page

type Page struct {
	ID               int
	UOMask           uint64
	DefaultSelected  int // button id, or NoButton
	DefaultActivated int // a button that runs when the selection times out, or NoButton
	Palette          int
	// AnimationRate is the video frames per animation frame of the buttons'
	// state animations (0 = no animation).
	AnimationRate int
	BOGs          []BOG
}

Page is one menu page.

func (*Page) Button

func (p *Page) Button(id int) *Button

Button finds a button on a page.

func (*Page) Visible

func (p *Page) Visible(enabled, disabled map[int]bool) []*Button

Visible lists the buttons shown on the page: each group's valid button, as the group defaults say, overridden by `valid` (button ids enabled by ENABLE_BUTTON) and `hidden` (disabled ones).

type Palette

type Palette [256]color.RGBA

Palette is 256 colours. Entries a segment does not set are transparent.

type PlayItem

type PlayItem struct {
	Clip  string // the clip's five-digit name, e.g. "00005"
	Codec string // "M2TS"
	// ConnectionCondition says how this item joins the previous one: 1 =
	// seamless (same clip continues), 5 = seamless across clips, 6 = a break
	// (the player may pause briefly).
	ConnectionCondition int
	STCID               int
	In, Out             uint32 // 45 kHz ticks into the clip
	UOMask              uint64
	RandomAccess        bool
	// StillMode: 0 = none, 1 = a still of StillTime seconds after the item,
	// 2 = a still until the user acts.
	StillMode int
	StillTime int
	// Angles lists the clips of a multi-angle item; the first is the main
	// angle (the same as Clip).
	Angles           []AngleClip
	SeamlessAngles   bool
	DifferentAudios  bool
	Video, Audio, PG []Stream
	IG, SecAudio     []Stream
	SecVideo, PiPPG  []Stream
}

PlayItem is one stretch of a clip.

func (*PlayItem) Duration

func (p *PlayItem) Duration() float64

Duration is the item's length in seconds.

type Playlist

type Playlist struct {
	Number       int
	Version      string
	PlaybackType int // 1 = sequential, 2 = random, 3 = shuffle
	// PlaybackCount is how many items a random or shuffle playlist plays.
	PlaybackCount int
	UOMask        uint64 // user operations the disc forbids (see UO constants)
	RandomAccess  bool   // the user may not jump around (chapter search, time search) when false
	Items         []PlayItem
	SubPaths      []SubPath
	Marks         []Mark
}

Playlist is one .mpls file.

func ParsePlaylist

func ParsePlaylist(number int, b []byte) (*Playlist, error)

ParsePlaylist parses one .mpls file.

type Program

type Program struct {
	StartSPN uint32
	PMTPID   uint16
	Streams  []ClipStream
}

Program is one program of the transport stream and its streams.

type RegisterOptions

type RegisterOptions struct {
	AudioLang, SubtitleLang, MenuLang string // three-letter codes, e.g. "eng"
	Country                           string // two letters, e.g. "US"
	Region                            int    // 1 = A, 2 = B, 4 = C; 0 = A
	Parental                          int    // 0 = no limit
	Stereo3D                          bool   // the display can show 3D
}

RegisterOptions set the player's identity: languages, region, 3D.

type Registers

type Registers struct {
	GPR [4096]uint32
	PSR [128]uint32
}

Registers: 4096 general-purpose registers the disc may set freely, and 128 player status registers (PSRs) that describe the player and the playback state, which the disc reads and the player and SET_SYSTEM commands write.

func NewRegisters

func NewRegisters(o RegisterOptions) *Registers

NewRegisters makes a player's register file for the options.

func (*Registers) Clone

func (r *Registers) Clone() *Registers

Clone copies the registers.

func (*Registers) Run

func (r *Registers) Run(cmds []Command, pc int, o RunOptions, fx *Effects) Result

Run executes commands from pc until one changes the player's course, or the end. Compare commands that are false skip the next command.

type Result

type Result struct {
	Kind     ResultKind
	Object   int // JUMP/CALL_OBJECT
	Title    int // JUMP/CALL_TITLE
	Playlist int
	Item     int // PLAY_PL_PI, LINK_PI; -1 otherwise
	Mark     int // PLAY_PL_PM, LINK_MK; -1 otherwise
	PC       int // the command after the one that stopped the run
	Err      error
}

Result is what a run of commands asks the player to do.

type ResultKind

type ResultKind int

ResultKind says why a run of commands stopped.

const (
	ResultEnd        ResultKind = iota // ran off the end (or BREAK)
	ResultJumpObject                   // run another movie object
	ResultJumpTitle                    // go to a title (0 = top menu, 0xffff = first play)
	ResultCallObject                   // run another movie object, resuming here after
	ResultCallTitle                    // a title, resuming here after
	ResultResume                       // back to what was suspended by a call
	ResultPlay                         // play a playlist (Playlist; Item or Mark when set)
	ResultTerminate                    // stop the playing playlist
	ResultLinkItem                     // jump within the playing playlist to a play item
	ResultLinkMark                     // jump within the playing playlist to a mark
	ResultError
)

type RunOptions

type RunOptions struct {
	MaxSteps int // 0 = 100000; a disc's program cannot loop for ever
}

RunOptions limit a run.

type STCSequence

type STCSequence struct {
	PCRPID     uint16
	StartSPN   uint32
	Start, End uint32 // presentation times, 45 kHz
}

STCSequence is a stretch of the clip with one continuous clock.

type Source

type Source interface {
	ReadFile(name string, max int64) ([]byte, error) // name is relative to the disc root, e.g. BDMV/index.bdmv
	Extents(name string) ([]FileExtent, error)
	List(dir string) ([]string, error) // file names in a folder of the disc
	Describe() string
	Close() error
}

Source abstracts an image or a BDMV folder.

type StateImages

type StateImages struct {
	Start, End int // object ids, NoButton when none
	Repeat     bool
}

StateImages is the range of pictures of one button state (an animation from Start to End; the player shows the first).

func (StateImages) Frames

func (st StateImages) Frames() int

Frames is how many pictures a button state animates through (0 = none).

type Step

type Step struct {
	Kind     StepKind
	Reason   string
	Playlist *Playlist
	Item     int    // where to start: the play item index
	Time     uint32 // and the time in it (45 kHz ticks, in the clip's time base); 0 = the item's IN
	// Menu is set when the playlist has an IG (menu graphics) stream: its
	// PID, and the clip it comes from when it is in a sub-path.
	Menu    bool
	IGPID   uint16
	IGClip  string // "" when the IG stream is in the play item's own clip
	Title   int    // PSR4 at this step (0xffff during first play)
	Object  int    // the movie object that asked for this
	Effects *Effects
}

Step is the navigator's instruction to the player.

type StepKind

type StepKind string

StepKind is what the player should do.

const (
	StepPlay        StepKind = "play"
	StepStop        StepKind = "stop"
	StepUnsupported StepKind = "unsupported" // a BD-J object: the player may fall back to the main feature
	StepStay        StepKind = "stay"        // nothing changes (a button only changed menu state)
)

type Stream

type Stream struct {
	Kind string // video, audio, pg (subtitles), ig (menu), sec-audio, sec-video, pip-pg
	// EntryType says where the stream is: 1 = in this item's clip, 2 = in a
	// sub-path's clip, 3 = in a sub-path (text subtitles), 4 = in a sub-path
	// clip with its own PID.
	EntryType int
	PID       uint16
	SubPath   int
	SubClip   int
	Coding    byte // MPEG-TS stream type: 0x1b H.264, 0x24 HEVC, 0xea VC-1, 0x02 MPEG-2, 0x20 MVC; 0x80 LPCM, 0x81 AC-3, 0x82 DTS, 0x83 TrueHD, 0x84 E-AC-3, 0x85 DTS-HD, 0x86 DTS-HD MA; 0x90 PG, 0x91 IG, 0x92 text
	Format    int  // video: 1 480i 2 576i 3 480p 4 1080i 5 720p 6 1080p 7 576p 8 2160p; audio: 1 mono 3 stereo 6 multi-channel 12 stereo+multi
	Rate      int  // video frame rate (see Index.FrameRate); audio: 1 48 kHz, 4 96 kHz, 5 192 kHz, 12 48/192, 14 48/96
	Lang      string
	CharCode  int // text subtitles: character coding
	// UHD (HEVC) video: DynamicRange 0 = SDR, 1 = HDR10, 2 = Dolby Vision; ColorSpace 1 = BT.709, 2 = BT.2020; HDR10Plus when the stream carries HDR10+ metadata.
	DynamicRange int
	ColorSpace   int
	HDR10Plus    bool
}

Stream is one selectable stream of a play item.

func (Stream) CodingName

func (s Stream) CodingName() string

CodingName is a readable name for the stream's coding.

type SubPath

type SubPath struct {
	// Type: 2 = primary audio of a browsable slideshow, 3 = IG menu, 4 = text
	// subtitles, 5 = out-of-mux synchronous (secondary audio/video), 6 =
	// out-of-mux asynchronous PiP, 7 = in-mux synchronous PiP, 8 = 3D
	// dependent view (MVC), 9 = 3D dependent view with PiP.
	Type   int
	Repeat bool
	Items  []SubPlayItem
}

SubPath is a sequence of sub play items with streams that play alongside the main path: out-of-mux menu graphics, secondary audio or video, picture-in-picture, text subtitles, or a 3D dependent view.

type SubPlayItem

type SubPlayItem struct {
	Clip                string
	Codec               string
	ConnectionCondition int
	STCID               int
	In, Out             uint32
	SyncItem            int    // the main path's play item this one is synchronised with
	SyncStart           uint32 // and the time in it (45 kHz)
	MultiClips          []AngleClip
}

SubPlayItem is one stretch of a clip in a sub-path.

type Subtitle

type Subtitle struct {
	Start, End uint32 // 45 kHz, in the clip's time base; End 0 = until the next
	X, Y       int    // on the video frame
	Image      *image.NRGBA
	Forced     bool // the disc wants it shown even with subtitles off (a translation of on-screen text)
}

Subtitle is one subtitle picture and when it shows.

type SubtitleWindow

type SubtitleWindow struct {
	Width, Height int
	Subtitles     []Subtitle
}

SubtitleWindow is what Subtitles returns: the pictures and the frame size they are placed on.

type Title

type Title struct {
	Number int // 1-based, as JUMP_TITLE names them
	// Access says what the user may do while this title plays: 0 = anything,
	// 1 = no title search, 2 = no title search and no menu call.
	Access int
	Object IndexObject
}

Title is a disc title as the player's title list shows it.

type Window

type Window struct {
	ID         int
	X, Y, W, H int
}

Window is a rectangle of the screen that compositions draw into.

Directories

Path Synopsis
Package cli holds the wittybluray commands, shared by the standalone tool and WittyMediaServer's `wms bluray ...`.
Package cli holds the wittybluray commands, shared by the standalone tool and WittyMediaServer's `wms bluray ...`.
cmd
wittybluray command
Command wittybluray inspects Blu-ray images and BDMV folders with the WittyBluray engine.
Command wittybluray inspects Blu-ray images and BDMV folders with the WittyBluray engine.

Jump to

Keyboard shortcuts

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