# H264 Classic 1.0 The first release we call finished: Main and High profile H.264 with B-frames in QuickTime 6 on Mac OS 9, on a G4 **and** on a G3. It is decoder build **17g** (the log banner says `v17g`) plus the same AVCDecLib as the 17d release. ## Files (both go in System Folder:Extensions) | File | What it is | Licence | |---|---|---| | **H264 Decoder 1.0** | The QuickTime 6 decompressor component (build 17g), version 0x00010011 (65553). | MIT | | **AVCDecLib** | FFmpeg 0.8.15's H.264 decoder as a CFM shared library, version 0x00080F02 (r2), unchanged since 17d. | LGPL 2.1 or later | **Before installing, remove every older `H264 Decoder ...` file from Extensions** (17d, 17e, 17f, or the h264bsd v15 `H264 Decoder`). 1.0 keeps 17d's version number, 0x00010011, so if two are installed, whichever loads first wins and there is no message. Restart after installing. ## One decoder for G3 and G4 The same file runs on both. At startup it asks the CPU (Gestalt `'ppcf'`): - **G4 (AltiVec):** the AltiVec library and exactly 17d/17e's output formats and paint code. Host proofs: with G3 mode off, every picture, index and destination byte is identical to 17e. - **G3 (no AltiVec): G3 mode turns on by itself.** New since 17d: - **16-bit output at Thousands of colours.** The decoder offers 16-bit RGB first when the screen is 16-bit, so QuickTime no longer converts 2vuy to the screen itself. - **A G3-shaped colour converter:** two rows per pass, two pixels per word, cache prefetch (`dcbt`), every store aligned, 64-bit stores where the row allows. Bit-exact with the old converter on x86 and on a PowerPC 750 (big-endian) under emulation; never `dcbz`. - **Skip levels when the decoder falls behind:** level 1 skips the loop filter on non-reference pictures, level 2 on all pictures, level 3 drops half, then all, B-frames evenly (never a reference picture). Levels step up and down with hysteresis. QuickTime's own catch-up jumps keep the level; a real seek resets it. - **Safety clamps:** every writer stays inside the rectangle and pixmap QuickTime gives it. ### Overriding G3 mode: the `H264 G3 Mode` file An optional SimpleText file named `H264 G3 Mode` in the Desktop Folder. Its first digit: `0` = G3 mode off, `1` = on (useful to try G3 behaviour on a G4: it also turns the library's AltiVec off), `2` or no file = automatic. A letter `n` after the digit (`1n`) turns off the 64-bit stores. The decoder log records what it read. ## What a G3 can do (PowerBook G3 "Pismo", 500 MHz, Mac OS 9.1, QuickTime 6.0.3) Measured in frames actually painted per second (10-second clips, earlier builds): | Clip | Thousands | Millions | |---|---|---| | 320x240 Main/High | about 24-29 | about 28 | | 640x480 Baseline | about 12-16 | about 12 | | 640x480 Main/High | about 9-12 | about 9 | **320x240 to 480x360 is the sweet spot on a G3.** At 640x480 the limit is how fast a Pismo can write to its screen (about 48 MB/s, ~12.7 ms per frame at Thousands), not the decoding. The skip levels and steady B-frame thinning in 1.0 trade sharpness or frames for smoothness there. [Classic Media Center](https://github.com/smithwicks-red/classic-media-center) 0.8 G3 picks the lighter files on a G3 by itself. ## Tested on - **QEMU Mac OS 9.2.2** (UTM): build 17g with G3 mode forced on and off; the kit clip checker passes in both (300 of 300 pictures bit-exact). - **PowerBook G3 (Pismo)**: G3 mode with 16-bit output (build 17f), and a 13-minute 640x360 Main film played to the end. - **Mac mini G4**: the 17d release; 1.0's G4 path is host-proven identical to it apart from the statistics lines. - Host: the whole decoder under a stand-in Toolbox, checked against FFmpeg; a 13.5-minute YouTube film under AddressSanitizer (library included) and on an emulated PowerPC 750: 24,320 of 24,320 pictures, no memory errors. ## Known issues - Build 17g's 64-bit stores and level 3 have run on emulators and in the VM, not yet on a real G3. If you see trouble that 17f did not show, put `1n` in an `H264 G3 Mode` file and tell us. - Our test Pismo locked up several times under long full-load playback, also with QuickTime's own MPEG-4 decoder and after playback had ended. We believe it is that machine (RAM or heat) and are checking. Reports from other G3s are very welcome. - QuickTime Player needs about 32 MB for 640x480 Main/High with B-frames (Get Info > Memory). - B-frames on QuickTime 6, by design: plain files lose their last N pictures and files with negative `ctts` offsets play N frames late (see [`DECODER-17.md`](DECODER-17.md)). Classic Media Center rewrites such files. ## Details [`DECODER-17F.md`](DECODER-17F.md) (G3 mode, 16-bit output, statistics lines) and [`DECODER-17G.md`](DECODER-17G.md) (clamps, jump classes, 64-bit stores, level 3).