wittybluray

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

README

WittyBluray

Plays Blu-ray images and BDMV folders in WittyMediaServer the way a player does, with their menus, including 4K, HDR and 3D discs. You need it if your disc libraries hold Blu-rays.

A Blu-ray playing in a browser

A Blu-ray image, in a browser. Sita Sings the Blues, Nina Paley, CC0.

A Blu-ray's page

A disc's page in WittyMediaServer. Sita Sings the Blues, Nina Paley, CC0.

A message saying the disc is encrypted

An encrypted pressing gets a plain message, and nothing unlocks it. Big Buck Bunny, Blender Foundation, CC BY 3.0, from a disc pressed by Imagion AG.

What it does

  • Plays the disc's own program: first play, titles, interactive and pop-up menus with animated highlights, chapters and the navigation timer, through a virtual machine for the disc's commands.
  • Reads without mounting: .iso and .img images and BDMV folders, through WittyDisc.
  • 4K and HDR: it reads 2160p HEVC streams with their HDR10, HDR10+ and Dolby Vision flags, so a player can choose what to do on an SDR screen.
  • Subtitles from the disc's presentation graphics, read in windows so a large film is never scanned whole.
  • Java (BD-J) menus, only if you install a Java and turn this on. None is shipped. They run in a default-deny sandbox, and without Java the disc plays its titles.
  • Finds the feature among decoys. Every playlist is scored from the disc's unencrypted navigation alone: distinct versus total time; repeated, shuffled or missing clips; fake short clips; how each clip joins the next (the clock carrying on, the clip's packet map, where the clips lie on an image); chapters, streams and file sizes; and where the disc's HDMV program leads, read by following its registers without running it, or what its Java program names, read from its class files. So the real film is picked among the hundreds or thousands of decoy playlists some discs carry, each cut of a film with several is listed, a TV disc's episodes come in order, and the answer comes with its reasons and a confidence. See docs/PLAYLIST-HEURISTICS.md.
  • Reads copies that went wrong. Every length in every file is checked, a damaged part of a file is left out and named, each structure falls back on its BACKUP copy when it is missing, unreadable or contradicts the rest of the disc, and playlists, clip information and stream file sizes are checked against each other. A copy with no index.bdmv or MovieObject.bdmv (a "movie only" copy) plays from its playlists.
  • Refuses encrypted discs. AACS-encrypted discs are refused and BD+ is not run. Nothing is decrypted. The server makes its own check as well, whatever a module says.
  • Tells you what's on a disc. The wittybluray command-line tool reports all of this, simulates the menus and draws menu pages.

It doesn't do these yet:

Not yet What happens instead
Secondary audio, picture in picture The disc's choice is recorded, not mixed in
The second view of a 3D disc The 2D view plays, and the second view is reported

Drawing menus into pictures, and the session code that turns steps into streams, stay with the server.

How to use it is in Help inside WittyMediaServer: see Blu-rays.

How to get it

An admin adds it from the module store inside WittyMediaServer: Settings → Modules, then Browse the store, then Add beside WittyBluray. That needs WittyMediaServer 0.6.0-alpha or later, and it works with nothing older. The range this version fits is in module.json: 0.6.0-alpha through 0.6.x.

What it needs

  • FFmpeg, which comes with the server.
  • Java 8 or newer on the server, only for discs with Java menus, and only if you turn that on.
  • WittyDisc, which reads the images, and WittyModule, which is how a server talks to it. Both are built in.
  • No media comes with it.

It's written in Go with no cgo, from the published disc structure, and contains no code from other players. If you have libbluray installed, it can be asked for a second opinion on a disc's playlists (see below); it is never needed.

Platforms

It has only been tested on custom-authored discs, so retail discs may show problems not seen yet.

A program is built for each system below, and the server uses the right one.

System Where it stands
Linux (x64, arm64, 32-bit ARM, x86) Its tests pass on x64, and a Blu-ray playlist has played from a test server with it installed, checked by script. The other CPUs are only built
Windows (x64, arm64) Built. This version hasn't been run on Windows since it became its own program
macOS (Intel, Apple silicon) Built by the release tool. It has not been run on a real Mac
FreeBSD (amd64, arm64) Cross-compiled only. It has not been run

On macOS and FreeBSD the server has no sandbox for a module's helper: it gets a small environment and a soft memory limit, and nothing more.

Its part of every app

A Blu-ray's page in every WittyMediaServer app comes from this module's own sdui.json (module API 4), kept equal to UI() in sdui.go by a test, so any app that draws the server's interface shows it in every look with no code of its own. Between the title's header and its cast, in this order, each section left out when it has nothing to show:

Section What it shows
This disc can't be played An encrypted disc: what happened, that nothing was changed or copied, and what the disc's index still says
Feature Presentation Play the film (the whole of it, however the disc cuts it up) and how many scenes it has
Scenes The film's chapters as pictures, each playing from its start
Episodes A TV disc's episodes in viewing order
Other versions Other cuts and camera angles than the one Play plays
Bonus material The disc's other playlists worth watching, without its decoys
Disc menus Shortcuts straight into the disc's own menus
Why this playlist Which playlist is the film, why, how sure the engine is, and the other candidates
Diagnosis What was wrong with this copy and what was mended, and for an administrator Check this disc

Each section's source takes the page's title and answers for a Blu-ray only. The module's service answers them (module API 5, package api), asking the server's host API for what only the server keeps and checks: this module's ranking, read by its helper and checked by the server, and an administrator's choice of film. The names given to its playlists are its own, in its own database. Their rows run its own commands (wittybluray.choose, wittybluray.clearChoice, wittybluray.rank), which are its routes under /api/modules/wittybluray/discs/{id}. The player is each app's own: playing the disc, its menus and buttons, and the remote are the app's native player screen, not SDUI; in a browser it is WittyDisc's web part. The module has no settings page: the server's disc settings are WittyDisc's Settings, DVDs and Blu-rays.

