< Inside DVD-Video

DVD-Video specifies a low-level machine-language instruction set that is used to define interactions with the user. Instruction sequences are invoked when the user selects an on-screen button, and may also be triggered at various other points, such as the end of a cell or a PGC, or when the disc is inserted into the player.

The instruction set is commonly referred to as the “VM” (Virtual Machine) language, but the implication of calling it “virtual” is that there cannot be real hardware that directly implements this instruction set. But why not? That’s why I am here using the term “interaction machine”, which makes it clearer what the purpose of the instruction set is.

(Note that I’m avoiding using the term “program” for sequences of instructions in this instruction set, because that already has a completely different meaning in DVD-Video.)

Basic Concepts

Data Model

The only available data storage consists of 16 general-purpose parameter registers (GPRMs) and 24 system parameter registers (SPRMs). Each holds a single 16-bit unsigned integer value. As their name indicates, GPRMs may be freely used for any purpose, while the SPRMs have predefined meanings.

Any GPRM may also be put into counter mode, where its value increments once per second.

Instruction Format

Each instruction is 8 bytes, and can encode up to 3 separate operations, up to one from each of the following categories:

  • Setting a register
  • Transferring control
  • Performing a comparison, the result of which is used to control conditional execution of the rest of the instruction.

The top three bits of the first byte define the instruction group, as follows:

  • Group 0: miscellaneous (including transfer of control within an instruction sequence). These can also be made conditional according to format 1 (below).
  • Group 1: Link/Jump/Call: transfer of control between parts of the video stream. The Link instructions can be made conditional according to format 1, while Jump and Call use conditional format 2.
  • Group 2: set SPRM. This also includes the instructions for setting GPRMs in counter mode. These can be made conditional according to format 2, or combined with a Link, but not both at once.
  • Group 3: set GPRM. These can be made conditional according to format 3, or combined with a Link, but not both at once.

Groups 4, 5 and 6 perform a set GPRM, comparison and a link, all in one instruction, but with the three operations interacting as follows:

  • Group 4: perform the set, perform the comparison, and conditionally link.
  • Group 5: perform the comparison, and conditionally set and link.
  • Group 6: perform the comparison, and conditionally perform the set. Always link.

Group 7 does not seem to be used.

Register numbering: fields for reading the value of a register are 8 bits wide, and can access both GPRMs and SPRMs. Bit 7 is 0 to indicate a GPRM access, 1 for an SPRM access. The actual register number is in the rest of the bits.

Literal operands: some instruction forms allow for a 16-bit literal operand value within the instruction. This is always stored in big-endian order, i.e. most significant byte first.

Interaction instructions can be found in the following places:

  • a cell can end with a single instruction to be executed when the cell has finished playing.
  • a button specifies a single instruction to be executed when the button is selected.
  • the pre- and post-sections of a PGC can each contain a sequence of instructions, to be executed before the PGC starts playing and after it finishes, respectively.
  • the FPC contains a sequence of instructions which automatically start executing when the disc is inserted into the player.

The single-instruction limitation on buttons is not a big issue in practice; it’s easy enough for the single instruction to be “set GPRM i to j and link to post-section of PGC”, to execute a longer sequence of instructions in the PGC post-section that does different things for different buttons, based on the value of GPRM i.

System Parameter Registers

In the following table, “writable” indicates whether there is an instruction for explicitly writing into that register. Non-writable registers may be implicitly altered via control-transfer instructions or automatically as playback progresses (these can change the current title/PGC/chapter), or explicitly by the user via some device-provided interface (e.g. preferred video and language settings), or may be readonly (e.g. player audio capabilities, region mask).

ISO-639 language codes and ISO-3166 country codes are represented as integers with the first character in the high byte and the second character in the low byte.

NumberNameMeaningWritable
0preferred menu language, ISO-639 codeN
1ASTNaudio stream number 0-7, or 15 meaning noneY
2SPSTNsubpicture stream number in bits 0-5, bit 6 must also be set to display. Normal stream numbers are 0-31, but special value 62 means “none” and 63 means “forced” (needed for menus). Y
3AGLNangle number, 1-9Y
4TTNtitle number over entire disc, 1-99N
5VTS_TTNtitle number within titleset, 1-99N
6TT_PGCNPGC number, 1-32767N
7PTTNchapter (PTT) number, 1-99N
8HL_BTNNhighlight button number × 1024. Thus, valid values are 0 (no button highlight), 1024 (highlight button 1), 2048 (highlight button 2) .. 36864 (highlight button 36)Y
9NVTMRnavigation timer in seconds, 0-65535Y
10NV_PGCNPGC number to jump to when navigation timer expires, 1-32767, must be in current titleY
11AMXMDkaraoke audio channel mixing mode:
15-131211109-54321-0
 4 → 03 → 02 → 0 4 → 13 → 12 → 1 
