cdg-decode
===

This is a simple CD+G and CD+EG decoder with some oddities for my own use.

This version will spawn a child ffmpeg process to encode MP4 output.


## Usage

```
cdg-decode disc.img disc.cdg disc.toc out-tmp.raw ffmpeg.exe out.mp4 start_track end_track mode
```

### Input

* `disc.img` is the audio data (16-bit stereo) for the CD in a single file disc image,
  part of this will be copied out to `out-tmp.raw`.
* `disc.cdg` is a single file with all the CD+G data, decoded and in logical pack
  order, as would be output by [redumper-extract-rw](https://github.com/hcs64/redumper-extract-rw).
* `disc.toc` is the table of contents from the disc, as recorded by redumper.
* `ffmpeg.exe` is the ffmpeg executable that will be run for encoding to MP4
* `start_track end_track` the first and last tracks to include in the output, inclusive (e.g.
  `3 3` to only output track 3).

  Note: Decoding will start at index 1 of `start_track`. If the graphics were encoded assuming
  playback proceeds from the previous track, there may be unwanted artifacts such as flashing.
* `mode` (optional) selects the graphics mode, `cdg` for CD+G (ignoring the EG commands), `cdeg` for CD+EG.
  For a non-EG disc this should have no effect. This is optional, if missing it will default to CD+G mode.

### Output

If the output files exist already they will not be overwritten and the conversion will fail.

* `out-tmp.raw` is the audio data, this is just a range copied from `disc.img`, must not be already
  present and will be deleted after encode
* `out.mp4` is the decoded video, scaled up 2x and reencoded as 60 FPS MP4, must not be already
  present

## Color

Colors are currently converted with a .5 bias then scaled by 16, instead of being scaled to a full 8
bit range (x17) as in some other decoders. This may be a mistake.