Why these sections are SDUI, and the rest isn't. A disc module doesn't need SDUI to work. These sections are SDUI only because they are plain rows of a title's page that every app already knows how to draw: as SDUI, the iPhone, Apple TV and Android apps show a Blu-ray's feature, scenes, episodes, versions and why this playlist with no code of their own, and the same words as the web. What stays each app's own, on purpose:

  • Playing the disc, its menus and buttons, and the remote: drawn frame by frame from the disc, with timing and focus no page description could carry.
  • Disc settings and naming titles and scenes: an administrator's dialogs on the web's title page (Manage this title, WittyDisc's), writing to the server's PUT /api/items/{id} and this module's PUT /api/modules/wittybluray/discs/{id}/labels.
  • The server-wide disc settings: WittyDisc's hand-built Settings, DVDs and Blu-rays.
  • WittyMediaPlayer's disc screens: the desktop player draws its own.

Building and testing

You need Go 1.26 or newer. In a worktree, first run the copy of dev-modules.mjs kept above the repositories (node D:/projects/dev-modules.mjs on the development machine). It writes a go.work that git ignores, so the checkout builds against the repositories beside it. Never run go work use.

go vet ./...
go test ./... -count=1
go run github.com/wittywilla/wittymodule/cmd/wittymodule check .

The last one checks the manifest. On the same tool, pack -targets linux/amd64 -out release . builds a release for one system. CI also builds for every system.

The tests run disc code in Java, and skip where there's no Java. WMS_REQUIRE_JAVA=1 makes a skip a failure, as CI does. bdj/runtime.jar is built by bdj/java/build.sh, which needs a JDK 11 or newer. You only need that to change the runtime.

To look at a disc by hand:

go run ./cmd/wittybluray info MY_DISC.iso
Command What it shows
wittybluray info <disc> Titles, the disc's program, playlists, clips and streams, 3D and HDR flags
wittybluray rank <disc> [json] Which playlist is the feature and why: every playlist scored, the confidence, editions, episodes, chapters, what in the copy disagrees, and libbluray's second opinion when it is installed
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
wittybluray bdj <disc> [seconds [picture.png [key...]]] Java titles and what their code needs; with Java, runs them, pressing the keys named

To use it as a library, wittybluray.Open opens an image or folder, and wittybluray.NewNav gives a navigator: Start, PressButton, PlaylistEnded and the rest return what to do next. Check d.Encrypted first. d.MainPlaylist() is the feature. d.Analyze(wittybluray.RankOptions{}), d.RankPlaylists(), d.Episodes() and d.Explain() give the whole ranking, with the same shape as WittyDVD's; pl.Chapters() gives a playlist's chapters on its playing time and d.Consistency() where the copy's structures disagree.

libbluray as a second opinion (optional)

WittyBluray needs nothing installed, and no libbluray code is in it or shipped with it. If a libbluray shared library is on the machine, the libbluray package loads it when asked (dlopen or LoadLibrary through purego: no cgo, nothing at build time) and compares its list of playlists, their lengths, chapters and angles, and the title it would play as the feature, with WittyBluray's. Disagreements are listed and lower the ranking's confidence; WittyBluray's own answer is never replaced. wittybluray rank, the diagnoser, and the helper's ranking call with shown: true are what ask.

brew install libbluray        # or your system's package; nothing to rebuild
go run ./cmd/wittybluray rank MY_DISC.iso
  • It is built for 64-bit macOS and Windows always, and for Linux with -tags libbluray (still without cgo). The release's Linux program is a static binary that runs on any distribution, and a loader would tie it to the machine's C library; build with the tag for your own machine if you want the comparison there. -tags nolibbluray leaves it out everywhere.
  • WITTYBLURAY_LIBBLURAY=off turns loading off, and WITTYBLURAY_LIBBLURAY=/path/to/libbluray.so.2 names the one file to load. libbluray.Capability() says what was found.
  • It is never used to decrypt. A disc is only handed to libbluray when its streams are clear and it has no AACS and no BDSVM folder at all, so libbluray has no reason to load libaacs or libbdplus; LIBAACS_PATH and LIBBDPLUS_PATH are pointed at a path that doesn't exist besides. No key file is given, and bd_read isn't bound at all.

wittyblurayplayer/ is the same engine as a program of its own for WittyMediaPlayer, with its own go.mod and manifest.

Licence

GNU Affero General Public License v3.0 (or later): see LICENSE and NOTICE. If you redistribute it or build on it, please keep the NOTICE attribution. It's an original implementation and contains no code from other players. bdj/runtime.jar is original code that re-implements the published interfaces disc applications link against, and contains no Java runtime. Each release archive carries a THIRD-PARTY-NOTICES.txt for what its programs link.

WittyBluray is an independent open-source project. It isn't associated with, sponsored by or endorsed by the Blu-ray Disc Association, any film studio or any other player project. “Blu-ray” and “Blu-ray Disc” are trademarks of the Blu-ray Disc Association; WittyBluray isn't a licensed or certified Blu-ray product and uses no Blu-ray logo. AACS-encrypted discs are refused, BD+ isn't run, nothing is decrypted, and no media comes with it: you're responsible for having the rights to what you open. Any third-party names here only describe what it works with, and belong to their owners. It's provided “as is”, with no warranty; see LICENSE. Local law applies to how you use it. This isn't legal advice.

Releasing

A version tag builds a program for every platform, signs the checksum list, and publishes a release that servers can install.

Versions move in small steps as work lands. go run github.com/wittywilla/wittymodule/cmd/wittymodule@v0.4.0 bump . raises it everywhere it is written (add -part minor for a bigger step). A bump isn't a release: nothing is tagged or published until you tag it. CI fails when code changed since the last tag and the version didn't, because tags never move.

To release:

  1. Check that version in module.json is the one to publish, with the bump committed.
  2. Tag that commit and push the tag: git tag vX.Y.Z, then git push origin vX.Y.Z. A tag with a suffix, such as v1.2.0-beta, is published as a prerelease.
  3. Watch the Actions tab. The signing step uses the WMS_SIGNING_KEY secret of the release environment, and nothing is published without it.

To take a version back, run the withdraw workflow from the Actions tab. It adds the version to a signed list on the release tagged withdrawals, which servers read.

Licensed under AGPL-3.0-or-later: see LICENSE and NOTICE.

Documentation

Index

Constants

View Source
const (
	ClassMain       = "main"
	ClassPlayAll    = "playAll"
	ClassEpisode    = "episode"
	ClassDecoy      = "decoy"
	ClassDuplicate  = "duplicate"
	ClassAlternate  = "alternate"
	ClassIntro      = "intro"
	ClassStub       = "stub"
	ClassTrailer    = "trailer"
	ClassFeaturette = "featurette"
	ClassExtra      = "extra"
	// ClassMenu: what plays behind a menu. It has a menu graphics stream and
	// little video of its own, and often plays one short clip over and over.
	ClassMenu = "menu"
)

Playlist classes (the same words WittyDVD uses for titles).

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
	UOPauseOff      = 1 << 54
	UOStillOff      = 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
	UOSelectActive  = 1 << 43
	UOPrimaryAudio  = 1 << 42
	UOAngle         = 1 << 40
	UOPopupOn       = 1 << 39
	UOPopupOff      = 1 << 38
	UOPGEnable      = 1 << 37
	UOPGChange      = 1 << 36
	UOSecVideoOn    = 1 << 35
	UOSecVideo      = 1 << 34
	UOSecAudioOn    = 1 << 33
	UOSecAudio      = 1 << 32
	UOPiPPG         = 1 << 30
)

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

View Source
const (
	SourceFeature  = ModuleID + ".feature"
	SourceScenes   = ModuleID + ".scenes"
	SourceEpisodes = ModuleID + ".episodes"
	SourceVersions = ModuleID + ".versions"
	SourceBonus    = ModuleID + ".bonus"
	SourceMenus    = ModuleID + ".menus"
	SourceWhy      = ModuleID + ".why"
	SourceCopy     = ModuleID + ".copy"
	SourceRefusal  = ModuleID + ".refusal"
)

The sources of a Blu-ray's sections on its page. Each takes the page's title ($item) and answers only for a Blu-ray: on any other title its sections are left out. WittyBluray's service answers them (package api; the commands are package commands, with no networking, for the player), asking the server's host API for what only the server keeps: the disc's ranking from this module's helper, checked there, and an administrator's choice of film. The names given to its playlists are WittyBluray's own.