Y
12CC_PLTparental management ISO-3166 country codeN
13PLTparental management level, 1-8, or 15 for noneY
14video preference and current mode
15-1211-109-87-0
 preferred display ratio: 0 = 4:3, 1 = not specified, 3 = 16:9current video mode: 0 = normal, 1 = pan&scan, 2 = letterbox 
N
15player audio capabilities
1514131211109-87654321-0
 Dolby MPEGDTSSDDS PCM karaokeDolby karaoke MPEG karaokeDTS karaokeSDDS karaoke 
N
16preferred audio language, ISO-639 codeN
17preferred audio language extension
CodeMeaning
0not specified
1normal
2for visually impaired
3director’s comments
4alternate director’s comments
N
18preferred subpicture language, ISO-639 codeN
19preferred subpicture language extension
CodeMeaning
0not specified
1normal
2large
3children
5normal captions
6large captions
7children’s captions
9forced
13director’s comments
14large director’s comments
15director’s comments for children
N
20player region code mask
15-876543210
 region 8region 7region 6region 5region 4region 3region 2region 1
N
21-23Reserved

(SPRM listing comes from here)

The instructions for diverting the flow of playback are divided into Link, Jump and Call categories. Link instructions allow for transfers within a PGC/title/domain, or to a fixed set of related PGCs (“next”, “previous” and “up”), while Jump and Call allow for more wide-ranging transfers across domains, menus, titles and chapters. Titles and chapters may be entered via Jump instructions, while menus (and the FPC) may be entered via Jump or Call instructions. The Jump-to-menu and Call-to-menu sets support the same set of possible transfers, except that Jump-to-menu instructions are only allowed within menus, while the Call-to-menu equivalents are only allowed within titles.

Call instructions perform the same action as their Jump equivalents, except they also save a playback point for later resumption. (This can be the current playback point, or another point explicitly specified in the instruction.) Only a single resume point can be saved: the “resume stack” (if you can call it that) is only a single element deep.

Thus, the resume point from a Call is always within a title, never a menu. The model is that invoking a menu involves temporarily suspending the playback of a title, which can be resumed when the menu is dismissed (unless a menu option starts playback somewhere else).

Allowable transfers using Jump or Call:

from\toFPCVMGVTSMVTST
FPC JumpSSJumpSSJumpTT
VMGJumpSSJumpSSJumpSSJumpTT
VTSMJumpSSJumpSSJumpSS (same titleset only)JumpVTS_TT, JumpVTS_PTT (same titleset only)
VTSTCallSSCallSSCallSS (same titleset only)JumpVTS_TT, JumpVTS_PTT (same titleset only)

Note that, from a VTS (menu or title), it is not permitted to jump directly into another VTS. You have to set up indirect jumps via the VMG.

The RSM command in the Link Subset (see below) resumes playback from the last-saved resume point. The Return button on the remote does the same thing.

Conditional Formats

Every instruction can be made conditional, where a comparison is made between two operands, and execution of the rest of the instruction depends on whether the comparison evaluates to true or not.

The layout of the conditional fields can vary between instruction groups. In the following instruction formats, the dots represent bits encoded as per the unconditional form of the instruction. The 3-bit cmp field indicates the comparison operator to be applied on the two operands:

CodeMeaning
0always true (unconditional form of instruction)
1BC (“&”, true iff logical-and of operands is nonzero)
2=
3
4
5>
6
7<

These particular formats are usable with instructions in groups 0, 1, 2, 3. Instructions in groups 4, 5 and 6 use the same cmp codes, but have their own arrangements for the comparison operands. Though note that the cmp field (and immediate flag for comparison operand 2) is in the same place for all instructions.

Format 1

This form allows for comparison between two registers, or between a register and a 16-bit literal value.

01:71:6-41:3-0234567
........0cmp.... creg1 creg2................
........1cmp.... creg1cimmed2................

Format 2

This form allows only for comparison between two registers.

01:71:6-41:3-0234567
........ cmp....................................creg1creg2

Format 3

This form allows for comparison between two registers, or between a register and a 16-bit literal value.

01:71:6-41:3-0234567
........0cmp....creg1........................ creg2
........1cmp....creg1........................cimmed2

Set-Operations

Instructions that assign a new value to a GPRM have an op field and a source-operand field (specifying either a register or a literal value). The new value for the destination is computed as a function of its existing value, the source operand, and the op. Furthermore, the swap operation alters the source as well (the others do not). Valid values of op (and corresponding restrictions on the source operand) are as follows:

opoperationAllowable source
literalGPRMSPRM
0no operation; reg unchangedYYY
1straight assignment; reg := source
2swap values of reg and sourceNYN
3add source to regYYN
4subtract source from reg
5multiply reg by source
6divide reg by source
7set reg to remainder on integer division by source
8set reg to a random integer in [1 .. source]
9bitwise-and source and regYYY
10bitwise-or source and reg
11bitwise-xor source and reg

Instruction Set Details

See the next page.

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.