Baseline 4:2:0 JPEG test patterns with large entropy-coded data ================================================================= Synthetic 4:2:0 patterns built to make the entropy-coded segment (the scan data between SOS and EOI, byte stuffing included) as large as possible at quality 100 and 99 with the standard (Annex K) Huffman tables, 8-bit samples. They answer one question: how many bytes per pixel can a valid baseline 4:2:0 JPEG need? Not 3: libjpeg-turbo writes up to 3.35 B/px of scan data at q100. Each pattern is a 32x16 tile (two 16x16 MCUs) repeated over the frame. The tile was found by a search (pixel annealing and per-block search) against libjpeg-turbo 3.1.4.1's encoder. Repetition does not help the encoder: baseline JPEG codes every 8x8 block on its own (only the DC value is coded as a difference), so the bytes per pixel are the same at any frame size. Files ----- q100-96x48-q100.jpg q100 pattern, 96x48, quality 100 q99-96x48-q99.jpg q99 pattern, 96x48, quality 99 q100-640x480-q100.jpg q100 pattern, 640x480, quality 100 q99-640x480-q99.jpg q99 pattern, 640x480, quality 99 *.nv12 the same samples as raw NV12 (Y plane, then CbCr interleaved), one frame, for encoder tests make.py makes any of them at any size and quality from the tile (needs Pillow); the JPEGs here are its output MD5SUMS 96x48 is above the smallest frames that common hardware JPEG blocks accept (for example 48x48 for a decoder, 96x32 for the Hantro H1 encoder). Sizes (B/px = bytes / (width * height)) --------------------------------------- file bytes file B/px scan bytes scan B/px q100-96x48-q100.jpg 16029 3.4785 15404 3.3429 q99-96x48-q99.jpg 14796 3.2109 14171 3.0753 q100-640x480-q100.jpg 1030776 3.3554 1030151 3.3534 q99-640x480-q99.jpg 945621 3.0782 944996 3.0762 The 96x48 files are larger per pixel as a whole because the headers (about 600 bytes) weigh more on a small frame. The same patterns through a hardware encoder (the Hantro H1 JPEG encoder of a Rockchip RK3026, mainline hantro driver, 640x480 NV12 input): q100 pattern at quality 100: scan 3.1414 B/px q99 pattern at quality 99: scan 2.8809 B/px Upper bound for comparison: with the Annex K tables and 8-bit samples a baseline 4:2:0 scan at quality 100 is at most about 3.32 B/px before byte stuffing and 4.88 B/px after it. Other Huffman tables give a higher bound, and APPn/COM segments add any amount on top. Reproduce --------- python3 make.py q100 96 48 100 q100-96x48-q100 prints the file and scan sizes. The JPEGs here were made this way with Pillow 12.1.1 (its bundled libjpeg-turbo); libjpeg-turbo's TurboJPEG API (tj3CompressFromYUVPlanes8, quality 100, 4:2:0, no Huffman optimisation, ISLOW DCT) gives byte-identical files. Do not go through RGB (PNG and the like): the conversion clips the samples and the scan drops to about 2.4 B/px. Sergei Khomenkov, 2026-11-18. Free to use for any purpose.