View Source
const (
	PSRIGStream       = 0  // selected IG (menu) stream, 1-based
	PSRAudio          = 1  // selected primary audio stream, 1-based (0xff = none chosen yet)
	PSRPG             = 2  // bits 0..11: PG/text subtitle stream, 1-based (0xfff = none); bits 16..27: PiP subtitle stream; bit 31: subtitles shown; bit 30: PiP 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 (0xffff = none)
	PSRPage           = 11 // current menu page id
	PSRStyle          = 12 // user style number
	PSRParental       = 13 // parental level (the viewer's age; 255 = no limit)
	PSRSecondary      = 14 // bits 0..7: secondary audio; bits 8..15: secondary video; bits 30, 31: shown
	PSRAudioCap       = 15 // player audio 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 // the display's 3D abilities and width
	PSR3DCap          = 24
	PSRUHDCap         = 25
	PSRUHDDisplayCap  = 26
	PSRHDRPref        = 27
	PSRSDRConv        = 28
	PSRVideoCap       = 29 // bit 0: secondary video in HD; bit 1: 25 and 50 Hz video
	PSRTextCap        = 30 // text subtitle abilities
	PSRProfile        = 31 // player profile (bits 16..23) and version (bits 0..15)
	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 (
	Profile1v10 = 0x00000100 // the first players
	Profile1v11 = 0x00010110 // Bonus View: secondary streams and local storage
	Profile2v20 = 0x00030200 // BD-Live: network access
	Profile3v20 = 0x00080200 // audio-only players
	Profile5v24 = 0x00130240 // 3D
	Profile6v30 = 0x00000300 // Ultra HD
)

Player profiles as PSR31 carries them. A disc's program reads this to decide what to offer: 3D, BD-Live, secondary video.

View Source
const MaxStructureBytes = 16 << 20

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

View Source
const ModuleID = "wittybluray"

ModuleID is this module's ID, the same as module.json's.

View Source
const NoButton = 0xffff

NoButton means "none" in button references.

View Source
const NoSound = 0xff

NoSound is the button sound id meaning "none".

Variables

View Source
var DefaultWeights = Weights{
	DistinctPerMinute: 1,
	MissingClip:       -40,
	ZeroSize:          -40,
	OutOfRangeAny:     -10,
	OutOfRangeShare:   -20,
	Repeats:           -30,
	BackJumpAny:       -5,
	BackJumpShare:     -35,
	Continuity:        5,
	Shuffled:          -25,
	Duplicate:         -0.5,
	SegmentSpam:       -30,
	BadChapters:       -10,
	RegularChapters:   3,
	AudioMatch:        2,
	SubtitleMatch:     1,
	LargestSize:       5,
	Stereo3D:          -1,
	FirstPlay:         15,
	TitleOne:          10,
	MenuReference:     4,
	BDJListed:         4,
	Truncated:         -30,
	Forward:           2,
	BadConnection:     -3,
	BDJLocator:        8,
	BDJName:           5,
	BDJNumber:         2,
	Ambiguous:         0,
	Rewind:            -40,
}

DefaultWeights are the weights MainPlaylist uses.

View Source
var ManifestJSON []byte

ManifestJSON is this module's manifest (docs/MODULES.md, "The manifest").

Functions

func ClassConstants added in v0.4.0

func ClassConstants(b []byte) (strs []string, ints []int32)

ClassConstants reads a Java class file without loading it: the string constants its code uses, and the integer constants its bytecode pushes or switches on (bipush, sipush, ldc of an integer, lookupswitch keys). A file that is not a class, or is cut short, gives what was read up to there. Nothing in the file is executed.

func UI added in v0.4.0

func UI() *sdui.Module

UI is WittyBluray's part of every app (module API 5, WittyMediaServer docs/SDUI-MODULES.md), written to sdui.json beside module.json: a Blu-ray's sections on its page, in every look (Design 2's "discpage", "whytitle" and "discrefuse" boards), the TV apps' among them, and the commands its rows run (choosing the film, ranking again, comparing with libbluray), each one of its own routes. The player is WittyDisc's in a browser and each app's own screen elsewhere.

Types

type ATCSequence added in v0.4.0

type ATCSequence struct {
	StartSPN uint32
	FirstSTC int // the ID of its first time base
	STCs     int // how many time bases it holds
}

ATCSequence is one arrival-time sequence and the time bases inside it.

type AngleClip

type AngleClip struct {
	Clip  string
	Codec string
	STCID int
}

AngleClip is one angle's clip.

type BDJApp added in v0.3.0

type BDJApp struct {
	Control      int // 1 = starts by itself, 2 = another application starts it
	Type         int // 1 = BD-J
	Org          uint32
	ID           uint16
	Priority     int
	Binding      int
	Visibility   int
	Names        map[string]string // by language
	Icon         string
	BaseDir      string // the JAR file's name, without .jar
	ClassPath    string
	InitialClass string
	Params       []string
}

BDJApp is one application of the title.

type BDJCacheItem added in v0.3.0

type BDJCacheItem struct {
	Dir  bool // a folder rather than a JAR
	Name string
	Lang string // "*.*" = always; "%%%" = when no language matches
}

BDJCacheItem is a JAR file or folder to load before the title starts.

type BDJHint added in v0.4.0

type BDJHint struct {
	Playlist int `json:"playlist"`
	// Locators counts string constants that name the playlist in a locator
	// or as an .mpls file; Names, constants that are just its five digits;
	// Numbers, integer constants in bytecode equal to its number.
	Locators int `json:"locators,omitempty"`
	Names    int `json:"names,omitempty"`
	Numbers  int `json:"numbers,omitempty"`
	// Listed: a BD-J object's table of playable playlists has it.
	Listed bool `json:"listed,omitempty"`
}

BDJHint is one playlist a disc's Java program names.

type BDJHints added in v0.4.0

type BDJHints struct {
	Hints   []BDJHint `json:"hints,omitempty"` // by playlist number
	Objects int       `json:"objects"`         // BD-J objects read
	Jars    int       `json:"jars"`            // JAR files read
	Classes int       `json:"classes"`         // class files read
	// Incomplete: a limit was reached (too many or too large JARs or
	// classes) before everything had been read.
	Incomplete bool `json:"incomplete,omitempty"`
}

BDJHints is what the static look found.

func (*BDJHints) Hint added in v0.4.0

func (h *BDJHints) Hint(playlist int) *BDJHint

Hint returns what was found for a playlist, or nil.

type BDJObject added in v0.3.0

type BDJObject struct {
	Name    string
	Version string
	// DefaultFont names a font in AUXDATA ("" = none). HAViConfig is the
	// graphics configuration the applications start with.
	DefaultFont     string
	HAViConfig      int
	MenuCallMask    bool
	TitleSearchMask bool
	Cache           []BDJCacheItem
	// Playlists the applications may play. AccessToAll allows every playlist
	// on the disc; AutostartFirst plays the first one as the title starts.
	Playlists      []int
	AccessToAll    bool
	AutostartFirst bool
	Apps           []BDJApp
	KeyInterest    uint32 // the 11 remote keys the title wants, top bit first
	// FileAccess lists the folders the applications may read ("." = all).
	FileAccess []string
}

BDJObject is one .bdjo file.

func ParseBDJObject added in v0.3.0

func ParseBDJObject(name string, b []byte) (*BDJObject, error)

ParseBDJObject parses one .bdjo file.

func (*BDJObject) Autostart added in v0.3.0

func (o *BDJObject) Autostart() []*BDJApp

Autostart lists the applications that start with the title.

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 Candidate added in v0.4.0

type Candidate struct {
	PlaylistNum int      `json:"playlist"`
	Duration    float64  `json:"durationSec"`
	Distinct    float64  `json:"distinctSec"` // each readable segment counted once
	Chapters    int      `json:"chapters"`
	Items       int      `json:"items"`
	Clips       int      `json:"clips"`     // distinct clips named
	Size        int64    `json:"sizeBytes"` // the distinct clips' .m2ts bytes
	Audio       int      `json:"audioStreams"`
	Subtitles   int      `json:"subtitleStreams"` // PG streams
	Languages   []string `json:"audioLanguages,omitempty"`
	Angles      int      `json:"angles"`
	Score       float64  `json:"score"`
	Class       string   `json:"class"`
	Flags       Flag     `json:"flags"`
	Reasons     []string `json:"reasons"`
	// Evidence is Reasons in a form a program can use: one entry per signal
	// with its name, the points it gave or took, and the sentence.
	Evidence []Evidence `json:"evidence,omitempty"`
	// Video describes the main video stream: "1080p H.264", "2160p HEVC
	// HDR10", "1080p H.264 3D".
	Video             string   `json:"video,omitempty"`
	SubtitleLanguages []string `json:"subtitleLanguages,omitempty"`
	// Continuity is how well the play items follow on from each other, from
	// -1 (every join goes back) to 1 (every join continues in time): the
	// evidence that tells a film from a shuffled copy of it. 1 for a single
	// item.
	Continuity float64 `json:"continuity"`
	// Cluster groups playlists that play the same set of segments (decoys
	// are permutations and copies of one another): the lowest playlist
	// number in the group, and how many it holds. ClusterSize is 1 for a
	// playlist like no other.
	Cluster     int `json:"cluster"`
	ClusterSize int `json:"clusterSize"`
	// contains filtered or unexported fields
}

Candidate is one playlist as the engine scored it.

func (Candidate) Playlist added in v0.4.0

func (c Candidate) Playlist() *Playlist

Playlist is the playlist the candidate was scored from.

type Chapter added in v0.4.0

type Chapter struct {
	Number int `json:"number"` // 1-based
	// Mark is the index of the entry mark in Playlist.Marks, which is what
	// PLAY_PL_PM and LINK_MK name.
	Mark int    `json:"mark"`
	Item int    `json:"item"` // the play item the chapter starts in
	Clip string `json:"clip"`
	// ClipTime is the start in the clip's own time base (45 kHz), as the
	// mark gives it, moved inside the play item if the mark lay outside.
	ClipTime uint32 `json:"clipTime"`
	// Start and Duration are in seconds of the playlist's playing time.
	Start    float64 `json:"startSec"`
	Duration float64 `json:"durationSec"`
	// Adjusted: the mark's time lay outside its play item and was moved to
	// the item's start or end.
	Adjusted bool `json:"adjusted,omitempty"`
}

Chapter is one chapter of a playlist, in playing order.

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 pictures, 4 =
	// browsable slideshow audio, 5 = IG menu, 6 = text subtitles, 7 = other
	// sub-path streams (secondary audio or video).
	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
	// ATC lists the arrival-time sequences: stretches of the file recorded
	// in one go. A clip mastered for a disc has one; a second one means the
	// packet clock restarts mid-file.
	ATC []ATCSequence
	// Warnings names the parts of the file that were damaged and done
	// without (the program table, the entry-point map). The clip's length
	// and time bases were still read.
	Warnings []string
}

Clip is one .clpi file.

func ParseClip

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

ParseClip parses one .clpi file. The header, the clip information and the time bases must be readable; a damaged program table or entry-point map is left out and named in Warnings, because the clip's length and time bases are enough to describe and rank what plays it.

func (*Clip) Duration

func (c *Clip) Duration() float64

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

func (*Clip) EndPTS added in v0.3.0

func (c *Clip) EndPTS(stc int) uint32

EndPTS is where a time base ends (45 kHz), or 0 when the clip does not say.

func (*Clip) EntryAfter added in v0.3.0

func (c *Clip) EntryAfter(pid uint16, stc int, pts uint32) (e EPEntry, ok bool)

EntryAfter is the first entry point after a time on a video stream, within that time base; ok is false when there is none.

func (*Clip) EntryAt added in v0.3.0

func (c *Clip) EntryAt(pid uint16, stc int, pts uint32) (e EPEntry, ok bool)

EntryAt is SPNAt within one time base. A clip with several (the clock restarts mid-file, as when studios join separately encoded reels) has the same times more than once, and its entries are not in time order overall, so a play item's time only means something inside its own time base. stc -1 searches the whole map. A stream with no map of its own uses the clip's first one (audio-only clips map their audio).

func (*Clip) PlayableSeconds added in v0.4.0

func (c *Clip) PlayableSeconds(size int64) (sec float64, ok bool)

PlayableSeconds says how much of a clip a stream file of the given size can play: the time of the last entry point that lies inside the file, measured from the clip's start. ok is false when the clip has no entry-point map to tell by.

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) STCRange added in v0.3.0

