Builds structurally valid JPEG byte streams for testing the scanner.
The scanner's job is to be right about the awkward cases — stuffed bytes,
restart markers, fill bytes, an EOI buried inside an EXIF thumbnail — and
real camera output gives no control over which of those show up in a given
capture. This builder makes each one reproducible on demand.
The images are structurally valid, not decodable: quantisation and Huffman tables are filler. Nothing here decodes a JPEG, so that costs nothing, and it keeps the fixtures small enough to assert on byte-exactly.
It ships in lib, not test/support, because every camera driver built on
this package needs it to feed BB.Camera.FFmpeg.Test.StubBackend, and a
dependency's test/support is never compiled. It is for tests only.
Summary
Functions
Build one JPEG image.
Split a binary into chunks of at most size bytes.
Concatenate images into an MJPEG stream.
An APP1 segment carrying a whole JPEG, the way an EXIF thumbnail does.
Functions
Build one JPEG image.
Options
:width,:height— dimensions written into the frame header. Default64x48.:components— number of colour components. Default3.:sampling— the luma component's{horizontal, vertical}sampling factors, which decide the chroma format. Default{2, 2}, which is 4:2:0.:precision— sample precision in bits. Default8.:progressive?— emit anSOF2rather than anSOF0frame header. Defaultfalse.:frame_header?— emit a frame header at all. Defaulttrue;falsebuilds the degenerate marker-soup image that has no dimensions.:entropy— bytes for the scan. Any0xFFis byte-stuffed for you, so arbitrary binaries are safe to pass. Default 256 bytes including an explicit0xFF.:restarts— how manyRSTmarkers to interleave into the scan data. Default0.:segments—{marker_byte, payload}pairs emitted before the frame header, forAPP/COMsegments. Default[].:fill— how many0xFFfill bytes to put before theEOImarker. Default0.:scans— how many scans to emit. More than one is what a progressive image looks like. Default1.
@spec chunks(binary(), pos_integer()) :: [binary()]
Split a binary into chunks of at most size bytes.
Capture hands over whatever the pipe had ready, so every boundary is a boundary the framer has to survive.
Concatenate images into an MJPEG stream.
An APP1 segment carrying a whole JPEG, the way an EXIF thumbnail does.
Pass it through :segments to build an image that contains FF D9 long
before its own end — the case that breaks framing by naive marker search.