1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Parallel-array index loops are idiomatic in codec code; skip the lint.
//! JPEG / Motion-JPEG codec, pure Rust.
//!
//! Each video packet is a standalone JPEG (one full SOI..EOI). The decoder
//! recognises baseline (SOF0), extended-sequential (SOF1), progressive
//! (SOF2), and lossless (SOF3) JPEGs with 4:2:0 / 4:2:2 / 4:4:4 chroma
//! subsampling (DCT variants) and outputs `VideoFrame`s in the matching
//! `Yuv*P` pixel format or `Gray8` for 1-component streams. SOF0 and
//! SOF1 share the same Huffman sequential scan structure at 8-bit
//! precision; both are handled by the same scan decoder, and
//! non-interleaved sequential scans (one SOS per component) fall back
//! to the same coefficient-accumulator path used by the progressive
//! decoder. Progressive scans accumulate DCT coefficients across
//! multiple SOS segments using both spectral selection and successive
//! approximation; the inverse DCT runs once after EOI. Restart markers
//! (`RSTn`) and DRI segments are honoured on both paths. APP0..APP15
//! segments (JFIF, EXIF, ICC, XMP, …) are skipped without parsing. The
//! encoder accepts the same pixel formats and produces a standalone
//! baseline JPEG using the Annex K "typical" Huffman tables, so its
//! output is interoperable with any compliant JPEG decoder. A
//! progressive (SOF2) output mode is available via
//! `encoder::MjpegEncoder::set_progressive` or
//! `encoder::encode_jpeg_progressive`; it emits a DC-first scan
//! followed by two per-component AC band scans (spectral selection
//! only, `Ah = Al = 0`).
//!
//! 4-component (CMYK / Adobe YCCK) JPEGs decode to packed `Cmyk` — the
//! decoder inspects the APP14 Adobe transform flag to choose among plain
//! CMYK, Adobe-inverted CMYK, and Adobe YCCK (which is colour-converted
//! back to CMYK via BT.601 full-range YCbCr→RGB→CMY plus K inversion).
//! 12-bit precision sequential JPEGs (SOF0/SOF1 with `P=12`) decode to
//! `Gray12Le` or `Yuv420P12Le`; sample buffers stay 16-bit throughout the
//! inverse DCT and the level shift uses 2048. Lossless JPEGs (SOF3)
//! decode single-component grayscale at any precision in 2..=16 bits
//! via Annex H predictor reconstruction (bit-exact, no DCT); output is
//! `Gray8` at P=8 and `Gray16Le` / `Gray10Le` / `Gray12Le` at wider
//! depths.
//!
//! **Not supported** (will return `Error::Unsupported`):
//! - Hierarchical (SOF5+) and arithmetic-coded (SOF9..SOF15) JPEGs
//! - 12-bit progressive (SOF2 with `P=12`)
//! - 12-bit 4:2:2 / 4:4:4 YUV (no matching output `PixelFormat`)
//! - Progressive 4-component JPEGs
//! - Multi-component lossless JPEGs (only grayscale is supported)
use ContainerRegistry;
use ;
use ;
pub const CODEC_ID_STR: &str = "mjpeg";
/// Register the still-image JPEG container (`.jpg` / `.jpeg`). Must be
/// called alongside [`register`] when wiring up a pipeline that expects
/// to read or write raw JPEG files.