func (c *Clip) STCRange(stc int) (from, to uint32, found bool)

STCRange is the source packets of a time base; found is false when the clip has only one, or no such number.

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 Cluster added in v0.4.0

type Cluster struct {
	// Kept is the member that stands for the group: the one in the most
	// natural order. Size counts all members; Shuffled those in a less
	// natural order, Duplicates those in exactly Kept's order.
	Kept       int     `json:"kept"`
	Size       int     `json:"size"`
	Shuffled   int     `json:"shuffled"`
	Duplicates int     `json:"duplicates"`
	Duration   float64 `json:"durationSec"`
	// Ambiguous: more than one member is in an equally natural order and
	// nothing else tells them apart.
	Ambiguous bool `json:"ambiguous,omitempty"`
}

Cluster is a group of playlists that play the same set of segments.

type Command

type Command struct {
	Op       uint32
	Dst, Src uint32
}

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

type Disagreement added in v0.4.0

type Disagreement struct {
	Playlist int    `json:"playlist"` // -1 for the disc as a whole
	Field    string `json:"field"`    // main, present, duration, chapters, chapterTimes, angles
	Ours     string `json:"ours"`
	Theirs   string `json:"theirs"`
	Note     string `json:"note,omitempty"`
}

Disagreement is one difference between this engine and a second opinion.

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's streams are scrambled (AACS or
	// otherwise). The engine never decrypts anything: such discs are refused
	// for playback. An AACS folder alone does not count, because a decrypted
	// copy usually keeps it; what matters is whether the video is readable.
	Encrypted bool
	// AACSFolder: the disc has an AACS folder. BDPlus: it has a BD+ program
	// (BDSVM). The engine does not run BD+ either; on such a copy some of the
	// picture may be damaged by design, which only the disc's own conversion
	// repairs.
	AACSFolder, BDPlus bool
	// Damaged names structures that could not be read from the disc or their
	// backups, and which were done without.
	Damaged []string
	// Recording: a BDAV or similar recording with no disc program; each clip
	// was made a playlist.
	Recording 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. Those run in a separate process when the server has Java (see
	// bdj.go); otherwise the disc plays from its playlists.
	BDJ bool

	// FromBackup names the structures read from the BACKUP folder because
	// the first copy was missing, damaged, or contradicted the rest of the
	// disc where the backup did not.
	FromBackup []string
	// Notes are remarks on how the disc was read that are not damage: a
	// backup that differs from the first copy, a copy with no disc program,
	// structures left out because the disc holds more than a disc can.
	Notes []string
	// MovieOnly: the copy has playlists and clips but neither index.bdmv nor
	// MovieObject.bdmv (a "movie only" copy). There is no disc program to
	// run or read; the playlists' structure alone decides the feature.
	MovieOnly bool
	// contains filtered or unexported fields
}

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 OpenSource added in v0.4.0

func OpenSource(src Source) (*Disc, error)

OpenSource opens a disc from any Source: a reader of the caller's own (a network share, an archive, a test's synthetic disc). The disc is laid out as on a Blu-ray, with BDMV at the root. Close closes the source.

func (*Disc) Analyze added in v0.4.0

func (d *Disc) Analyze(opt RankOptions) *Ranking

Analyze scores and classifies every playlist. Its cost grows with the number of play items on the disc, not with the square of the number of playlists: playlists are compared through hashes of their segments, and against a fixed number of reference playlists.

func (*Disc) BDJObject added in v0.3.0

func (d *Disc) BDJObject(name string) (*BDJObject, error)

BDJObject reads a BD-J object by name, from its backup copy if it is damaged.

func (*Disc) BDJStaticHints added in v0.4.0

func (d *Disc) BDJStaticHints() *BDJHints

BDJStaticHints reads the disc's BD-J objects and JAR files for the playlists they name, without running anything. Only playlists the disc has are reported. Worked out once per opened disc; nil when the disc has no BD-J object.

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) ClipLead added in v0.3.0

func (d *Disc) ClipLead(clip string, video uint16, from uint32, only ...uint16) float64

ClipLead says how long before the first picture a stretch of a clip's earliest packet lies, in seconds: usually sound, stored ahead of its picture. A demuxer puts an input on its timeline by that packet, so whoever joins clips must allow for it. video is the picture's PID; 0 when nothing can be told. only, when given, limits which streams count.

func (*Disc) Close

func (d *Disc) Close() error

Close releases the image.

func (*Disc) Consistency added in v0.4.0

func (d *Disc) Consistency() []Inconsistency

Consistency lists where the disc's playlists, clip information and stream files disagree, the most serious first. It reads structure and file sizes only, never stream content. Worked out once per opened disc; at most a thousand entries are kept.

func (*Disc) Episodes added in v0.4.0

