psx-spx.github.io/cdromvideocdsvcd/index.html
2021-05-15 21:28:56 +00:00

2131 lines
95 KiB
HTML

<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8"/>
<meta content="width=device-width,initial-scale=1" name="viewport"/>
<link href="https://psx-spx.consoledev.net/cdromvideocdsvcd/" rel="canonical"/>
<link href="../assets/images/favicon.png" rel="icon"/>
<meta content="mkdocs-1.1.2, mkdocs-material-7.1.3" name="generator"/>
<title>CDROM Video CDs (VCD) - PlayStation Specifications - psx-spx</title>
<link href="../assets/stylesheets/main.e35208c4.min.css" rel="stylesheet"/>
<link href="../assets/stylesheets/palette.ef6f36e2.min.css" rel="stylesheet"/>
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect"/>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&amp;display=fallback" rel="stylesheet"/>
<style>:root{--md-text-font-family:"Roboto";--md-code-font-family:"Roboto Mono"}</style>
<link href="../css/extra.css" rel="stylesheet"/>
</head>
<body data-md-color-accent="indigo" data-md-color-primary="indigo" data-md-color-scheme="default" dir="ltr">
<script>function __prefix(e){return new URL("..",location).pathname+"."+e}function __get(e,t=localStorage){return JSON.parse(t.getItem(__prefix(e)))}</script>
<script>var palette=__get("__palette");if(null!==palette&&"object"==typeof palette.color)for(var key in palette.color)document.body.setAttribute("data-md-color-"+key,palette.color[key])</script>
<input autocomplete="off" class="md-toggle" data-md-toggle="drawer" id="__drawer" type="checkbox"/>
<input autocomplete="off" class="md-toggle" data-md-toggle="search" id="__search" type="checkbox"/>
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a class="md-skip" href="#cdrom-video-cds-vcd">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<header class="md-header" data-md-component="header">
<nav aria-label="Header" class="md-header__inner md-grid">
<a aria-label="PlayStation Specifications - psx-spx" class="md-header__button md-logo" data-md-component="logo" href=".." title="PlayStation Specifications - psx-spx">
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54z"></path></svg>
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2z"></path></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
PlayStation Specifications - psx-spx
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
CDROM Video CDs (VCD)
</span>
</div>
</div>
</div>
<form class="md-header__option" data-md-component="palette">
<input class="md-option" data-md-color-accent="indigo" data-md-color-media="(prefers-color-scheme: light)" data-md-color-primary="indigo" data-md-color-scheme="default" id="__palette_1" name="__palette" type="radio"/>
<label class="md-header__button md-icon" for="__palette_2" hidden="" title="Switch to dark mode">
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10a2 2 0 0 1 2 2 2 2 0 0 1-2 2 2 2 0 0 1-2-2 2 2 0 0 1 2-2m10-3a5 5 0 0 1 5 5 5 5 0 0 1-5 5H7a5 5 0 0 1-5-5 5 5 0 0 1 5-5h10M7 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3h10a3 3 0 0 0 3-3 3 3 0 0 0-3-3H7z"></path></svg>
</label>
<input class="md-option" data-md-color-accent="blue" data-md-color-media="(prefers-color-scheme: dark)" data-md-color-primary="blue" data-md-color-scheme="slate" id="__palette_2" name="__palette" type="radio"/>
<label class="md-header__button md-icon" for="__palette_1" hidden="" title="Switch to light mode">
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M17 7H7a5 5 0 0 0-5 5 5 5 0 0 0 5 5h10a5 5 0 0 0 5-5 5 5 0 0 0-5-5m0 8a3 3 0 0 1-3-3 3 3 0 0 1 3-3 3 3 0 0 1 3 3 3 3 0 0 1-3 3z"></path></svg>
</label>
</form>
<label class="md-header__button md-icon" for="__search">
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"></path></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input aria-label="Search" autocapitalize="off" autocomplete="off" autocorrect="off" class="md-search__input" data-md-component="search-query" data-md-state="active" name="query" placeholder="Search" required="" spellcheck="false" type="text"/>
<label class="md-search__icon md-icon" for="__search">
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"></path></svg>
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"></path></svg>
</label>
<button aria-label="Clear" class="md-search__icon md-icon" tabindex="-1" type="reset">
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"></path></svg>
</button>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix="">
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Initializing search
</div>
<ol class="md-search-result__list"></ol>
</div>
</div>
</div>
</div>
</div>
<div class="md-header__source">
<a class="md-source" data-md-component="source" href="https://github.com/psx-spx/psx-spx.github.io/" title="Go to repository">
<div class="md-source__icon md-icon">
<svg viewbox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"></path></svg>
</div>
<div class="md-source__repository">
GitHub
</div>
</a>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav aria-label="Navigation" class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a aria-label="PlayStation Specifications - psx-spx" class="md-nav__button md-logo" data-md-component="logo" href=".." title="PlayStation Specifications - psx-spx">
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54z"></path></svg>
</a>
PlayStation Specifications - psx-spx
</label>
<div class="md-nav__source">
<a class="md-source" data-md-component="source" href="https://github.com/psx-spx/psx-spx.github.io/" title="Go to repository">
<div class="md-source__icon md-icon">
<svg viewbox="0 0 448 512" xmlns="http://www.w3.org/2000/svg"><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"></path></svg>
</div>
<div class="md-source__repository">
GitHub
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix="">
<li class="md-nav__item">
<a class="md-nav__link" href="..">
Home
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../memorymap/">
Memory Map
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../iomap/">
I/O Map
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../graphicsprocessingunitgpu/">
Graphics Processing Unit (GPU)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../geometrytransformationenginegte/">
Geometry Transformation Engine (GTE)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../macroblockdecodermdec/">
Macroblock Decoder (MDEC)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../soundprocessingunitspu/">
Sound Processing Unit (SPU)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../interrupts/">
Interrupts
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../dmachannels/">
DMA Channels
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../timers/">
Timers
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../cdromdrive/">
CDROM Drive
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../controllersandmemorycards/">
Controllers and Memory Cards
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../pocketstation/">
Pocketstation
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../serialportsio/">
Serial Port (SIO)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../expansionportpio/">
Expansion Port (PIO)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../memorycontrol/">
Memory Control
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../unpredictablethings/">
Unpredictable Things
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../cpuspecifications/">
CPU Specifications
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../kernelbios/">
Kernel (BIOS)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../arcadecabinets/">
Arcade Cabinets
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../cheatdevices/">
Cheat Devices
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../psxdevboardchipsets/">
PSX Dev-Board Chipsets
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../hardwarenumbers/">
Hardware Numbers
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../pinouts/">
Pinouts
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../aboutcredits/">
About &amp; Credits
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" data-md-toggle="toc" id="__toc" type="checkbox"/>
<label class="md-nav__link md-nav__link--active" for="__toc">
CDROM Video CDs (VCD)
<span class="md-nav__icon md-icon"></span>
</label>
<a class="md-nav__link md-nav__link--active" href="./">
CDROM Video CDs (VCD)
</a>
<nav aria-label="Table of contents" class="md-nav md-nav--secondary">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix="">
<li class="md-nav__item">
<a class="md-nav__link" href="#vcds-on-playstation">
VCDs on Playstation
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#iso-filesystem-track-1">
ISO Filesystem (Track 1)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-streams-track-2-and-up">
MPEG Streams (Track 2 and up)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-versions-variants">
VCD Versions &amp; Variants
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-iso-basic-files-info-entries-avseqnn-iso-filesystem">
VCD ISO Basic Files (INFO, ENTRIES, AVSEQnn, ISO Filesystem)
</a>
<nav aria-label="VCD ISO Basic Files (INFO, ENTRIES, AVSEQnn, ISO Filesystem)" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#primary-volume-descriptor-000216">
Primary Volume Descriptor (00:02:16)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcdinfovcd-or-svcdinfosvd-000400-800h-bytes-one-sector">
VCD\INFO.VCD or SVCD\INFO.SVD (00:04:00) (800h bytes, one sector)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcdentriesvcd-or-svcdentriessvd-000401-800h-bytes-one-sector">
VCD\ENTRIES.VCD or SVCD\ENTRIES.SVD (00:04:01) (800h bytes, one sector)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpegavavseqnndat-pointers-to-max-98-mpeg-1-tracks-nn0198-for-vcds">
MPEGAV\AVSEQnn.DAT (pointers to max 98 MPEG-1 Tracks, nn=01..98) (for VCDs)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg2avseqnnmpg-pointers-to-max-98-mpeg-2-tracks-nn0198-for-svcds">
MPEG2\AVSEQnn.MPG (pointers to max 98 MPEG-2 Tracks, nn=01..98) (for SVCDs)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpegavavseqnnmpg-pointers-to-whatever-as-so-on-some-svcds-or-vcd30">
MPEGAV\AVSEQnn.MPG (pointers to WHATEVER) (as so on some SVCDs or VCD30?)
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-iso-playback-control-pbc-files-psd-lot-itemnnnn">
VCD ISO Playback Control PBC Files (PSD, LOT, ITEMnnnn)
</a>
<nav aria-label="VCD ISO Playback Control PBC Files (PSD, LOT, ITEMnnnn)" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#vcdpsdvcd-or-svcdpsdsvd-000434-and-up-max-256-sectors">
VCD\PSD.VCD or SVCD\PSD.SVD (00:04:34 and up) (max 256 sectors)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcdlotvcd-or-svcdlotsvd-00040233-64kbyte-32-sectors">
VCD\LOT.VCD or SVCD\LOT.SVD (00:04:02..33) (64Kbyte, 32 sectors)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#segmentitemnnnndat-pictures-menu-screens-nnnn00011980">
SEGMENT\ITEMnnnn.DAT (Pictures, Menu screens) (nnnn=0001..1980)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#extpsd_xvcd-or-extpsd_xsvd-extended-version-of-psdvcd">
EXT\PSD_X.VCD or EXT\PSD_X.SVD (extended version of PSD.VCD)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#extlot_xvcd-or-extlot_xsvd-extended-version-of-lotvcd">
EXT\LOT_X.VCD or EXT\LOT_X.SVD (extended version of LOT.VCD)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#playback-control-issues">
Playback Control Issues
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-iso-search-files-scandata-search-tracks-spicontx">
VCD ISO Search Files (SCANDATA, SEARCH, TRACKS, SPICONTX)
</a>
<nav aria-label="VCD ISO Search Files (SCANDATA, SEARCH, TRACKS, SPICONTX)" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#caution-overlapping-sectors">
Caution: Overlapping Sectors (!?!)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#extscandatadat-123n-bytes-for-vcd-20-or-163n2x3y3z-for-svcd">
EXT\SCANDATA.DAT (12+3*N bytes for VCD 2.0) (or 16+3*N+2*X+3*Y+3*Z for SVCD)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#svcdsearchdat-133n-bytes">
SVCD\SEARCH.DAT (13+3*N bytes)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#svcdtrackssvd-114n-bytes-or-rarely115n-bytes">
SVCD\TRACKS.SVD (11+4*N bytes) (or rarely:11+5*N bytes)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#svcdspicontxsvd-1000h-bytes-two-sectors">
SVCD\SPICONTX.SVD (1000h bytes, two sectors)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#content-flags-for-segments-and-tracks">
Content Flags for Segments and Tracks
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-iso-misc-files-captnn-audionn-karinfo-pictures-cdi">
VCD ISO Misc files (CAPTnn, AUDIOnn, KARINFO, PICTURES, CDI)
</a>
<nav aria-label="VCD ISO Misc files (CAPTnn, AUDIOnn, KARINFO, PICTURES, CDI)" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#extcaptnndat-closed-caption-data-aka-subtitles-svcd-only">
EXT\CAPTnn.DAT (Closed Caption data, aka subtitles) (SVCD only?)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#cddaaudionndat-pointers-to-uncompressed-cd-audio-tracks">
CDDA\AUDIOnn.DAT (pointers to uncompressed CD Audio Tracks)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#karaokekarinfoxxx-whatever">
KARAOKE\KARINFO.xxx (whatever)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#pictures-whatever">
PICTURES\*.* (whatever)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#cdi-some-kind-of-guidriver-for-philips-cdi-players">
CDI\*.* (some kind of GUI/driver for Philips CDI Players)
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-mpeg-1-multiplex-stream">
VCD MPEG-1 Multiplex Stream
</a>
<nav aria-label="VCD MPEG-1 Multiplex Stream" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#multiplex-stream-sector-boundaries">
Multiplex Stream &amp; Sector Boundaries
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-multiplex-pack-sector-header-12-bytes">
MPEG-1 Multiplex Pack (sector header) (12 bytes)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-multiplex-system-header-12n3-bytesoptionallyat-start-of-stream">
MPEG-1 Multiplex System Header (12+N*3 bytes)(optionally)(at start of stream)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-multiplex-videoaudiospecial-packets-724-bytes-plus-data">
MPEG-1 Multiplex Video/Audio/Special Packets (7..24 bytes, plus data)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-multiplex-end-code-4-bytes">
MPEG-1 Multiplex End Code (4 bytes)
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-mpeg-1-video-stream">
VCD MPEG-1 Video Stream
</a>
<nav aria-label="VCD MPEG-1 Video Stream" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-sequence-header-12-76-or-140-bytes-ie-12n64">
MPEG-1 Video Sequence Header (12, 76, or 140 bytes, ie. 12+N*64)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-group-of-pictures-gop-8-bytes-xxx">
MPEG-1 Video Group of Pictures (GOP) (8 bytes) XXX...
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-picture-header-xxx">
MPEG-1 Video Picture Header XXX...
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#frame-order">
Frame Order
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-slice">
MPEG-1 Video Slice
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-groupsequence-extension-data-reserved">
MPEG-1 Video Group/Sequence Extension Data (reserved)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-user-data-optional">
MPEG-1 Video User Data (optional)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-sequence-end-code-4-bytes">
MPEG-1 Video Sequence End Code (4 bytes)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-420-macroblock">
MPEG-1 Video 4:2:0 Macroblock
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-mp2-audio-stream">
VCD MP2 Audio Stream
</a>
<nav aria-label="VCD MP2 Audio Stream" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#overall-mp2-frame-format">
Overall MP2 Frame Format
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mp2-header">
MP2 Header
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mp2-checksum-optional">
MP2 Checksum (optional)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#allocation-information">
Allocation Information
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#scale-factor-selector-information">
Scale Factor Selector Information
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#scale-factors">
Scale Factors
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#data">
Data
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#inflate">
Inflate
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#inflate-core-functions">
Inflate - Core Functions
</a>
<nav aria-label="Inflate - Core Functions" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_uncompressdstsrc">
tinf_uncompress(dst,src)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_inflate_uncompressed_block">
tinf_inflate_uncompressed_block()
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_inflate_compressed_block">
tinf_inflate_compressed_block()
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_decode_symboltree">
tinf_decode_symbol(tree)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_read_bitsnum-get-n-bits-from-source-stream">
tinf_read_bits(num) ;get N bits from source stream
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_getbit-get-one-bit-from-source-stream">
tinf_getbit() ;get one bit from source stream
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_align_src_to_byte_boundary">
tinf_align_src_to_byte_boundary()
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#inflate-initialization-tree-creation">
Inflate - Initialization &amp; Tree Creation
</a>
<nav aria-label="Inflate - Initialization &amp; Tree Creation" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_init">
tinf_init()
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_build_bits_basebitsbasedeltabase_val">
tinf_build_bits_base(bits,base,delta,base_val)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_build_fixed_trees">
tinf_build_fixed_trees()
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_decode_dynamic_trees">
tinf_decode_dynamic_trees()
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_build_treetree-first-num">
tinf_build_tree(tree, first, num)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_data">
tinf_data
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#inflate-headers-and-checksums">
Inflate - Headers and Checksums
</a>
<nav aria-label="Inflate - Headers and Checksums" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_gzip_uncompressvoid-dest-destlen-source-sourcelen">
tinf_gzip_uncompress(void *dest, *destLen, *source, sourceLen)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_zlib_uncompressdst-destlen-src-sourcelen">
tinf_zlib_uncompress(dst, destLen, src, sourceLen)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_adler32src-length">
tinf_adler32(src, length)
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../cdrominternalinfoonpsxcdromcontroller/">
CDROM Internal Info on PSX CDROM Controller
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav aria-label="Table of contents" class="md-nav md-nav--secondary">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix="">
<li class="md-nav__item">
<a class="md-nav__link" href="#vcds-on-playstation">
VCDs on Playstation
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#iso-filesystem-track-1">
ISO Filesystem (Track 1)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-streams-track-2-and-up">
MPEG Streams (Track 2 and up)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-versions-variants">
VCD Versions &amp; Variants
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-iso-basic-files-info-entries-avseqnn-iso-filesystem">
VCD ISO Basic Files (INFO, ENTRIES, AVSEQnn, ISO Filesystem)
</a>
<nav aria-label="VCD ISO Basic Files (INFO, ENTRIES, AVSEQnn, ISO Filesystem)" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#primary-volume-descriptor-000216">
Primary Volume Descriptor (00:02:16)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcdinfovcd-or-svcdinfosvd-000400-800h-bytes-one-sector">
VCD\INFO.VCD or SVCD\INFO.SVD (00:04:00) (800h bytes, one sector)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcdentriesvcd-or-svcdentriessvd-000401-800h-bytes-one-sector">
VCD\ENTRIES.VCD or SVCD\ENTRIES.SVD (00:04:01) (800h bytes, one sector)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpegavavseqnndat-pointers-to-max-98-mpeg-1-tracks-nn0198-for-vcds">
MPEGAV\AVSEQnn.DAT (pointers to max 98 MPEG-1 Tracks, nn=01..98) (for VCDs)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg2avseqnnmpg-pointers-to-max-98-mpeg-2-tracks-nn0198-for-svcds">
MPEG2\AVSEQnn.MPG (pointers to max 98 MPEG-2 Tracks, nn=01..98) (for SVCDs)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpegavavseqnnmpg-pointers-to-whatever-as-so-on-some-svcds-or-vcd30">
MPEGAV\AVSEQnn.MPG (pointers to WHATEVER) (as so on some SVCDs or VCD30?)
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-iso-playback-control-pbc-files-psd-lot-itemnnnn">
VCD ISO Playback Control PBC Files (PSD, LOT, ITEMnnnn)
</a>
<nav aria-label="VCD ISO Playback Control PBC Files (PSD, LOT, ITEMnnnn)" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#vcdpsdvcd-or-svcdpsdsvd-000434-and-up-max-256-sectors">
VCD\PSD.VCD or SVCD\PSD.SVD (00:04:34 and up) (max 256 sectors)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcdlotvcd-or-svcdlotsvd-00040233-64kbyte-32-sectors">
VCD\LOT.VCD or SVCD\LOT.SVD (00:04:02..33) (64Kbyte, 32 sectors)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#segmentitemnnnndat-pictures-menu-screens-nnnn00011980">
SEGMENT\ITEMnnnn.DAT (Pictures, Menu screens) (nnnn=0001..1980)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#extpsd_xvcd-or-extpsd_xsvd-extended-version-of-psdvcd">
EXT\PSD_X.VCD or EXT\PSD_X.SVD (extended version of PSD.VCD)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#extlot_xvcd-or-extlot_xsvd-extended-version-of-lotvcd">
EXT\LOT_X.VCD or EXT\LOT_X.SVD (extended version of LOT.VCD)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#playback-control-issues">
Playback Control Issues
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-iso-search-files-scandata-search-tracks-spicontx">
VCD ISO Search Files (SCANDATA, SEARCH, TRACKS, SPICONTX)
</a>
<nav aria-label="VCD ISO Search Files (SCANDATA, SEARCH, TRACKS, SPICONTX)" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#caution-overlapping-sectors">
Caution: Overlapping Sectors (!?!)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#extscandatadat-123n-bytes-for-vcd-20-or-163n2x3y3z-for-svcd">
EXT\SCANDATA.DAT (12+3*N bytes for VCD 2.0) (or 16+3*N+2*X+3*Y+3*Z for SVCD)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#svcdsearchdat-133n-bytes">
SVCD\SEARCH.DAT (13+3*N bytes)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#svcdtrackssvd-114n-bytes-or-rarely115n-bytes">
SVCD\TRACKS.SVD (11+4*N bytes) (or rarely:11+5*N bytes)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#svcdspicontxsvd-1000h-bytes-two-sectors">
SVCD\SPICONTX.SVD (1000h bytes, two sectors)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#content-flags-for-segments-and-tracks">
Content Flags for Segments and Tracks
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-iso-misc-files-captnn-audionn-karinfo-pictures-cdi">
VCD ISO Misc files (CAPTnn, AUDIOnn, KARINFO, PICTURES, CDI)
</a>
<nav aria-label="VCD ISO Misc files (CAPTnn, AUDIOnn, KARINFO, PICTURES, CDI)" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#extcaptnndat-closed-caption-data-aka-subtitles-svcd-only">
EXT\CAPTnn.DAT (Closed Caption data, aka subtitles) (SVCD only?)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#cddaaudionndat-pointers-to-uncompressed-cd-audio-tracks">
CDDA\AUDIOnn.DAT (pointers to uncompressed CD Audio Tracks)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#karaokekarinfoxxx-whatever">
KARAOKE\KARINFO.xxx (whatever)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#pictures-whatever">
PICTURES\*.* (whatever)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#cdi-some-kind-of-guidriver-for-philips-cdi-players">
CDI\*.* (some kind of GUI/driver for Philips CDI Players)
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-mpeg-1-multiplex-stream">
VCD MPEG-1 Multiplex Stream
</a>
<nav aria-label="VCD MPEG-1 Multiplex Stream" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#multiplex-stream-sector-boundaries">
Multiplex Stream &amp; Sector Boundaries
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-multiplex-pack-sector-header-12-bytes">
MPEG-1 Multiplex Pack (sector header) (12 bytes)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-multiplex-system-header-12n3-bytesoptionallyat-start-of-stream">
MPEG-1 Multiplex System Header (12+N*3 bytes)(optionally)(at start of stream)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-multiplex-videoaudiospecial-packets-724-bytes-plus-data">
MPEG-1 Multiplex Video/Audio/Special Packets (7..24 bytes, plus data)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-multiplex-end-code-4-bytes">
MPEG-1 Multiplex End Code (4 bytes)
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-mpeg-1-video-stream">
VCD MPEG-1 Video Stream
</a>
<nav aria-label="VCD MPEG-1 Video Stream" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-sequence-header-12-76-or-140-bytes-ie-12n64">
MPEG-1 Video Sequence Header (12, 76, or 140 bytes, ie. 12+N*64)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-group-of-pictures-gop-8-bytes-xxx">
MPEG-1 Video Group of Pictures (GOP) (8 bytes) XXX...
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-picture-header-xxx">
MPEG-1 Video Picture Header XXX...
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#frame-order">
Frame Order
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-slice">
MPEG-1 Video Slice
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-groupsequence-extension-data-reserved">
MPEG-1 Video Group/Sequence Extension Data (reserved)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-user-data-optional">
MPEG-1 Video User Data (optional)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-sequence-end-code-4-bytes">
MPEG-1 Video Sequence End Code (4 bytes)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mpeg-1-video-420-macroblock">
MPEG-1 Video 4:2:0 Macroblock
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#vcd-mp2-audio-stream">
VCD MP2 Audio Stream
</a>
<nav aria-label="VCD MP2 Audio Stream" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#overall-mp2-frame-format">
Overall MP2 Frame Format
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mp2-header">
MP2 Header
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#mp2-checksum-optional">
MP2 Checksum (optional)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#allocation-information">
Allocation Information
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#scale-factor-selector-information">
Scale Factor Selector Information
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#scale-factors">
Scale Factors
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#data">
Data
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#inflate">
Inflate
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#inflate-core-functions">
Inflate - Core Functions
</a>
<nav aria-label="Inflate - Core Functions" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_uncompressdstsrc">
tinf_uncompress(dst,src)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_inflate_uncompressed_block">
tinf_inflate_uncompressed_block()
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_inflate_compressed_block">
tinf_inflate_compressed_block()
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_decode_symboltree">
tinf_decode_symbol(tree)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_read_bitsnum-get-n-bits-from-source-stream">
tinf_read_bits(num) ;get N bits from source stream
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_getbit-get-one-bit-from-source-stream">
tinf_getbit() ;get one bit from source stream
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_align_src_to_byte_boundary">
tinf_align_src_to_byte_boundary()
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#inflate-initialization-tree-creation">
Inflate - Initialization &amp; Tree Creation
</a>
<nav aria-label="Inflate - Initialization &amp; Tree Creation" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_init">
tinf_init()
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_build_bits_basebitsbasedeltabase_val">
tinf_build_bits_base(bits,base,delta,base_val)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_build_fixed_trees">
tinf_build_fixed_trees()
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_decode_dynamic_trees">
tinf_decode_dynamic_trees()
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_build_treetree-first-num">
tinf_build_tree(tree, first, num)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_data">
tinf_data
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#inflate-headers-and-checksums">
Inflate - Headers and Checksums
</a>
<nav aria-label="Inflate - Headers and Checksums" class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_gzip_uncompressvoid-dest-destlen-source-sourcelen">
tinf_gzip_uncompress(void *dest, *destLen, *source, sourceLen)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_zlib_uncompressdst-destlen-src-sourcelen">
tinf_zlib_uncompress(dst, destLen, src, sourceLen)
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="#tinf_adler32src-length">
tinf_adler32(src, length)
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<a class="md-content__button md-icon" href="https://github.com/psx-spx/psx-spx.github.io/edit/master/docs/cdromvideocdsvcd.md" title="Edit this page">
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z"></path></svg>
</a>
<h1 id="cdrom-video-cds-vcd">CDROM Video CDs (VCD)</h1>
<p>VCDs are Video CDs with MPEG compression, yielding a playtime of 72 minutes per
disc (whole movies usually being stored on two CDs). VCDs are popular in asia
(as opposed to VHS tapes used in western world).<br/></p>
<h4 id="vcds-on-playstation">VCDs on Playstation</h4>
<p>For the Playstation, the asian SCPH-5903 model includes a special daughterboard
with MPEG decoding hardware for playing VCDs.<br/>
<a href="../cdromdrive/#cdrom-video-cd-commands">CDROM - Video CD Commands</a><br/>
<a href="../pinouts/#pinouts-vcd-pinouts">Pinouts - VCD Pinouts</a><br/>
Without that hardware it has been widely believed to be impossible to play VCDs
on Playstations, although, as of 2017, it turned out that the Playstation's CPU
and MDEC decoder are fast enough for that purpose (when skipping B-frames,
rendering the movie in monochrome without colors, and reducing audio output to
11kHz/mono).<br/></p>
<h4 id="iso-filesystem-track-1">ISO Filesystem (Track 1)</h4>
<p><a href="./#vcd-iso-basic-files-info-entries-avseqnn-iso-filesystem">VCD ISO Basic Files (INFO, ENTRIES, AVSEQnn, ISO Filesystem)</a><br/>
<a href="./#vcd-iso-playback-control-pbc-files-psd-lot-itemnnnn">VCD ISO Playback Control PBC Files (PSD, LOT, ITEMnnnn)</a><br/>
<a href="./#vcd-iso-search-files-scandata-search-tracks-spicontx">VCD ISO Search Files (SCANDATA, SEARCH, TRACKS, SPICONTX)</a><br/>
<a href="./#vcd-iso-misc-files-captnn-audionn-karinfo-pictures-cdi">VCD ISO Misc files (CAPTnn, AUDIOnn, KARINFO, PICTURES, CDI)</a><br/></p>
<h4 id="mpeg-streams-track-2-and-up">MPEG Streams (Track 2 and up)</h4>
<p><a href="./#vcd-mpeg-1-multiplex-stream">VCD MPEG-1 Multiplex Stream</a><br/>
<a href="./#vcd-mpeg-1-video-stream">VCD MPEG-1 Video Stream</a><br/>
XXX MPEG-1 Macroblocks<br/>
<a href="./#vcd-mp2-audio-stream">VCD MP2 Audio Stream</a><br/></p>
<h4 id="vcd-versions-variants">VCD Versions &amp; Variants</h4>
<p>XXX<br/></p>
<h2 id="vcd-iso-basic-files-info-entries-avseqnn-iso-filesystem">VCD ISO Basic Files (INFO, ENTRIES, AVSEQnn, ISO Filesystem)</h2>
<h4 id="primary-volume-descriptor-000216">Primary Volume Descriptor (00:02:16)</h4>
<p>VCDs are having a standard ISO Primary Volume Descriptor, with some VCD
specific entries:<br/></p>
<pre><code> 008h 32 System Identifier (always "CD-RTOS CD-BRIDGE" for VCDs)
028h 32 Volume Identifier (often nonsense, eg. "" or "__" or "VolumeLabel")
23Eh 128 Application Identifier ("CDI/CDI_APPL.VCD;1" or "CDI/CDI_VCD.APP;1")
400h 8 CD-XA Identifying Signature ("CD-XA001" for PSX and VCD)
</code></pre>
<p>There are some more differences to normal CDROMs:<br/></p>
<pre><code> VCDs are using MODE2 (with 800h-byte and 914h-byte sectors)
MPEG videos are on extra data tracks (outside of the ISO area on Track 1)
Files in VCD or SVCD folders use fixed sectors numbers (00:04:00 and up)
All 16bit/32bit values in files in VCD,SVCD,EXT,etc are BIG-ENDIAN
</code></pre>
<p>Due to the fixed sector numbers, VCDs players can completely ignore the ISO
filesystem with filenames and folders, and just address everything via sector
numbers (though accessing files in EXT and CDI folders seem to require using
the filesystem).<br/></p>
<h4 id="vcdinfovcd-or-svcdinfosvd-000400-800h-bytes-one-sector">VCD\INFO.VCD or SVCD\INFO.SVD (00:04:00) (800h bytes, one sector)</h4>
<pre><code> 000h 8 ID "VIDEO_CD" for VCD (or "SUPERVCD"/"HQ-VCD " for SVCD)
008h 1 Version ;Version Major (01h) (or 02h for VCD 2.0)
009h 1 System Profile Tag ;Version Minor (00h) (or 01h for VCD 1.1 or HQ)
00Ah 16 Album ID/Desc (name in ASCII, padded with SPC) (usually empty)
01Ah 2 Total Number of CDs in Album (1..N) ;\usually always 1,1 (even
01Ch 2 Number of this CD in Album (1..N) ;/for movies with 2 discs)
01Eh 13 PAL Flags, 98x1bit, for each Track? (0=NTSC, 1=PAL)
02Bh 1 InfoStatusFlags (see below)
Below is usually zero-filled when not using PBC
02Ch 4 Size of PSD.VCD file (or PSD.SVD?) (0=None)
030h 3 First segment addr MM:SS:00 in BCD (00:02:00 ???)
033h 1 Offset Multiplier for "PsdOffset" values in PSD.VCD (must be 8)
034h 2 Number of ListIDs in LOT.VCD file (1..7FFFh, plus 1 in some discs)
036h 2 Number of ITEMnnnn.DAT files (plus nonsense in some discs?)
Below is usually zero-filled (maybe exists on SVCD only?)
038h 1980 SegmentContent[1..1980] (b0-1=Audio, b2-4=Video, b5=Cont, b6-7=OGT)
7F4h 5*2 volume start time[0]: 5x16bit ;aka playing_time[5] in seconds (?)
7FEh 2 Reserved (0)
</code></pre>
<p>InfoStatusFlags at [02Bh] describes certain characteristics of the disc:<br/></p>
<pre><code> bit0 Reserved, must be zero
bit1-2 Restriction (0=No, 1..3=Restricted category 1..3) (eg. "not for kids")
bit3 Special Information is encoded in the pictures, uh?
bit4 MPEG User Data is used for Closed Caption (user_data_cc) (0=No, 1=Yes)
bit5 Next Disc with PBC (0=Start at ListID#1, 1=Start at ListID#2)
bit6 Next Disc without PBC (0=Start at Track #2, 1=Start at Track #3)
bit7 Extended PBC available (0=No, 1=Yes... aka EXT\PSD_X exists?)
</code></pre>
<p>Note: Bit5/6 are used only if the next disc has the same Album ID (eg. the
feature allows to skip copyright messages if the same message was already shown
on another disc).<br/>
First_segment_addr: The location of the first sector of the Segment Play Item
Area [that is... the first ITEMnnnn.DAT file?], in the form mm:ss:00. Must be
00:00:00 if PSD size is zero. If PSD size is nonzero, but no segments used:
Usually set to 00:02:00.<br/></p>
<h4 id="vcdentriesvcd-or-svcdentriessvd-000401-800h-bytes-one-sector">VCD\ENTRIES.VCD or SVCD\ENTRIES.SVD (00:04:01) (800h bytes, one sector)</h4>
<pre><code> 000h 8 ID "ENTRYVCD" for VCD and SVCD (or "ENTRYSVD" for VCD30)
008h 1 Version ;\same as in INFO.VCD/SVD
009h 1 System Profile Tag ;/
00Ah 2 Number of Entries/Chapters (1..500)
00Ch 4*500 Entry[N] (Track 02h..99h, and MM:SS:FF) (all 4 bytes in BCD)
7DCh 36 Reserved (0)
</code></pre>
<p>Version;<br/></p>
<pre><code> 0x02 --- VCD2.0
0x01 --- SVCD, should be same as version in INFO.SVD
</code></pre>
<p>Sys_prof_tag;<br/></p>
<pre><code> 0x01 if VCD1.1
0x00 else
</code></pre>
<h4 id="mpegavavseqnndat-pointers-to-max-98-mpeg-1-tracks-nn0198-for-vcds">MPEGAV\AVSEQnn.DAT (pointers to max 98 MPEG-1 Tracks, nn=01..98) (for VCDs)</h4>
<h4 id="mpeg2avseqnnmpg-pointers-to-max-98-mpeg-2-tracks-nn0198-for-svcds">MPEG2\AVSEQnn.MPG (pointers to max 98 MPEG-2 Tracks, nn=01..98) (for SVCDs)</h4>
<h4 id="mpegavavseqnnmpg-pointers-to-whatever-as-so-on-some-svcds-or-vcd30">MPEGAV\AVSEQnn.MPG (pointers to WHATEVER) (as so on some SVCDs or VCD30?)</h4>
<p>These filesystem entries contain pointers to the video tracks (that is, outside
of the ISO area on Track 1).<br/>
Commercially made SVCDs can reportedly contain 7 folders: Autorun, Data, Ext,
Mpegav, Segment, Svcd and Vmp (ie. there's no MPEG2 folder on all SVCDs? though
that MPEGAV folder is said to contain a .MPG file instead of .DAT file).<br/></p>
<h2 id="vcd-iso-playback-control-pbc-files-psd-lot-itemnnnn">VCD ISO Playback Control PBC Files (PSD, LOT, ITEMnnnn)</h2>
<p>Playback Control (PBC) is an optional feature that allows to define menues,
pictures or text pages (whereas all those is internally just consisting of MPEG
compressed bitmaps; rather than of text characters).<br/>
Presence of the PBC feature is indicated by PSD.VCD filesize entry (in
INFO.VCD) being nonzero. PBC seems to be supported by most VCDs (except older
discs from around 1997), however, many VCDs are merely including a single
PlayList entry for the movie track, without any further menues/extras.<br/></p>
<h4 id="vcdpsdvcd-or-svcdpsdsvd-000434-and-up-max-256-sectors">VCD\PSD.VCD or SVCD\PSD.SVD (00:04:34 and up) (max 256 sectors)</h4>
<p>The Descriptors in this file can be considered as being "program code". The
program is usually stuck on "executing" the current descriptor (eg. playing a
movie, or showing a selection menu) without automatically increasing the
program counter. Actual program flow occurs only if the user presses a button
(or upon selection timeouts), causing the program to "goto" to a new PsdOffset.
And, something does probably happen upon end-of-track/item... maybe that does
automatically trigger the Next button handler?<br/></p>
<pre><code>&lt;B&gt; PsdPlayListDescriptor (14+2*N bytes):&lt;/B&gt;
00h 1 Type (10h=PlayList)
01h 1 Number of Items (noi) ;for Start-of-Movie and Numeric-Input?
02h 2 ListID for this Descriptor (1..7FFFh)
04h 2 PsdOffset for Prev button (FFFFh=Disable)
06h 2 PsdOffset for Next button (FFFFh=Disable)
08h 2 PsdOffset for Return/back button (FFFFh=Disable)
0Ah 2 Play time in 1/15s (=max 72.8 minutes) (or 0000h=full item)
0Ch 1 Delay time in "1s/10s" units after ;&lt;-- uh, after? after what?
0Dh 1 Auto pause time in "1s/10s" units (used for each item in list if
the auto pause flag in a sector is true) [WHAT is that? Trigger bit?]
0Eh 2*N ItemID[N] ;item number (0..599 or 1000..2979)
Entry 0 is for "start of movie" (usually 0002h=Track 2)
Entry 1..N-1 is for numeric input ?
&lt;B&gt; PsdSelectionListDescriptor (20+2*N bytes, or 36+6*N bytes):&lt;/B&gt;
00h 1 Type (18h=SELECTION_LIST, or 1Ah=EXT_SELECTION_LIST)
01h 1 Flags (bit0=SelectionArea, bit1=CommandList, bit2-7=Reserved)
02h 1 nos &lt;-- aka Number of Numeric-input selections ?
03h 1 bsn &lt;-- ?
04h 2 ListID for this Descriptor (1..7FFFh)
06h 2 PsdOffset for Prev button
08h 2 PsdOffset for Next button
0Ah 2 PsdOffset for Return/back button
0Ch 2 PsdOffset for Default button (uh, what is that?)
0Eh 2 PsdOffset for Timeout
10h 1 totime &lt;-- aka Timeout Time maybe? in WHAT units?
11h 1 loop &lt;-- aka ?
12h 2 itemid &lt;-- aka Item to be displayed during the selection?
14h 2*N PsdOffset[N] for Numeric-input ?
Below only for SVCDs (with Type=18h), or for Extended VCDs (with Type=1Ah):
(14h+2*N) 4 Area for Prev (x1,y1,x2,y2) ;\these extra entries exist for
(18h+2*N) 4 Area for Next (x1,y1,x2,y2) ; SVCDs with Type=18h, and
(1Ch+2*N) 4 Area for Return (x1,y1,x2,y2) ; Extended VCDs with Type=1Ah
(20h+2*N) 4 Area for Default (x1,y1,x2,y2) ; (but do NOT exist for
(24h+2*N) 4*N Area[N] (x1,y1,x2,y2) ;/older VCDs with Type=18h)
&lt;B&gt; PsdEndListDescriptor (8 bytes)&lt;/B&gt;
00h 1 Type (1Fh=EndList)
01h 1 Next_disc ;00h to stop PBC or NNh to switch to disc no NN (BCD!?)
02h 2 Item (0 or 1000..2979, should be still image, eg. Change Disc pic)
04h 4 Reserved (0)
N/A - This descriptor doesn't have a ListID (unlike as other descriptors)
&lt;B&gt; PsdCommandListDescriptor (5+2*N bytes)&lt;/B&gt;
00h 1 Type (20h=CommandList)
01h 2 Command_count
03h 2 ListID for this Descriptor (1..7FFFh)
05h 2*N command[EMPTY_ARRAY_SIZE] ;uh, WHAT is a command?
&lt;B&gt; PsdAlignmentPadding (after each list entry)&lt;/B&gt;
00h 0..7 Padding to next 8-byte PsdOffset boundary (00h-filled)
</code></pre>
<p>Delay values in "1s/10s" units (for PlayList[0Ch,0Dh]):<br/></p>
<pre><code> 1..60 --&gt; wait "N" seconds
61..254 --&gt; wait "(N-60)*10+60" seconds
255 --&gt; wait infinite
</code></pre>
<p>Item numbers (0..599 or 1000..2979) can be:<br/></p>
<pre><code> 0..1 - Play nothing
2..99 - Play Track 2..99 (TOC tracks, for AVSEQnn.DAT and AUDIOnn.DAT?)
100..599 - Play Entry 1..500 from table in ENTRIES file up to end of track
600..999 - Reserved
1000..2979 - Play SPI Segment Play Item 1..1980 (ITEMnnnn.DAT file)
2980..65535 - Reserved
</code></pre>
<p>PsdOffset values can be:<br/></p>
<pre><code> 0..N Offset within PSD.VCD file, in 8-byte units
FFFDh PSD_OFS_MULTI_DEF_NO_NUM ;\uh, what is that?
FFFEh PSD_OFS_MULTI_DEF ;/
FFFFh PSD_OFS_DISABLED ;-no function assigned to the button
</code></pre>
<p>For whatever reason, some PsdOffsets are specified as ListID (lid), these
ListID values must be translated to actual PsdOffset via the ListID Offset
Table (aka LOT.VCD/LOT.SVD file).<br/></p>
<h4 id="vcdlotvcd-or-svcdlotsvd-00040233-64kbyte-32-sectors">VCD\LOT.VCD or SVCD\LOT.SVD (00:04:02..33) (64Kbyte, 32 sectors)</h4>
<p>The ListID Offset Table (LOT) allows to translate ListIDs to PsdOffsets. The
file is always 64Kbyte in size (unused entries should be set to FFFFh).<br/>
The PSD.VCD file does also assign ListIDs to each descriptor (ie. instead of
using the LOT.VCD file, one could also scan all descriptors in PSD.VCD when
searching a specific ListID).<br/></p>
<pre><code> 0000h 2 Reserved (0)
0002h 2*7FFFh PsdOffset[1..7FFFh] ;for ListID 1..7FFFh
</code></pre>
<p>Note: ListID#1 is used as entrypoint to PSD.VCD when inserting a new disc (or
when inserting another disc of the SAME movie, the entrypoint can be ListID#2,
depending on the Next Disc flag in INFO.VCD).<br/></p>
<h4 id="segmentitemnnnndat-pictures-menu-screens-nnnn00011980">SEGMENT\ITEMnnnn.DAT (Pictures, Menu screens) (nnnn=0001..1980)</h4>
<p>These files contain Pictures/Menu screens referenced from PSD.VCD. The files
seem to be stored in FORM2 sectors (not FORM1). Unknown if the files are
located on Track 1.<br/>
The content of the files seems to resemble short MPEG video clips (with only
one picture frame, or eventually with a few frames for short animations,
including audio in some cases). Still images are said to be allowed to use
twice the resolution of MPEG videos.<br/></p>
<h4 id="extpsd_xvcd-or-extpsd_xsvd-extended-version-of-psdvcd">EXT\PSD_X.VCD or EXT\PSD_X.SVD (extended version of PSD.VCD)</h4>
<h4 id="extlot_xvcd-or-extlot_xsvd-extended-version-of-lotvcd">EXT\LOT_X.VCD or EXT\LOT_X.SVD (extended version of LOT.VCD)</h4>
<p>The "extended" files are often identical to the normal PSD/LOT files. The
difference is that, if disc uses SelectionLists, then PSD should use the normal
descriptor (18h), and PSD_X should use the extended descriptor (1Ah), the
latter one seems to be intended to allow to highlight the current menu
selection (particulary useful when using +/- buttons instead of Numeric Keypad
input). Note: Nethertheless, Muppets from Space uses descriptor 18h in PSD_X.<br/>
Unknown if SVCDs do really have "extended" files, too (theoretically the VCD
extension should be a default feature for SVCDs).<br/></p>
<h4 id="playback-control-issues">Playback Control Issues</h4>
<p>Although PBC was intended as "nice extra feature", many VCDs are containing
faulty PSD files. In general, VCD players should either leave PBC unsupported
(or provide an option for disabling it).<br/>
Red Dragon from 2003 uses extended selection lists, but crops PSD_X.VCD to the
same filesize as PSD.VCD.<br/>
Muppets from Space from 1999 assigns weird functions to Prev/Next buttons (Next
wraps from Last Track to First Track, but Prev doesn't wrap from First to Last;
default Non-PBC Prev/Next functions are more user friendly).<br/>
Sony's SCPH-5903 console refuses to display the HH:MM:SS playback time when
using PBC (instead it does only display a "PBC" logo).<br/></p>
<h2 id="vcd-iso-search-files-scandata-search-tracks-spicontx">VCD ISO Search Files (SCANDATA, SEARCH, TRACKS, SPICONTX)</h2>
<p>Below files can help searching I-frames, and provide some info about the
content of Tracks and Segments.<br/>
Essentially, searching I-frames is possible without these files - however, if
present, then the files may be useful in two cases: For discs with variable
bitrates (which isn't allowed on VCDs though), and, for CDROM firmwares that
don't support "inaccurate" seeking (like telling it to start reading anywhere
NEAR some MM:SS:FF value, so one could skip sectors till reaching an I-frame)
(ie. if the firmware insists on a "accurate" seek position, then it's best to
give it a known I-frame address).<br/></p>
<h4 id="caution-overlapping-sectors">Caution: Overlapping Sectors (!?!)</h4>
<p>Reportedly the new SVCD files TRACKS.SVD and SEARCH.DAT are on these sectors:<br/></p>
<pre><code> TRACKS_SVD_SECTOR = (PSD_VCD_SECTOR+1) ;aka 2nd sector in PSD.SVD?
SEARCH_DAT_SECTOR = (TRACKS_SVD_SECTOR+1) ;aka 3rd..Nth sector in PSD.SVD?
</code></pre>
<p>If that's correct, then the files would overlap with PSD.SVD (when PSD.SVD is
bigger than one sector), that would be weird, but possible (ie. the "PsdOffset"
in PSD.SVD would need to "skip" the region used by those two files).<br/></p>
<h4 id="extscandatadat-123n-bytes-for-vcd-20-or-163n2x3y3z-for-svcd">EXT\SCANDATA.DAT (12+3*N bytes for VCD 2.0) (or 16+3*N+2*X+3*Y+3*Z for SVCD)</h4>
<p>This file fulfills much the same purpose of the SEARCH.DAT file except that
this file is mandatory only if the System Profile Tag of the INFO.SVD file is
0x01 (HQ-VCD) and also that it contains sector addresses also for each video
Segment Play Items in addition to the regular MPEG tracks.<br/></p>
<pre><code> SCANDATA.DAT Format for VCD 2.0 (12+3*N bytes):
000h 8 ID "SCAN_VCD"
008h 1 Version (02h for VCD 2.0)
009h 1 Reserved (0)
00Ah 2 Number of scan points (in 0.5s units) (max FFFFh = ca. 9.1 hours)
00Ch 3*N Scan Point[0..N-1] ;MM:SS:FF of closest I-frame
SCANDATA.DAT Format for SVCD (16+3*N+2*X+3*Y+3*Z bytes):
000h 8 ID "SCAN_VCD"
008h 1 Version (01h for SVCD)
009h 1 Reserved (0)
00Ah 2 scandata_count ;number of 3-byte entries in the table
00Ch 2 track_count ;number of MPEG tracks on disc
00Eh 2 spi_count ;number of consecutively recorded play item segments
; (as opposed to the number of segment play items).
010h 3*N msf_t cum_playtimes[N] ;cumulative playing time up to track N.
; (track time just wraps at 99:59:74)
xxxh 2*X spi_indexes[X] ;Indexes into the following scandata table
xxxh 2 mpegtrack_start_index ;Index into the following scandata table
; (where the MPEG track scan points start)
xxxh 3*Y The scandata table... [Y] ;8bit Track Number and 16bit Index
uint8_t track_num; /* Track number as in TOC
uint16_t table_offset; /* Index into scandata table
xxxh 3*Z msf_t scandata_table[Z] ;MM:SS:FF
</code></pre>
<h4 id="svcdsearchdat-133n-bytes">SVCD\SEARCH.DAT (13+3*N bytes)</h4>
<p>This file defines where the scan points are. It covers all mpeg tracks
together. A scan point at time T is the nearest I-picture in the MPEG stream to
the given time T. Scan points are given at every half-second for the entire
duration of the disc.<br/></p>
<pre><code> 000h 8 ID "SEARCHSV"
008h 1 Version (01h)
009h 1 Reserved (0)
00Ah 2 Number of scan points
00Ch 1 Time_interval (in units of 0.5 seconds) (must be 01h)
00Dh 3*N Scan Point[0..N-1] ;MM:SS:FF of closest I-frame
</code></pre>
<p>Note: This SVCD file is about same as the old EXT\SCANDATA.DAT file on VCDs
(with one extra entry for Time Interval). Whilst, SVCDs are storing some
different stuff in EXT\SCANDATA.DAT (despite of the identical filename).<br/></p>
<h4 id="svcdtrackssvd-114n-bytes-or-rarely115n-bytes">SVCD\TRACKS.SVD (11+4*N bytes) (or rarely:11+5*N bytes)</h4>
<p>The TRACKS.SVD file contains a series of structures, one for each track, which
indicates the track's playing time (in sectors, not actually real time) and
contents.<br/>
SVCD\TRACKS.SVD is a mandatory file which describes the numbers and types of
MPEG tracks on the disc.<br/></p>
<pre><code> SVCD\TRACKS.SVD Format for SVCD (11+4*N bytes):
000h 8 ID "TRACKSVD"
008h 1 Version (01h)
009h 1 Reserved (0)
00Ah 1 Number of MPEG tracks (N)
00Bh 3*N Track playing_time[N] (MM:SS:FF, in BCD)(in sectors, not real time)
0xxh 1*N TrackContent[N] ;bit0-1=Audio,bit2-4=Video,bit5=Reserved,bit6-7=OGT
SVCD\TRACKS.SVD Format for VCD30 (11+5*N bytes) (some sort of SVCD-prototype):
000h 8 ID "TRACKSVD"
008h 1 Version (01h)
009h 1 Reserved (0)
00Ah 1 Number of MPEG tracks (N)
00Bh 5*N Cum_Playing_time and Content (MM:SS:FF in BCD, and OGT, Audio)
</code></pre>
<h4 id="svcdspicontxsvd-1000h-bytes-two-sectors">SVCD\SPICONTX.SVD (1000h bytes, two sectors)</h4>
<p>Unknown if/when/where/why this file exists, possibly only on VCD30?<br/>
Note: The same info can be stored in INFO.SVD at offsets [038h..7F3h].<br/></p>
<pre><code> 0000h 8 ID "SPICONSV"
0008h 1 Version (01h)
0009h 1 Reserved (0)
000Ah 2*1980 Segment Content[1..1980] (1st byte=OGT, 2nd byte=Audio)
0F82h 126 Reserved (0)
</code></pre>
<h4 id="content-flags-for-segments-and-tracks">Content Flags for Segments and Tracks</h4>
<p>For SVCD\INFO.SVD and SVCD\TRACKS.SVD (on SVCD) these are encoded in 1 byte:<br/></p>
<pre><code> bit0-1 Audio characteristics:
0 = No MPEG audio stream
1 = One MPEG1 or MPEG2 audio stream without extension
2 = Two MPEG1 or MPEG2 audio streams without extension
3 = One MPEG2 multi-channel audio stream with extension
bit2-4 Video characteristics:
In TRACKS.SVD this must be 0,3,7 (no still pictures)
0 = No MPEG video data
1 = NTSC still picture
2 = NTSC Reserved (NTSC still pic hires?)
3 = NTSC motion picture
4 = Reserved
5 = PAL still picture
6 = PAL Reserved (PAL still pic hires?)
7 = PAL motion picture
bit5 Indicates segment is continuation of an item
In TRACKS.SVD this must be 0 (reserved)
0 = First or only segment of item
1 = Second or later segment of item
bit6-7 Overlay Graphics/Text (OGT):
0 = No OGT substream
1 = Sub-stream 0 available
2 = Sub-stream 0 &amp; 1 available
3 = All OGT sub-substreams available
</code></pre>
<p>For SPICONTX.SVD and SVCD\TRACKS.SVD (on VCD30) these are encoded in 2 bytes:<br/></p>
<pre><code> 1st byte = Audio characteristics ;\probably same values as
2nd byte = Overlay Graphics/Text (OGT) ;/in above bitfields?
</code></pre>
<h2 id="vcd-iso-misc-files-captnn-audionn-karinfo-pictures-cdi">VCD ISO Misc files (CAPTnn, AUDIOnn, KARINFO, PICTURES, CDI)</h2>
<h4 id="extcaptnndat-closed-caption-data-aka-subtitles-svcd-only">EXT\CAPTnn.DAT (Closed Caption data, aka subtitles) (SVCD only?)</h4>
<p>VCDs with subtitles are usually/always having the subtitles encoded directly in
the picture frames (ie. in the MPEG macroblocks, rather than using the Closed
Caption feature).<br/>
These CAPTnn.DAT files are intended for Closed Captions (eg. subtitles in
different languages and/or for deaf people).<br/>
Alternately, the "user_data_cc" flag in INFO.VCD?/INFO.SVD can indicate to
store Closed Captions in MPEG User Data (with START_CODE=000001B2h=User Data)
instead of in EXT\CAPTnn.DAT. Either way, the format of those Closed Captions
is unknown.<br/>
Moreover, Content can be flagged to have Overlay Graphics/Text (OGT), whatever
that is: it might be related to Closed Captions.<br/>
Note: Reportedly CAPTnn.DAT can exist on VCDs and SVCDs (although the same
person reported that VCDs do not support subtitles, so that info sounds wrong).<br/></p>
<h4 id="cddaaudionndat-pointers-to-uncompressed-cd-audio-tracks">CDDA\AUDIOnn.DAT (pointers to uncompressed CD Audio Tracks)</h4>
<p>These filesystem entries contain pointers to uncompressed audio tracks tracks
(that is, outside of the ISO area on Track 1).<br/>
Most VCDs don't have audio tracks (though some VCDs do contain empty CDDA
folders).<br/>
Maybe the feature is occassionally used the other way around: Music discs
containing VCD clips as bonus feature?<br/></p>
<h4 id="karaokekarinfoxxx-whatever">KARAOKE\KARINFO.xxx (whatever)</h4>
<p>The KARAOKE folder exists on many VCDs (about 50%), but it's usually/always
empty on all discs.<br/>
Reportedly the folder can contain "KARINFO.xxx" files, but the purpose/format
of that files is unknown.<br/>
Reportedly there are Midi VCDs (MVCDs) for karaoke, maybe those discs have
"KARINFO.xxx" files(?)<br/></p>
<h4 id="pictures-whatever">PICTURES\*.* (whatever)</h4>
<p>Unknown purpose. The PICTURES folder has been spotted on one VCD (Wallace and
Gromit), but the folder was just empty.<br/></p>
<h4 id="cdi-some-kind-of-guidriver-for-philips-cdi-players">CDI\*.* (some kind of GUI/driver for Philips CDI Players)</h4>
<p>The CDI folder is some relict for Philips CDI Players, it isn't used by normal
VCD players, however, the CDI folder &amp; files are included on most or all
VCDs.<br/>
The path/name for the CDI executable is stored at offset 23Eh in the ISO
Primary Volume Descriptor (usually "CDI/CDI_APPL.VCD;1" or "CDI/CDI_VCD.APP;1")
(or accidentally "CDI_CDI_VCD.APP;1" on homebrew Nero discs).<br/>
The files in the CDI folder are usually just some standard files (without any
customizations), however, there are some different revisions of these files:<br/></p>
<pre><code>&lt;B&gt; Revision A (spotted on two discs from 1997 and 1999):&lt;/B&gt;
CDI_APPL.VCD 80702 bytes, 04-Mar-1996, CRC32=AE8FC5D0h ;executable
VCD_BACK.DYV 92572 bytes, 18-Jul-1995, CRC32=00693E5Eh ;whatever?
VCD_BTN.C8 93719 bytes, 18-Jul-1995, CRC32=FF0A636Ah ;whatever?
&lt;B&gt; Revision B (spotted on a disc from 2003):&lt;/B&gt;
CDI_VCD.APP 20648 bytes, 00-Nul-0000 CRC32=DC885F70h ;executable
CDI_FONT.FNT 145388 bytes, 00-Nul-0000 CRC32=FB4D63F4h ;font?
CDI_ALL.RTF ? bytes, CRC32=? ;realtimefile?
CDI_BUM.RTF ? bytes, CRC32=? ;realtimefile?
&lt;B&gt; Revision C (spotted on a disc from 2006, and homebrews from 2001 and 2017):&lt;/B&gt;
CDI_VCD.APP 102400 bytes, 00-Nul-0000 CRC32=E91E128Dh ;executable
CDI_VCD.CFG 193 bytes, 00-Nul-0000 CRC32=D1C6F7ADh ;config/ascii
CDI_TEXT.FNT 13616 bytes, 00-Nul-0000 CRC32=BDC55E86h ;font?
CDI_IMAG.RTF 1510028 bytes, 00-Nul-0000 CRC32=(RIFF) ;realtimefile?
</code></pre>
<p>CDI_VCD.CFG is some ASCII text file (with uncommon 0Dh,0Dh,0Ah line breaks),
the file could be customized to change things like GUI colors, but most or all
discs seem to contain the same file with CRC32=D1C6F7ADh. Note: The CFG file is
missing on the homebrew DemoVCD.<br/>
CDI_IMAG.RTF is seen as 1510028 byte file under windows (that is, with a
windows RIFF header, and with data area containing the whole 930h bytes from
each sector; this includes the MM:SS:FF values from the sector header, so the
RTF file may look slightly different depending on which sectors it has been
stored on, although the files are usually exactly same apart from those
MM:SS:FF values). Note: The RTF file is cropped to 1324220 bytes (instead of
1510028) on the homebrew DemoVCD (apart from that, the file is same as normal).<br/>
CDI_ALL.RTF and CDI_BUM.RTF cannot be read/copied under Windows 7 (which is
weirdly reporting them to use an "invalid MS-DOS function"; some people also
reported having CDI_IMAG.RTF files with similar problems). The reason is
unknown, maybe windows doesn't fully support the CD filesystem, or some VCDs
are violating the filesystem specs, or whatever... maybe windows is
mis-identifying certain RTF files as Rich Text Format files and tries to
prevent virus-infections by throwing a faked "MS-DOS" error message.<br/></p>
<h2 id="vcd-mpeg-1-multiplex-stream">VCD MPEG-1 Multiplex Stream</h2>
<h4 id="multiplex-stream-sector-boundaries">Multiplex Stream &amp; Sector Boundaries</h4>
<p>The Multiplex stream is some higher level stream, intended to help to
distinguish between Audio- and Video-streams (which are enclosed in the
Multiplex stream). MPEG's are somewhat organized in "sectors", with sector size
varying for normal .mpg files and VCDs:<br/></p>
<pre><code> VCD discs --&gt; Sector Size = 914h bytes (the discs MODE2/FORM2 sector size)
.mpg files --&gt; Sector Size = 800h bytes (regardless of physical sector size)
</code></pre>
<p>Sectors are always beginning with a Multiplex Packet (and Multiplex Packets are
never crossing sector boundaries). If the amount of video data exceeds the
sector size, then it's split into several Multiplex packets, whereas, that may
happen anywhere in the video stream (ie. there can be Multiplex Headers
occurring even in the middle of Video packet).<br/></p>
<h4 id="mpeg-1-multiplex-pack-sector-header-12-bytes">MPEG-1 Multiplex Pack (sector header) (12 bytes)</h4>
<p>The Pack Header is found at the begin of the stream (on VCDs, it's also found
at the begin of each sector). The SCR values might help on identifying the
current playback position, and, with the bitrate value, this could be also used
to compute the distance to another position (though there are other ways to
determine the position/bitrate, so the Pack is kinda useless).<br/></p>
<pre><code> 32bit PACK_START_CODE (000001BAh) ;-4byte
2bit Fixed (00b for MPEG-1) (would be 01b for MPEG-2) ;\
2bit Fixed (10b) ;
3bit System Clock Reference, bit32-30 ;\ ;
1bit Marker (1) ; System Clock Reference (SCR) ;
15bit System Clock Reference, bit29-15 ; (intended Time, ; 5byte
1bit Marker (1) ; in 90kHz clock cycles) ;
15bit System Clock Reference, bit14-0 ;/ ;
1bit Marker (1) ;/
1bit Marker (1) ;\
22bit Multiplex Rate (total bitrate of the stream, in 400bit/s units) ; 3byte
1bit Marker (1) ;/
</code></pre>
<h4 id="mpeg-1-multiplex-system-header-12n3-bytesoptionallyat-start-of-stream">MPEG-1 Multiplex System Header (12+N*3 bytes)(optionally)(at start of stream)</h4>
<p>The System Header is usally found after the first Pack at the begin of the
stream.<br/></p>
<pre><code> 32bit SYSTEM_HEADER_START_CODE (000001BBh) ;\6byte
16bit Header Length minus 6 (in bytes) (0006h+N*3) ;/
1bit Marker (1) ;\
22bit Rate bound (max multiplex rate of all packs in the stream, ; 3byte
1bit Marker (1) in 400bit/s units) ;/
6bit Audio Bound (max number of audio streams in this ISO stream) ;\
1bit Fixed Flag (1=Fixed bitrate) ; 1byte
1bit CSPS Flag (1=Constrained) ;/
1bit System Audio Lock Flag XXX ;\
1bit System Video Lock Flag XXX ; 1byte
1bit Marker (1) ;
5bit Video Bound (max number of video streams in this ISO stream) ;/
8bit Reserved (FFh) ;-1byte
</code></pre>
<p>Followed by N*3 bytes for the streams (each with first bit=set):<br/></p>
<pre><code> 8bit Stream ID (C0h..DFh=Audio, E0h..EFh=Video) ;\
2bit Fixed (11b) ; 3byte
1bit STD buffer scale (0=Mul128/audio, 1=Mul1024/video) ;
13bit STD buffer size (largest required buffer over all packets) ;/
</code></pre>
<p>Terminated by a value with first bit=cleared (eg. next 000001xxh value).<br/></p>
<h4 id="mpeg-1-multiplex-videoaudiospecial-packets-724-bytes-plus-data">MPEG-1 Multiplex Video/Audio/Special Packets (7..24 bytes, plus data)</h4>
<p>These packets are encapsulating the lower-level Video/Audio streams.<br/></p>
<pre><code> 32bit START (000001xxh BDh-BFh=Special, C0h-DFh=Audio, E0h-EFh=Video);\6byte
16bit Packet Length minus 6 (in bytes) (1..18, plus data) ;/
</code></pre>
<p>If (and while) next two bits are 11b (0..16 padding bytes):<br/></p>
<pre><code> (2bit) Fixed (11b, indicates presence of stuffing) ;\optional 0..16byte
(6bit) Fixed (111111b) ;/
</code></pre>
<p>If next two bits are 01b (buffer size info):<br/></p>
<pre><code> (2bit) Fixed (01b, indicates presence of buffer size) ;\
(1bit) STD Buffer Scale (0=Mul128/audio, 1=Mul1024/video) ; optional 2byte
(13bit) STD Buffer Size (for decoding, in above scale units) ;/
</code></pre>
<p>Always:<br/></p>
<pre><code> 2bit Fixed (00b, indicates no further stuffing/buffer info);\
1bit PTS Flag (Presentation Time Stamp) ; 0.5 bytes
1bit DTS Flag (Decoding Time Stamp) ;/
</code></pre>
<p>If PTS Flag set:<br/></p>
<pre><code> (3bit) Presentation Time Stamp, bit32-30 ;\
(1bit) Marker (1) ; optional 4.5 bytes
(15bit) Presentation Time Stamp, bit29-15 ; (time when to output the
(1bit) Marker (1) ; the packet to audio/video
(15bit) Presentation Time Stamp, bit14-0 ; hardware, in 90kHz cycles)
(1bit) Marker (1) ;/
</code></pre>
<p>If DTS Flag set (in this case PTS Flag must be also set):<br/></p>
<pre><code> (4bit) Fixed (0001b) ;\
(3bit) Decoding Time Stamp, bit32-30 ; optional 5 bytes
(1bit) Marker (1) ; (recommended time when
(15bit) Decoding Time Stamp, bit29-15 ; to decode the block,
(1bit) Marker (1) ; in 90kHz cycles)
(15bit) Decoding Time Stamp, bit14-0 ;
(1bit) Marker (1) ;/
</code></pre>
<p>If PTS and DTS Flags are both zero:<br/></p>
<pre><code> (4bit) Fixed (1111b) ;-optional 0.5 bytes
</code></pre>
<p>Always:<br/></p>
<pre><code> ... packet data bytes ;-data...(not crossing sector)
</code></pre>
<p>Note: The first Multiplex Video Packet would usually start with a Sequence
Header Code (000001B3h), and the first Multiplex Audio Packet should always
start with an Audio Sync Word (FFFh).<br/>
However, the size of the Multiplex packets does usually differ from the size of
the packets in the audio/video stream, so new Multiplex Packets may occur
anywhere in the middle of those streams (eg. in the middle of a video slice,
the next Multiplex Video packet would then begin with the remaining slice
bytes, rather than with a 000001xxh code; it's also possible that a Multiplex
Audio packet gets inserted in the middle of the video slice).<br/>
The best (or easiest) way to get continous data for the lower level streams
might be to memcopy the data from Multiplex packets to separate Audio &amp;
Video buffers.<br/></p>
<h4 id="mpeg-1-multiplex-end-code-4-bytes">MPEG-1 Multiplex End Code (4 bytes)</h4>
<pre><code> 32bit END_CODE (000001B9h) ;-4byte
</code></pre>
<p>This should occur at the end of the video. On a VCD it does also occur at the
end of each video track.<br/></p>
<h2 id="vcd-mpeg-1-video-stream">VCD MPEG-1 Video Stream</h2>
<p>The Video stream is part of the Multiplex stream, meaning that the Video
packets preceeded (and interrupted) by Multiplex headers. Ie. before processing
the Video packets, one must first extract the video snippets from the Multiplex
stream (see previous chapter).<br/></p>
<h4 id="mpeg-1-video-sequence-header-12-76-or-140-bytes-ie-12n64">MPEG-1 Video Sequence Header (12, 76, or 140 bytes, ie. 12+N*64)</h4>
<pre><code> 32bit SEQUENCE_HEADER_CODE (000001B3h) ;-4byte
12bit Width in pixels (1..4095) ;\3byte
12bit Height in pixels (1..2800, for max AFh slices) ;/
4bit Aspect Ratio (01h..0Eh, see below) ;\1byte
4bit Framerate (01h..08h, see below) ;/
18bit Bitrate (in 400bit/s units, 3FFFFh=variable rate) ;\
1bit Marker (1) ; 3byte
10bit VBV (required decoding memory size, in "16 kB" units) ; +6bit
1bit Constrained Parameter Flag ;/
1bit Load Intra Q Matrix (0=No, use Standard Matrix, 1=Yes, Custom)
</code></pre>
<p>Next 64byte only when above bit was set:<br/></p>
<pre><code> (64byte) Intra Quantizer Matrix (64 x 8bit, unsigned) (in zigzag order)
1bit Load Non-Intra Q Matrix (0=No, use Standard Matrix, 1=Yes, Custom)
</code></pre>
<p>Next 64byte only when above bit was set:<br/></p>
<pre><code> (64byte) Non-Intra Quantizer Matrix (64 x 8bit, unsigned) (in zigzag order)
</code></pre>
<p>Aspect Ratio values:<br/></p>
<pre><code> 0 - ;forbidden
1 1.0 ;square pixels
2 0.6735 ;0.6735
3 0.7031 ;16:9, 625 line, PAL
4 0.7615 ;0.7615
5 0.8055 ;0.8055
6 0.8437 ;16:9, 525 line, NTSC
7 0.8935 ;0.8935
8 0.9157 ;4:3, 625 line, PAL, CCIR601
9 0.9815 ;0.9815
10 1.0255 ;1.0255
11 1.0695 ;1.0695
12 1.0950 ;4:3, 525 line, NTSC, CCIR601
13 1.1575 ;1.1575
14 1.2015 ;1.2015
15 - ;reserved
</code></pre>
<p>Frame Rate values:<br/></p>
<pre><code> 0 - ;forbidden
1 23.976 (24000/1001) ;NTSC encapsulated film rate
2 24.0 ;Standard international cinema film rate
3 25.0 ;PAL video frame rate (625/50)
4 29.97 (30000/1001) ;NTSC video frame rate
5 30.0 ;NTSC video frame rate drop-frame (525/60)
6 50.0 ;PAL double frame rate/progressive
7 59.94 (60000/1001) ;NTSC double frame rate
8 60.0 ;NTSC double frame rate drop-frame
9-15 - ;reserved
</code></pre>
<h4 id="mpeg-1-video-group-of-pictures-gop-8-bytes-xxx">MPEG-1 Video Group of Pictures (GOP) (8 bytes) XXX...</h4>
<pre><code> 32bit GROUP_START_CODE (000001B8h)
1bit Drop Frame (1=drop this frame; for reducing 30 fps to 29.97 fps)
5bit Time Code Hours (0..23)
6bit Time Code Minutes (0..59)
1bit Marker (1)
6bit Time Code Seconds (0..59)
6bit Time Code Picture (0..59)
1bit Closed GOP
1bit Broken Link
</code></pre>
<h4 id="mpeg-1-video-picture-header-xxx">MPEG-1 Video Picture Header XXX...</h4>
<pre><code> 32bit PICTURE_START_CODE (00000100h) ;\
10bit Temporal Reference (display order, 0..3FFh) ; 61bit
3bit Coding Type (0=Invalid, 1=I, 2=P, 3=B, 4=D, 5-7=Reserved);
16bit VBV Delay (in 90kHz cycles, FFFFh=variable bitrate) ;/
</code></pre>
<p>If Coding Type is 2 or 3 (P-Frame or B-Frame):<br/></p>
<pre><code> (1bit) full fel forward vector (0=half pix, 1=full pix) ;\optional 4bit
(3bit) forward f code (0=invalid, 1..7=0..6bits) ;/
</code></pre>
<p>If Coding Type is 3 (B-Frame):<br/></p>
<pre><code> (1bit) full backward vector ;\optional 4bit
(3bit) backward f code ;/
</code></pre>
<p>If (and while) next bit is set:<br/></p>
<pre><code> (1bit) Fixed (1, indicates presence of Extra Info) ;\opt. N*9bit
(8bit) Extra Information ;/
</code></pre>
<p>End of Extra:<br/></p>
<pre><code> 1bit Fixed (0, indicates no further Extra Info) ;-1bit
0-7bit Padding to byte boundary (0) ;-0..7bit
</code></pre>
<p>Coding Type values:<br/></p>
<pre><code> 0 Forbidden
1 I - Intra Coded (full image)
2 P - Predictive Coded (based on prev I or P frame)
3 B - Bidirectionally Predictive Coded (based on prev+next I or P frame)
4 D - DC Intra Coded (don't care, lowres thumbnail)
5 Reserved
6 Reserved
7 Reserved
</code></pre>
<h4 id="frame-order">Frame Order</h4>
<pre><code> DISPLAY ORDER:
I B B B P B B B P B B B P B B B I B B B P B B B P B B B P B B B ...
| |_______|_______| | |_______|_______|
| | | |
I-Frame P-frames I-Frame P-frames
</code></pre>
<p>The B-fames require to know the next P- (or I-) frame in advance, for that
reason, the frames are stored as "PBBB" (although being played as "BBBP"):<br/></p>
<pre><code> STORAGE ORDER:
I P B B B P B B B P B B B I B B B P B B B P B B B P B B B ...
| |_______|_______| | |_______|_______|
| | | |
I-Frame P-frames I-Frame P-frames
</code></pre>
<h4 id="mpeg-1-video-slice">MPEG-1 Video Slice</h4>
<p>Slices are containing the actual 16x16 pixel Macro Blocks. Usually a Slice
contains one horizontal line - although, theoretically, it could be longer or
shorter, ie. a slice could wrap to next line, or a line could be split into
several slices (with the leading "MBA Increment" value greater than 1 to define
the horizontal start offset).<br/></p>
<pre><code> 32bit PACK_START_CODE (000001xxh; xx=01h..AFh; vertical index) ;-4byte
5bit Quantizer Scale (1..31) (may be later changed by blocks) ;-5bit
</code></pre>
<p>If (and while) next bit is set:<br/></p>
<pre><code> (1bit) Fixed (1, indicates presence of Extra Info) ;\opt. N*9bit
(8bit) Extra Information ;/
</code></pre>
<p>End of Extra:<br/></p>
<pre><code> 1bit Fixed (0, indicates no further Extra Info) ;-1bit
</code></pre>
<p>If (and while) next 23bit are nonzero (ie. until next 000001xxh):<br/></p>
<pre><code> ... Macroblock (within horizontal line) ;...
</code></pre>
<p>Final padding:<br/></p>
<pre><code> 0-7bit Padding to byte boundary (0) ;-0..7bit
</code></pre>
<h4 id="mpeg-1-video-groupsequence-extension-data-reserved">MPEG-1 Video Group/Sequence Extension Data (reserved)</h4>
<h4 id="mpeg-1-video-user-data-optional">MPEG-1 Video User Data (optional)</h4>
<pre><code> 32bit START_CODE (000001B2h=User Data, 000001B5h=Extension Data) ;-4byte
... data (end is signaled by presence of next 000001xxh code) ;-data
</code></pre>
<p>User Data can contain Closed Captions (see flag in VCD\INFO.VCD or
SVCD\INFO.SVD).<br/>
User Data contains 11h-byte "Created with Nero" in some homebrew discs.<br/></p>
<h4 id="mpeg-1-video-sequence-end-code-4-bytes">MPEG-1 Video Sequence End Code (4 bytes)</h4>
<pre><code> 32bit SEQUENCE_END_CODE (000001B7h) ;-4byte
</code></pre>
<h4 id="mpeg-1-video-420-macroblock">MPEG-1 Video 4:2:0 Macroblock</h4>
<pre><code> N*11bit Macroblock_address_increase escape/stuffing codes (if any)
1..11bit Macroblock_address_increase
1-6bit Macroblock_type
5bit Quantizer_scale
... Motion_vector
3-9bit Coded_block_pattern
... Block(i)
</code></pre>
<p>Aka...<br/></p>
<pre><code> Addr Incr
Type
Motion Vector
QScale
CBP
Block b0 (Y1)
Block b1 (Y2)
Block b2 (Y3)
Block b3 (Y4)
Block b4 (Cb)
Block b5 (Cr)
</code></pre>
<h2 id="vcd-mp2-audio-stream">VCD MP2 Audio Stream</h2>
<p>VCD video discs and .mpg movie files are having the MP2 Audio Stream enclosed
in the Multiplex stream (whilst .mp2 audio files may contain raw MP2 data
without Multiplex stream).<br/></p>
<p>Each MP2 frame is starting with a FFFh syncword (which is always located on a
byte boundary). Unfortunately, the value FFFh can also occur anywhere in the
audio data (eg. a 16bit sample with value 3FFCh).<br/>
So, when starting mid-stream, one will need some guessing when searching a
valid syncword. The best method is to compute the frame size (based on the
supposed frame header), and then to check if supposed frame begins AND ends
with a sync word. Moreover, one could check for invalid sample rate values in
the frame header, or invalid "groupings" in the frame's data part.<br/>
VCDs are conventionally having three audio frames encoded in one CDROM sector,
so the first syncword can be simply found right after the multiplex packet
header (though that might differ in some cases: VCD2.0 allows different audio
bitrates, and a CDROM sector could be theoretically shared for Audio and Video
data).<br/></p>
<h4 id="overall-mp2-frame-format">Overall MP2 Frame Format</h4>
<pre><code> Header (32bit)
Optional CRC (16bit) (or 0bit if none)
Allocation Information
Scale Factor Selector Information
Scale Factors
Data
</code></pre>
<h4 id="mp2-header">MP2 Header</h4>
<pre><code> 12bit Syncword (FFFh) ;\
1bit Revision (0=MPEG-2, 1=MPEG-1) ; 2 bytes
2bit Layer (2=Audio LayerII) ;
(3=LayerI, 1=LayerIII, r3=reserved) ;
1bit Protection_bit (1=no crc) ;/
4bit Bitrate_index (1..14) ;\
(0=free format, 15=reserved) ;
2bit Sampling_frequency ; 1 byte
1bit Padding_bit ;
1bit Private_bit ;/
2bit Mode ;\
2bit Mode_extension (aka bound) ;
1bit Copyright ; 1 byte
1bit Original/home ;
2bit Emphasis ;/
</code></pre>
<h4 id="mp2-checksum-optional">MP2 Checksum (optional)</h4>
<pre><code> 16bit CRC
</code></pre>
<h4 id="allocation-information">Allocation Information</h4>
<h4 id="scale-factor-selector-information">Scale Factor Selector Information</h4>
<h4 id="scale-factors">Scale Factors</h4>
<h4 id="data">Data</h4>
<pre><code> XXX...
</code></pre>
<h2 id="inflate">Inflate</h2>
<p>Inflate/Deflate is a common (de-)compression algorithm. In the PSX world, it's
used by the .CDZ cdrom-image format.<br/></p>
<p><a href="./#inflate-core-functions">Inflate - Core Functions</a><br/>
<a href="./#inflate-initialization--tree-creation">Inflate - Initialization &amp; Tree Creation</a><br/>
<a href="./#inflate-headers-and-checksums">Inflate - Headers and Checksums</a><br/></p>
<h2 id="inflate-core-functions">Inflate - Core Functions</h2>
<h4 id="tinf_uncompressdstsrc">tinf_uncompress(dst,src)</h4>
<pre><code> tinf_init() ;init constants (needed to be done only once)
tinf_align_src_to_byte_boundary()
repeat
bfinal=tinf_getbit() ;read final block flag (1 bit)
btype=tinf_read_bits(2) ;read block type (2 bits)
if btype=0 then tinf_inflate_uncompressed_block()
if btype=1 then tinf_build_fixed_trees(), tinf_inflate_compressed_block()
if btype=2 then tinf_decode_dynamic_trees(), tinf_inflate_compressed_block()
if btype=3 then ERROR ;reserved
until bfinal=1
tinf_align_src_to_byte_boundary()
ret
</code></pre>
<h4 id="tinf_inflate_uncompressed_block">tinf_inflate_uncompressed_block()</h4>
<pre><code> tinf_align_src_to_byte_boundary()
len=LittleEndian16bit[src+0] ;get len
if LittleEndian16bit[src+2]&lt;&gt;(len XOR FFFFh) then ERROR ;verify inverse len
src=src+4 ;skip len values
for i=0 to len-1, [dst]=[src], dst=dst+1, src=src+1, next i ;copy block
ret
</code></pre>
<h4 id="tinf_inflate_compressed_block">tinf_inflate_compressed_block()</h4>
<pre><code> repeat
sym1=tinf_decode_symbol(tinf_len_tree)
if sym1&lt;256
[dst]=sym1, dst=dst+1
if sym1&gt;256
len = tinf_read_bits(length_bits[sym1-257])+length_base[sym1-257]
sym2 = tinf_decode_symbol(tinf_dist_tree)
dist = tinf_read_bits(dist_bits[sym2])+dist_base[sym2]
for i=0 to len-1, [dst]=[dst-dist], dst=dst+1, next i
until sym1=256
ret
</code></pre>
<h4 id="tinf_decode_symboltree">tinf_decode_symbol(tree)</h4>
<pre><code> sum=0, cur=0, len=0
repeat ;get more bits while code value is above sum
cur=cur*2 + tinf_getbit()
len=len+1
sum=sum+tree.table[len]
cur=cur-tree.table[len]
until cur&lt;0
return tree.trans[sum+cur]
</code></pre>
<h4 id="tinf_read_bitsnum-get-n-bits-from-source-stream">tinf_read_bits(num) ;get N bits from source stream</h4>
<pre><code> val=0
for i=0 to num-1, val=val+(tinf_getbit() shl i), next i
return val
</code></pre>
<h4 id="tinf_getbit-get-one-bit-from-source-stream">tinf_getbit() ;get one bit from source stream</h4>
<pre><code> bit=tag AND 01h, tag=tag/2
if tag=00h then tag=[src], src=src+1, bit=tag AND 01h, tag=tag/2+80h
return bit
</code></pre>
<h4 id="tinf_align_src_to_byte_boundary">tinf_align_src_to_byte_boundary()</h4>
<pre><code> tag=01h ;empty/end-bit (discard any bits, align src to byte-boundary)
ret
</code></pre>
<h2 id="inflate-initialization-tree-creation">Inflate - Initialization &amp; Tree Creation</h2>
<h4 id="tinf_init">tinf_init()</h4>
<pre><code> tinf_build_bits_base(length_bits, length_base, 4, 3)
length_bits[28]=0, length_base[28]=258
tinf_build_bits_base(dist_bits, dist_base, 2, 1)
ret
</code></pre>
<h4 id="tinf_build_bits_basebitsbasedeltabase_val">tinf_build_bits_base(bits,base,delta,base_val)</h4>
<pre><code> for i=0 to 29
bits[i]=min(0,i-delta)/delta
base[i]=base_val
base_val=base_val+(1 shl bits[i])
ret
</code></pre>
<h4 id="tinf_build_fixed_trees">tinf_build_fixed_trees()</h4>
<pre><code> for i=0 to 6, tinf_len_tree.table[i]=0, next i ;[0..6]=0 ;len tree...
tinf_len_tree.table[7,8,9]=24,152,112 ;[7..9]=24,152,112
for i=0 to 23, tinf_len_tree.trans[i+0] =i+256, next i ;[0..23] =256..279
for i=0 to 143, tinf_len_tree.trans[i+24] =i+0, next i ;[24..167] =0..143
for i=0 to 7, tinf_len_tree.trans[i+168]=i+280, next i ;[168..175]=280..287
for i=0 to 111, tinf_len_tree.trans[i+176]=i+144, next i ;[176..287]=144..255
for i=0 to 4, tinf_dist_tree.table[i]=0, next i ;[0..4]=0,0,0,0,0 ;\dist
tinf_dist_tree.table[5]=32 ;[5]=32 ; tree
for i=0 to 31, tinf_dist_tree.trans[i]=i, next i ;[0..31]=0..31 ;/
ret
</code></pre>
<h4 id="tinf_decode_dynamic_trees">tinf_decode_dynamic_trees()</h4>
<pre><code> hlit = tinf_read_bits(5)+257 ;get 5 bits HLIT (257-286)
hdist = tinf_read_bits(5)+1 ;get 5 bits HDIST (1-32)
hclen = tinf_read_bits(4)+4 ;get 4 bits HCLEN (4-19)
for i=0 to 18, lengths[i]=0, next i
for i=0 to hclen-1 ;read lengths for code length alphabet
lengths[clcidx[i]]=tinf_read_bits(3) ;get 3 bits code length (0-7)
tinf_build_tree(code_tree, lengths, 19) ;build code length tree
for num=0 to hlit+hdist-1 ;decode code lengths for dynamic trees
sym = tinf_decode_symbol(code_tree)
len=1, val=sym ;default (for sym=0..15)
if sym=16 then len=tinf_read_bits(2)+3, val=lengths[num-1] ;3..6 previous
if sym=17 then len=tinf_read_bits(3)+3, val=0 ;3..10 zeroes
if sym=18 then len=tinf_read_bits(7)+11, val=0 ;11..138 zeroes
for i=1 to len, lengths[num]=val, num=num+1, next i
tinf_build_tree(tinf_len_tree, 0, hlit) ;\build trees
tinf_build_tree(tinf_dist_tree, 0+hlit, hdist) ;/
ret
</code></pre>
<h4 id="tinf_build_treetree-first-num">tinf_build_tree(tree, first, num)</h4>
<pre><code> for i=0 to 15, tree.table[i]=0, next i ;clear code length count table
;scan symbol lengths, and sum code length counts...
for i=0 to num-1, x=lengths[i+first], tree.table[x]=tree.table[x]+1, next i
tree.table[0]=0
sum=0 ;compute offset table for distribution sort
for i=0 to 15, offs[i]=sum, sum=sum+tree.table[i], next i
for i=0 to num-1 ;create code to symbol xlat table (symbols sorted by code)
x=lengths[i+first], if x&lt;&gt;0 then tree.trans[offs[x]]=i, offs[x]=offs[x]+1
next i
ret
</code></pre>
<h4 id="tinf_data">tinf_data</h4>
<pre><code> clcidx[0..18] = 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 ;constants
</code></pre>
<pre><code> typedef struct TINF_TREE:
unsigned short table[16] ;table of code length counts
unsigned short trans[288] ;code to symbol translation table
</code></pre>
<pre><code> TINF_TREE tinf_len_tree ;length/symbol tree
TINF_TREE tinf_dist_tree ;distance tree
TINF_TREE code_tree ;temporary tree (for generating the dynamic trees)
unsigned char lengths[288+32] ;temporary 288+32 x 8bit ;\for dynamic tree
unsigned short offs[16] ;temporary 16 x 16bit ;/creation
</code></pre>
<pre><code> unsigned char length_bits[30]
unsigned short length_base[30]
unsigned char dist_bits[30]
unsigned short dist_base[30]
</code></pre>
<h2 id="inflate-headers-and-checksums">Inflate - Headers and Checksums</h2>
<h4 id="tinf_gzip_uncompressvoid-dest-destlen-source-sourcelen">tinf_gzip_uncompress(void *dest, *destLen, *source, sourceLen)</h4>
<pre><code> src_start=src, dst_start=dst ;memorize start addresses
if (src[0]&lt;&gt;1fh or src[1]&lt;&gt;8Bh) then ERROR ;check id bytes
if (src[2]&lt;&gt;08h) then ERROR ;check method is deflate
flg=src[3] ;get flag byte
if (flg AND 0E0h) then ERROR ;verify reserved bits
src=src+10 ;skip base header
if (flg AND 04h) then src=src+2+LittleEndian16bit[src] ;skip extra data
if (flg AND 08h) then repeat, src=src+1, until [src-1]=00h ;skip file name
if (flg AND 10h) then repeat, src=src+1, until [src-1]=00h ;skip file comment
hcrc=(tinf_crc32(src_start, src-src_start) &amp; 0000ffffh)) ;calc header crc
if (flg AND 02h) then x=LittleEndian16bit[src], src=src+2 ;get header crc
if (flg AND 02h) then if x&lt;&gt;hcrc then ERROR ;verify header
tinf_uncompress(dst, destLen, src, src_start+sourceLen-src-8) ;----&gt; inflate
crc32=LittleEndian32bit[src], src=src+4 ;get crc32 of decompressed data
dlen=LittleEndian32bit[src], src=src+4 ;get decompressed length
if (dlen&lt;&gt;destLen) then ERROR ;verify dest len
if (crc32&lt;&gt;tinf_crc32(dst_start,dlen)) then ERROR ;verify crc32
ret
</code></pre>
<h4 id="tinf_zlib_uncompressdst-destlen-src-sourcelen">tinf_zlib_uncompress(dst, destLen, src, sourceLen)</h4>
<pre><code> src_start=src, dst_start=dst ;memorize start addresses
hdr=BigEndian16bit[src], src=src+2 ;get header
if (hdr MOD 31)&lt;&gt;0 then ERROR ;check header checksum (modulo)
if (hdr AND 20h)&gt;0 then ERROR ;check there is no preset dictionary
if (hdr AND 0F00h)&lt;&gt;0800h then ERROR ;check method is deflate
if (had AND 0F000h)&gt;7000h then ERROR ;check window size is valid
tinf_uncompress(dst, destLen, src, sourceLen-6) ;------&gt; inflate
chk=BigEndian32bit[src], src=src+4 ;get data checksum
if src-src_start&lt;&gt;sourceLen then ERROR ;verify src len
if dst-dst_start&lt;&gt;destLen then ERROR ;verify dst len
if a32&lt;&gt;tinf_adler32(dst_start,destLen)) then ERROR ;verify data checksum
ret
</code></pre>
<h4 id="tinf_adler32src-length">tinf_adler32(src, length)</h4>
<pre><code> s1=1, s2=0
while (length&gt;0)
k=max(length,5552)
for i=0 to k-1, s1=s1+[src], s2=s2+s1, src=src+1, next i
s1=s1 mod 65521, s2=s2 mod 65521, length=length-k
return (s2*10000h+s1)
</code></pre>
</article>
</div>
</div>
</main>
<footer class="md-footer">
<nav aria-label="Footer" class="md-footer__inner md-grid">
<a class="md-footer__link md-footer__link--prev" href="../aboutcredits/" rel="prev">
<div class="md-footer__button md-icon">
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"></path></svg>
</div>
<div class="md-footer__title">
<div class="md-ellipsis">
<span class="md-footer__direction">
Previous
</span>
About &amp; Credits
</div>
</div>
</a>
<a class="md-footer__link md-footer__link--next" href="../cdrominternalinfoonpsxcdromcontroller/" rel="next">
<div class="md-footer__title">
<div class="md-ellipsis">
<span class="md-footer__direction">
Next
</span>
CDROM Internal Info on PSX CDROM Controller
</div>
</div>
<div class="md-footer__button md-icon">
<svg viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4z"></path></svg>
</div>
</a>
</nav>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-footer-copyright">
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" rel="noopener" target="_blank">
Material for MkDocs
</a>
... <a class="link--pdf-download" download href="../psx-spx.pdf" title="PDF">download PDF</a></div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": "..", "features": [], "translations": {"clipboard.copy": "Copy to clipboard", "clipboard.copied": "Copied to clipboard", "search.config.lang": "en", "search.config.pipeline": "trimmer, stopWordFilter", "search.config.separator": "[\\s\\-]+", "search.placeholder": "Search", "search.result.placeholder": "Type to start searching", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.term.missing": "Missing"}, "search": "../assets/javascripts/workers/search.fe42c31b.min.js", "version": null}</script>
<script src="../assets/javascripts/bundle.4ea5477f.min.js"></script>
</body>
</html>