func (d *Disc) Episodes() []Episode

Episodes lists the episodes of a TV disc in viewing order; nil when the disc doesn't look like one.

func (*Disc) Explain added in v0.4.0

func (d *Disc) Explain() string

Explain words the ranking for people: the pick, why, and warnings.

func (*Disc) ExportProgram added in v0.3.0

func (d *Disc) ExportProgram(dst string, maxBytes int64) error

ExportProgram copies the disc's program files (not its video) into a folder laid out as the disc is, for a BD-J runtime that reads them as files. Every name is checked: a disc cannot place a file outside dst.

func (*Disc) FirstPlayReach added in v0.4.0

func (d *Disc) FirstPlayReach() Reach

FirstPlayReach is StaticReach from the index's first play, following title jumps, with the registers as they are when a disc is put in (all zero), so a program's "have I been here before" test goes the way it does on a first run.

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 finds the feature with the playlist ranking engine (heuristics.go): distinct, readable video counts most, because longest is what some discs try to defeat: copy-protection schemes add hundreds of playlists that loop a clip, name clips that are not there or are empty, run past a clip's end, or shuffle the real film's clips into nonsense. Those are scored down or ruled out; among the rest the one the disc's program leads to, the one whose clips follow on from each other, and the one with even chapters gain. A disc with no video at all (a music disc) picks by sound. The answer is worked out once per opened disc.

func (*Disc) Meta added in v0.4.0

func (d *Disc) Meta() *DiscMeta

Meta reads the disc library metadata, in English when the disc has it and otherwise in its first language. nil when the disc has none that reads. Worked out once per opened disc.

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) RankPlaylists added in v0.4.0

func (d *Disc) RankPlaylists() []Candidate

RankPlaylists scores every playlist, the pick first, then best first.

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) ReadProgramFile added in v0.3.0

func (d *Disc) ReadProgramFile(rel string, max int64) ([]byte, error)

ReadProgramFile reads a file of the disc's program by its path under BDMV.

func (*Disc) Sounds added in v0.3.0

func (d *Disc) Sounds() *Sounds

Sounds reads the disc's button sounds; nil when it has none.

func (*Disc) StaticReach added in v0.4.0

func (d *Disc) StaticReach(o IndexObject, followTitles bool) Reach

StaticReach follows an index entry through the movie objects: their commands in command order, with JUMP/CALL_OBJECT followed at once (depth first, so the order of Playlists is close to the order they would play). With followTitles, JUMP/CALL_TITLE to a numbered title is followed too (never to the top menu or first play).

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.

func (*Disc) SubtitlesIn added in v0.3.0

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

SubtitlesIn is Subtitles within one time base of the clip (-1 = all). The read starts a little before `from`, since a picture is stored ahead of the time it shows.

func (*Disc) TextSubtitles added in v0.3.0

func (d *Disc) TextSubtitles(clip string, pid uint16, charCode int) ([]TextCue, error)

TextSubtitles reads a text subtitle clip whole (they are small). charCode is the stream's character coding from the playlist.

func (*Disc) TitleReach added in v0.4.0

func (d *Disc) TitleReach(n int) Reach

TitleReach is StaticReach from a title (1-based), following title jumps.

type DiscMeta added in v0.4.0

type DiscMeta struct {
	Language string         `json:"language,omitempty"` // three letters, from the file's name
	Name     string         `json:"name,omitempty"`     // the disc's name
	Titles   map[int]string `json:"titles,omitempty"`   // title number -> name
	// Languages lists every language the disc has such a file for.
	Languages []string `json:"languages,omitempty"`
}

DiscMeta is the disc library metadata in one language.

func ParseDiscMeta added in v0.4.0

func ParseDiscMeta(b []byte) *DiscMeta

ParseDiscMeta reads one bdmt_xxx.xml. It follows no reference out of the document (the decoder has no external entities) and stops after a fixed number of elements. nil when the document names nothing.

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 Edition added in v0.4.0

type Edition struct {
	Playlist int     `json:"playlist"`
	Duration float64 `json:"durationSec"`
	// Shared is the playing time it has in common with the main playlist,
	// Own the time of video that only this cut has among the editions.
	Shared float64 `json:"sharedSec"`
	Own    float64 `json:"ownSec"`
	// Label: "longest cut", "shortest cut" or "cut" for those between.
	Label    string `json:"label"`
	Chapters int    `json:"chapters"`
	Main     bool   `json:"main,omitempty"`
	// ByProgram: the disc's program is seen to play it.
	ByProgram bool `json:"byProgram,omitempty"`
}

Edition is one cut of a film with several.

type Effect added in v0.3.0

type Effect struct {
	DurationSec float64
	Palette     int
	Objects     []compObject
}

Effect is one step of a transition: pictures placed in windows, for a time.

func (*Effect) GobDecode added in v0.3.0

func (e *Effect) GobDecode(b []byte) error

GobDecode reads an effect and checks it.

func (Effect) GobEncode added in v0.3.0

func (e Effect) GobEncode() ([]byte, error)

GobEncode sends an effect with where its pictures go.

type EffectSequence added in v0.3.0

type EffectSequence struct {
	Windows []Window
	Effects []Effect
}

EffectSequence is a page transition: a list of timed compositions.

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
	// NavTimerOff: SET_NV_TIMER with a time of 0 cancelled the timer.
	NavTimerOff bool
}

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

type Episode added in v0.4.0

type Episode struct {
	Index    int     `json:"index"` // 1-based viewing order
	Playlist int     `json:"playlist"`
	Duration float64 `json:"durationSec"`
	Chapters int     `json:"chapters"`
}

Episode is one episode of a TV disc, in viewing order.

type Evidence added in v0.4.0

type Evidence struct {
	Signal string  `json:"signal"` // distinct, continuity, backJumps, firstPlay, shuffled, ...
	Points float64 `json:"points"`
	Detail string  `json:"detail"`
}

Evidence is one signal's contribution to a candidate's score.

type Extension added in v0.4.0

type Extension struct {
	ID1, ID2 int
	Length   int
}

Extension is one block of a playlist's extension data. ID1 2 with ID2 1 is the 3D stream table, ID1 2 with ID2 2 more sub-paths, ID1 1 with ID2 1 picture-in-picture placement.

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 Flag added in v0.4.0

type Flag uint32

Flag marks what the engine found out about a playlist.

const (
	FlagMain        Flag = 1 << iota // the engine's pick
	FlagDecoy                        // structure-protection decoy or junk
	FlagMenuTarget                   // a title's HDMV program plays it, or a BD-J object lists it
	FlagFirstPlay                    // first play reaches this long playlist (static reading)
	FlagTitleOne                     // title 1 reaches this long playlist (static reading)
	FlagIntro                        // a short playlist first play passes on its way
	FlagEpisode                      // one episode of a TV disc
	FlagPlayAll                      // plays the episodes one after another
	FlagDuplicate                    // the same segments in the same order as a lower-numbered playlist
	FlagShuffled                     // another playlist's segments in a less natural order
	FlagOutOfRange                   // in or out times outside the clip's time base
	FlagRepeats                      // replays the same segments
	FlagSegmentSpam                  // many play items under a second or a few seconds long
	FlagMissingClip                  // names a clip whose .clpi or .m2ts is missing
	FlagZeroSize                     // names a clip whose .m2ts is empty
	FlagBadChapters                  // chapter marks name play items that don't exist
	FlagAlternate                    // mostly the main playlist's video (another cut)
	FlagStereo3D                     // has a 3D (MVC) dependent view
	FlagMultiAngle                   // has a multi-angle play item
	FlagAudioOnly                    // no video stream: a music disc's playlist
	FlagTruncated                    // names a clip whose .m2ts is much shorter than its information says
	FlagAmbiguous                    // one of several playlists of the same video that nothing tells apart
	FlagEdition                      // one cut of a film that has several (seamless branching)
	FlagBDJTarget                    // the disc's Java program names it (static reading of its JAR files)
	FlagUHD                          // 2160p video
	FlagHDR                          // HDR10, HDR10+ or Dolby Vision video
	FlagMenu                         // a menu's background: menu graphics over a short loop
)

func (Flag) Has added in v0.4.0

func (f Flag) Has(g Flag) bool

Has reports whether every flag in g is set.

func (Flag) MarshalJSON added in v0.4.0

func (f Flag) MarshalJSON() ([]byte, error)

MarshalJSON writes the flags as a list of names.

func (Flag) Names added in v0.4.0

func (f Flag) Names() []string

Names lists the flags set, in a fixed order.

func (Flag) String added in v0.4.0

func (f Flag) String() string

func (*Flag) UnmarshalJSON added in v0.4.0

func (f *Flag) UnmarshalJSON(b []byte) error

UnmarshalJSON reads a list of flag names; unknown names are ignored.

type Group

type Group int

Group is a command's group.

const (
	GroupBranch Group = iota
	GroupCompare
	GroupSet
)

type Inconsistency added in v0.4.0

type Inconsistency struct {
	// Severity: "error" when something cannot play as written, "warn" when
	// it plays but not as the disc describes, "info" for oddities.
	Severity string `json:"severity"`
	// Kind names the check: clipMissing, streamMissing, streamEmpty,
	// streamShort, streamLong, streamUnaligned, timesOutside, emptyItem,
	// stcOrder, entryPastEnd, bitrate, markNoItem, markOutside,
	// angleMissing, subClipMissing.
	Kind     string `json:"kind"`
	Playlist int    `json:"playlist"` // -1 when it is about a clip alone
	Clip     string `json:"clip,omitempty"`
	What     string `json:"what"`
	// PlayableSec, for streamShort: how much of the clip the bytes that are
	// there can play, by the clip's entry-point map. 0 when it cannot be told.
	PlayableSec float64 `json:"playableSec,omitempty"`
}

Inconsistency is one disagreement between a disc's structures.

type Index

type Index struct {
	Version    string
	Stereo3D   bool // the disc prefers 3D output when the player can
	HasContent bool // the disc says it holds 3D content
	// DynamicRange is the initial dynamic range of an Ultra HD disc.
	DynamicRange int
	// 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
	// Timeout and SelectionTimeout are the stream times (seconds, 0 = none)
	// when the menu ends and when selection ends and the default activated
	// button runs. UserTimeout is how long a pop-up stays with no key pressed.
	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) DrawEffect(seq *EffectSequence, i int) *image.NRGBA

DrawEffect paints one step of a transition on a full frame.

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) GobDecode(b []byte) error

GobDecode reads a menu and checks it.

func (m *Menu) GobEncode() ([]byte, error)

GobEncode sends a menu with its palettes and pictures.

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. An Ultra HD disc gets an Ultra HD player: such discs ask, and refuse to start on anything else.

func (n *Nav) Clone() *Nav

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

func (n *Nav) Forbids(uo uint64) bool

Forbids says whether the playing playlist or item forbids a user operation (a UO constant).

func (n *Nav) LoopsAtEnd(st *Step) bool

LoopsAtEnd says whether the disc's program starts this same playlist again when it ends. Such a menu plays as one seamless loop; anything else (a menu that moves on by itself) must be reported as ended.

func (n *Nav) MenuAllowed() bool

MenuAllowed says whether the disc lets the viewer call the menu now: the movie object or the playing playlist and item can forbid it.

func (n *Nav) MenuCall() *Step

MenuCall is the user's Menu key: the top menu. When the disc's program means the playing object to be resumed (its resume-intention flag), it is suspended so RESUME can return; otherwise it ends here. A disc that masks the key sees nothing happen.

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 what a call or menu call suspended.

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) SetMenuState(page, button int)

SetMenuState records the page and button on show, which a disc's commands read to find out what was pressed.

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) SkipItem(delta int) (st *Step, ok bool)

SkipItem moves within an item-by-item playlist (a slideshow), one way or the other; ok is false when the playlist does not play that way or has no such item.

func (n *Nav) Start() *Step

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

func (n *Nav) Timer() *NavTimer

Timer is the navigation timer running now, or nil. The player starts its clock when this changes and calls NavTimerFired when it runs out.

type NavOptions struct {
	Registers RegisterOptions
}

NavOptions configure the player the navigator simulates.

type NavTarget struct {
	Object int    `json:"object"` // the movie object the command is in
	PC     int    `json:"pc"`     // the command's index in it
	Op     string `json:"op"`     // PLAY_PL, PLAY_PL_PI, PLAY_PL_PM, JUMP_OBJECT, JUMP_TITLE, CALL_OBJECT, CALL_TITLE
	// Value is the playlist, object or title; -1 when the operand is a
	// register whose value can't be told statically.
	Value int `json:"value"`
	// Arg is PLAY_PL_PI's play item or PLAY_PL_PM's mark; -1 otherwise or
	// when unknown.
	Arg int `json:"arg"`
	// FromRegister: the operand is a register, and Value is a constant the
	// program put there.
	FromRegister bool `json:"fromRegister,omitempty"`
	// Alternatives is how many values the register may hold at this
	// command (each is listed as a target of its own); 0 or 1 for one.
	Alternatives int `json:"alternatives,omitempty"`
	// Conditional: the command is only reached past a comparison that the
	// reading could not decide.
	Conditional bool `json:"conditional,omitempty"`
	// Dead: no path through the object's commands reaches this one. It is
	// listed because a reading can be wrong, and never followed.
	Dead bool `json:"dead,omitempty"`
}

NavTarget is one place a movie object's commands lead.

func ObjectTargets added in v0.4.0

func ObjectTargets(m MovieObject, index int) []NavTarget

ObjectTargets reads a movie object's commands by itself, knowing nothing of the registers on entry, and lists every PLAY_PL, PLAY_PL_PI, PLAY_PL_PM, JUMP/CALL_OBJECT and JUMP/CALL_TITLE in command order. A register operand gives one target for each constant the object's own commands may have put there, and a target with Value -1 when it cannot be told. Commands that no path reaches are listed with Dead set.

func (t NavTarget) IsPlay() bool

IsPlay says the target starts a playlist.

type NavTimer struct {
	Seconds uint32
	Object  int
}

NavTimer is SET_NV_TIMER: run a movie object after some seconds (at most 300).

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
)

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
	// In and Out are the page's transition effects, played as it opens and
	// closes.
	In, Out EffectSequence
}

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 Part added in v0.4.0

type Part struct {
	Index     int     `json:"index"`     // 1-based
	FirstItem int     `json:"firstItem"` // play items, inclusive
	LastItem  int     `json:"lastItem"`
	Start     float64 `json:"startSec"`
	Duration  float64 `json:"durationSec"`
	// Episode is the per-episode playlist this part matches, or -1.
	Episode int `json:"episode"`
}

Part is one stretch of a play-all playlist.

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
	DV               []Stream // Dolby Vision enhancement layers
}

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
	// AudioMix: the disc mixes button sounds and secondary audio into the
	// primary audio. LosslessBypass: it allows lossless output unmixed.
	// RightEyeBase: on a 3D playlist the base (2D) view is the right eye.
	AudioMix, LosslessBypass, RightEyeBase bool
	Items                                  []PlayItem
	SubPaths                               []SubPath
	Marks                                  []Mark
	// ExtSubPaths are the sub-paths kept in the file's extension data, where
	// 3D discs put the dependent view and Ultra HD discs the Dolby Vision
	// layer. Stream entries never index them, so they are apart from SubPaths.
	ExtSubPaths []SubPath
	// Stereo3D: the playlist has a 3D stream table or a dependent-view
	// sub-path (in SubPaths or in the extension data).
	Stereo3D bool
	// Extensions lists the blocks of extension data the file carries.
	Extensions []Extension
	// Warnings names what was damaged in the file and done without: a stream
	// table cut short, chapter marks that could not be read. The play items
	// themselves were read, or parsing would have failed.
	Warnings []string
}

Playlist is one .mpls file.

func ParsePlaylist

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

ParsePlaylist parses one .mpls file. The play items must be readable. A stream table that runs past its own length keeps the streams read so far, and unreadable chapter marks, sub-paths or extension data are left out; each is named in Warnings.

func (*Playlist) Chapters added in v0.4.0

func (pl *Playlist) Chapters() []Chapter

Chapters maps the playlist's entry marks onto its playing time. Link points (mark type 2) are not chapters. A mark naming a play item that does not exist is left out; a mark whose time lies outside its item is moved to the item's nearer end; marks are put in playing order, and two at the same instant count once. The last chapter runs to the end of the playlist. nil when the playlist has no usable entry mark.

func (*Playlist) SubClip added in v0.3.0

func (pl *Playlist) SubClip(s Stream) string

SubClip finds the clip a stream outside the main path is in: its sub-path and the numbered clip of that sub-path's first item.

type Program

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

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

type ProgramReading added in v0.4.0

type ProgramReading struct {
	// Kind: "hdmv" (movie objects were read), "bdj" (first play or title 1
	// is Java), "none" (a copy without a program).
	Kind string `json:"kind"`
	// Certain: the playlists first play is sure to play, whatever the
	// player's state.
	Certain []int `json:"certain,omitempty"`
	// Unknown counts playlist, object and jump operands that were registers
	// of unknown value. Incomplete: the reading ran out of budget.
	Unknown    int  `json:"unknown,omitempty"`
	Incomplete bool `json:"incomplete,omitempty"`
	// BDJClasses is how many Java class files were read for constants, and
	// BDJNamed how many of the disc's playlists they name.
	BDJClasses int `json:"bdjClasses,omitempty"`
	BDJNamed   int `json:"bdjNamed,omitempty"`
}

ProgramReading says what the static reading of the disc's program gave.

type RankOptions added in v0.4.0

type RankOptions struct {
	// ClipSizes is the size in bytes of each clip's .m2ts file (-1 when the
	// file is missing). nil reads them from the disc's Source when it has
	// one; a disc without a Source is ranked without them.
	ClipSizes map[string]int64
	Weights   *Weights
	// ClipOffsets is where each clip's stream file begins on the disc, in
	// bytes from the start of the image. A film's clips lie in playing
	// order (a player cannot seek back between them without a pause), so
	// the order is evidence. nil reads them from an image's Source; a
	// folder of files has none.
	ClipOffsets map[string]int64
	// SecondOpinion is another reader's account of the disc to compare
	// with; nil for none.
	SecondOpinion *SecondOpinion
	// NoBDJ skips the static reading of a BD-J disc's JAR files.
	NoBDJ bool
}

RankOptions add what the caller knows beyond the disc's structures.

type Ranking added in v0.4.0

type Ranking struct {
	Candidates []Candidate `json:"candidates"` // the pick first, then best first
	Main       int         `json:"main"`       // -1 when no playlist can be the feature
	PlayAll    int         `json:"playAll"`    // -1 when none
	Episodes   []Episode   `json:"episodes,omitempty"`
	Decoys     []int       `json:"decoys,omitempty"`
	FirstPlay  int         `json:"firstPlay"` // long playlist first play reaches; -1 none
	TitleOne   int         `json:"titleOne"`  // long playlist title 1 reaches; -1 none
	// BDJ: the disc's first play or title 1 is a Java program, which this
	// engine doesn't run; the ranking falls back to structure, helped by a
	// static reading of the program's constants.
	BDJ      bool     `json:"bdj,omitempty"`
	Warnings []string `json:"warnings,omitempty"`

	// Confidence says how sure the pick is, from 0 to 1, and
	// ConfidenceLabel the same as "high", "medium" or "low". Why gives the
	// reasons for the pick and for the confidence in short sentences, the
	// weightiest first: what a server shows as "why this playlist".
	Confidence      float64  `json:"confidence"`
	ConfidenceLabel string   `json:"confidenceLabel"`
	Why             []string `json:"why,omitempty"`
	// Editions lists the cuts of a film that shares its video between
	// several playlists (seamless branching: theatrical and extended), the
	// main one included, longest first. Empty when there is one cut.
	Editions []Edition `json:"editions,omitempty"`
	// Clusters summarises the groups of playlists that play the same
	// segments: the decoys of an obfuscated disc show as a few large ones.
	Clusters []Cluster `json:"clusters,omitempty"`
	// PlayAllParts splits a play-all playlist where its episodes begin.
	// With per-episode playlists these are the Episodes mapped onto it;
	// without, they are a guess from play items of even length, and
	// Episodes stays empty.
	PlayAllParts []Part `json:"playAllParts,omitempty"`
	// Chapters are the main playlist's chapters, mapped onto its playing time.
	Chapters []Chapter `json:"chapters,omitempty"`
	// Stereo3D, UHD and HDR describe the main playlist's video. HDR is "",
	// "HDR10", "HDR10+" or "Dolby Vision".
	Stereo3D bool   `json:"stereo3d,omitempty"`
	UHD      bool   `json:"uhd,omitempty"`
	HDR      string `json:"hdr,omitempty"`
	// MovieOnly: the copy has no disc program at all.
	MovieOnly bool `json:"movieOnly,omitempty"`
	// Program says how the disc's own program was read for this ranking.
	Program ProgramReading `json:"program"`
	// Inconsistencies counts the disagreements between playlists, clip
	// information and stream files by kind (see Disc.Consistency).
	Inconsistencies map[string]int `json:"inconsistencies,omitempty"`
	// SecondOpinion is the comparison with another reader of the disc
	// (libbluray, when the user has it installed and the caller passed its
	// answer in). nil when there was none.
	SecondOpinion *SecondOpinionReport `json:"secondOpinion,omitempty"`
}

Ranking is the engine's full answer for a disc. Playlist numbers start at 0 (00000.mpls is a real playlist), so "none" is -1.

func (*Ranking) Candidate added in v0.4.0

func (r *Ranking) Candidate(playlist int) *Candidate

Candidate returns the scored playlist by number, or nil.

func (*Ranking) Explain added in v0.4.0

func (r *Ranking) Explain() string

Explain words a ranking for people: the pick, how sure it is and why, the top candidates with their reasons, and the warnings.

type Reach added in v0.4.0

type Reach struct {
	Playlists []int       `json:"playlists"` // in the order found, each once
	Titles    []int       `json:"titles,omitempty"`
	Objects   []int       `json:"objects,omitempty"` // movie objects visited
	Targets   []NavTarget `json:"targets,omitempty"`
	// Unknown counts targets whose operand is a register with no known value.
	Unknown int `json:"unknown,omitempty"`
	// BDJ: the chain reaches a BD-J object, which can't be read statically.
	BDJ bool `json:"bdj,omitempty"`
	// Certain lists the playlists reached by commands that are not behind
	// an undecided comparison and whose operand had one value: the ones the
	// program plays whatever the player's state.
	Certain []int `json:"certain,omitempty"`
	// Incomplete: the reading ran out of its budget of work or objects
	// before it had followed everything.
	Incomplete bool `json:"incomplete,omitempty"`
}

Reach is what an entry of the index leads to, read statically.

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
	UHD                               bool   // an Ultra HD player (for Ultra HD discs, which ask)
}

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

type Registers

type Registers struct {
	GPR [4096]uint32
	PSR [128]uint32
	// Rand returns a number in [0,1) for RND; tests and diagnostic tools set
	// it to make a run repeatable. nil uses the system generator.
	Rand func() float64
}

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. Registers nobody has chosen yet start at the "none" values the format defines: a disc sees 0xff for the audio stream until a stream is selected, and its program can tell a first visit to a menu from a later one that way.

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 = 1000000; a disc's program cannot loop for ever
	// Button: the commands belong to a menu button, not a movie object. Some
	// commands only mean something there (LINK, TERMINATE_PL, POPUP_OFF,
	// stills), and changing the page ends the button's commands.
	Button bool
}

RunOptions limit a run.

type STCSequence

type STCSequence struct {
	ID         int // the number play items name it by
	ATC        int // index into Clip.ATC
	PCRPID     uint16
	StartSPN   uint32
	Start, End uint32 // presentation times, 45 kHz
}

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

type SecondOpinion added in v0.4.0

type SecondOpinion struct {
	Source string               `json:"source"` // "libbluray 1.3.4"
	Main   int                  `json:"main"`   // the playlist it would play as the feature; -1 none
	Titles []SecondOpinionTitle `json:"titles"`
}

SecondOpinion is another reader's account of the disc, to compare with. The libbluray package fills one in from a user-installed libbluray.

type SecondOpinionReport added in v0.4.0

type SecondOpinionReport struct {
	Source string `json:"source"`
	Main   int    `json:"main"`
	// AgreesOnMain: it picks the same playlist, or one that plays the same
	// segments in the same order.
	AgreesOnMain  bool           `json:"agreesOnMain"`
	Disagreements []Disagreement `json:"disagreements,omitempty"`
	// More counts disagreements past the first fifty.
	More int `json:"more,omitempty"`
}

SecondOpinionReport is how the second opinion compares.

type SecondOpinionTitle added in v0.4.0

type SecondOpinionTitle struct {
	Playlist int     `json:"playlist"`
	Duration float64 `json:"durationSec"`
	Chapters int     `json:"chapters"`
	Angles   int     `json:"angles"`
	// ChapterStarts in seconds of playing time, when the reader gives them.
	ChapterStarts []float64 `json:"chapterStarts,omitempty"`
}

SecondOpinionTitle is one playlist as the other reader sees it.

type SoundClip added in v0.3.0

type SoundClip struct {
	Channels int
	Rate     int
	// contains filtered or unexported fields
}

SoundClip is one sound, by its place in the file (the id buttons name).

type Sounds added in v0.3.0

type Sounds struct {
	Clips []SoundClip
	// contains filtered or unexported fields
}

Sounds is a disc's sound.bdmv.

func ParseSounds added in v0.3.0

func ParseSounds(b []byte) (*Sounds, error)

ParseSounds parses sound.bdmv.

func (*Sounds) GobDecode added in v0.3.0

func (s *Sounds) GobDecode(b []byte) error

GobDecode reads a disc's button sounds and checks that each lies in their data.

func (*Sounds) GobEncode added in v0.3.0

func (s *Sounds) GobEncode() ([]byte, error)

GobEncode sends a disc's button sounds.

func (*Sounds) WAV added in v0.3.0

func (s *Sounds) WAV(id int) ([]byte, bool)

WAV returns one clip as a WAV file, which every browser plays.

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
	// ItemOnly: play just this item, then report PlaylistEnded; the navigator
	// says which item comes next. Set for random and shuffle playlists, items
	// with a still, and playlists whose items do not share one set of streams.
	ItemOnly bool
	// StillSec is how long the picture holds after what this step plays: 0 =
	// not at all, -1 = until the viewer acts.
	StillSec float64
	// 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
	// BDJ names the BD-J object of a StepUnsupported step.
	BDJ string
}

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 (Step.BDJ names it): run it if the player can, else 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 TextCue added in v0.3.0

type TextCue struct {
	Start, End uint32 // 45 kHz, in the clip's time base
	Forced     bool
	Style      TextStyle
	Text       string // lines separated by \n
}

TextCue is one dialog: its words, when, and in what style.

type TextStyle added in v0.3.0

type TextStyle struct {
	ID            int
	X, Y, W, H    int // the region on the video frame
	Background    color.RGBA
	BoxX, BoxY    int // the text box, relative to the region
	BoxW, BoxH    int
	Flow          int // 1 = left to right, 2 = right to left, 3 = top to bottom
	HAlign        int // 1 = left, 2 = centre, 3 = right
	VAlign        int // 1 = top, 2 = middle, 3 = bottom
	LineSpace     int
	Bold, Italic  bool
	Outline       bool
	FontSize      int
	Color         color.RGBA
	OutlineColor  color.RGBA
	OutlineWeight int
}

TextStyle is a region style of the dialog style segment.

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 Weights added in v0.4.0

type Weights struct {
	DistinctPerMinute float64 // per minute of distinct, readable video
	MissingClip       float64 // names a clip whose .clpi or .m2ts is missing
	ZeroSize          float64 // names a clip whose .m2ts is empty
	OutOfRangeAny     float64 // any item's in/out time is outside the clip's time base
	OutOfRangeShare   float64 // times the share of such items
	Repeats           float64 // times the share of play time spent on repeats
	BackJumpAny       float64 // any join goes back (a lower clip, or earlier in the same clip)
	BackJumpShare     float64 // times the share of joins that go back
	Continuity        float64 // times the share of joins that continue seamlessly (PTS or SPN)
	Shuffled          float64 // another playlist's segments in a less natural order
	Duplicate         float64 // identical to a lower-numbered playlist (tie breaker)
	SegmentSpam       float64 // most items are under a second, or a few seconds, long
	BadChapters       float64 // chapter marks point nowhere
	RegularChapters   float64 // three or more chapters of sensible, even length
	AudioMatch        float64 // among the long playlists, has the most audio streams
	SubtitleMatch     float64 // among the long playlists, has the most PG streams
	LargestSize       float64 // its clips hold the most bytes
	Stereo3D          float64 // a 3D playlist (the 2D one is preferred: it plays here as 2D)
	FirstPlay         float64 // first play reaches it by itself
	TitleOne          float64 // title 1 reaches it
	MenuReference     float64 // a title's HDMV program plays it
	BDJListed         float64 // the BD-J object of first play or title 1 lists it among a few
	Truncated         float64 // times the share of play time on clips whose stream file is cut short
	Forward           float64 // times the share of joins that only go forward on the disc
	BadConnection     float64 // an item claims to continue its clock from the last one and does not
	BDJLocator        float64 // the Java program has a locator or file name for it
	BDJName           float64 // the Java program has its five digits as a string
	BDJNumber         float64 // the Java program pushes its number, and few other long playlists'
	Ambiguous         float64 // nothing tells it from a sibling of the same video
	Rewind            float64 // times the share of joins that go back inside one clip
}

Weights tune the scoring. Scores are in "minutes of distinct video": a weight of 15 is worth as much as a quarter of an hour of unique segments.

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 api is a disc module's own HTTP API and SDUI sources (module API 5): a disc's page, why a title is its film and the choice of another, the names given to its titles and chapters, and its sections on a title's page in every app.
Package api is a disc module's own HTTP API and SDUI sources (module API 5): a disc's page, why a title is its film and the choice of another, the names given to its titles and chapters, and its sections on a title's page in every app.
Package bdj runs a disc's BD-J applications.
Package bdj runs a disc's BD-J applications.
Package cli holds the commands of the standalone wittybluray tool.
Package cli holds the commands of the standalone wittybluray tool.
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.
wittybluray-module command
Command wittybluray-module is WittyBluray as a helper process, so a new version can reach a server without a new server.
Command wittybluray-module is WittyBluray as a helper process, so a new version can reach a server without a new server.
Package commands is the disc module's own commands, as its sdui.json declares them.
Package commands is the disc module's own commands, as its sdui.json declares them.
Package helper is WittyBluray's side of running as a helper process: one opened disc and its navigator, answering the server's calls.
Package helper is WittyBluray's side of running as a helper process: one opened disc and its navigator, answering the server's calls.
Package libbluray asks a libbluray that the user has installed for a second opinion on a disc's navigation, and compares it with WittyBluray's own reading.
Package libbluray asks a libbluray that the user has installed for a second opinion on a disc's navigation, and compares it with WittyBluray's own reading.

Jump to

Keyboard shortcuts

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