src/jpeg_enc.bend checks
raw source on the hub · import emerging-ezimg@1.5.0.0/src/jpeg_enc.bend as Jpeg_enc
src/jpeg_enc: baseline JPEG encode. Sequential 8-bit Huffman (SOF0) and JFIF APP0. Colour is YCbCr, 4:4:4 (one 8 by 8 block per component per MCU) or 4:2:0 (a 16 by 16 MCU: four Y blocks, then one Cb and one Cr block, each chrominance sample the mean of 2 by 2 samples, rounded with libjpeg's alternating bias of 1 and 2, the edge samples repeated past the raster as libjpeg repeats them). A raster whose every sample has red, green and blue the same is one gray component (Y only, the luminance tables only), as libjpeg writes a grayscale image: its samples are the luminance, exactly. Samples are packed 0xAARRGGBB, the layout decode returns; the alpha byte is ignored. Quantisation is T.81 Annex K's tables K.1 (luminance) and K.2 (chrominance), scaled for a quality of 1 to 100 as the IJG library scales them, so a file is the size libjpeg writes at that quality. Y uses K.1 and the Annex K luminance Huffman tables (K.3, K.5); Cb and Cr use K.2 and the chrominance tables (K.4, K.6). The forward DCT (T.81 A.3.3) pairs samples that share a cosine weight, then rounds once with the same fixed-point product as a matrix column; the column pass divides each coefficient by its quantisation step, rounding half away from zero, as libjpeg does. A coefficient indexes its symbol in a book written out from the Annex K tables. The scan does not walk the table. An MCU reads each pixel once and keeps the three level planes in arrays. A neutral plane (every sample 128) is an all-zero block, coded without the DCT. The coding is lossy. Progressive and arithmetic frames are not written. Width and height must sit in 1..65535; anything else is SOI then EOI.
2 imports
import Base import ./jpeg.bend as Jpeg
Types
type Put source · line 27 · raw
Data
bytes emitted so far (newest first), the open byte, and how many bits it holds
Put@out:List<&2, U32> -> @buf:U32 -> @n:U32 -> Put
type Kern source · line 31 · raw
Data
cosine weights shared by symmetric samples: DC, two even weights, four odd weights
Kern@k0:U32 -> @k2:U32 -> @k6:U32 -> @o0:U32 -> @o1:U32 -> @o2:U32 -> @o3:U32 -> Kern
type Ctx source · line 35 · raw
Data
the cosine kernel, the zigzag, and each table's quantisation steps, one Oct per frequency column
Ctx@kern:Kern -> @zig:List<&2, U32> -> @ql:List<&2, Oct> -> @qc:List<&2, Oct> -> Ctx
type Book source · line 39 · raw
Type
DC and AC symbols indexed to a packed code: length in the high half, code in the low half
Book@dc:Array<U32> -> @ac:Array<U32> -> Book
type Code source · line 43 · raw
Data
one looked-up Huffman code
Code@len:U32 -> @bits:U32 -> Code
type Oct source · line 47 · raw
Data
eight values, the first at frequency 0
Oct@f0:U32 -> @f1:U32 -> @f2:U32 -> @f3:U32 -> @f4:U32 -> @f5:U32 -> @f6:U32 -> @f7:U32 -> Oct
type Plane source · line 51 · raw
Type
a chrominance plane and whether its every sample is level
Plane@px:Array<U32> -> @flat:Bool -> Plane
type Coder source · line 55 · raw
Data
what codes a block: the transform's kernel, the zigzag order and the quantization table
Coder@kern:Kern -> @zig:List<&2, U32> -> @qt:List<&2, Oct> -> Coder
type Pend source · line 59 · raw
Type
the chrominance's book and its two predictors, held while the luminance blocks are coded
Pend@book:Book -> @pb:U32 -> @pr:U32 -> Pend
type Spot source · line 63 · raw
Data
an MCU's corner and the image's size
Spot@x:U32 -> @y:U32 -> @w:U32 -> @h:U32 -> Spot
type Four source · line 67 · raw
Data
four weights of one odd frequency, paired with four sample differences
Four@w0:U32 -> @w1:U32 -> @w2:U32 -> @w3:U32 -> Four
type Planes source · line 71 · raw
Type
the sample plane, the frequency plane, and the next column of one forward DCT
Planes@src:Array<U32> -> @dst:Array<U32> -> @at:U32 -> Planes
type Layout source · line 76 · raw
Data
the frame the encoder writes: three components, Cb and Cr sampled as Y (4:4:4), or one gray component, or three components with Cb and Cr sampled at half Y's rate each way (4:2:0)
K444Layout
KGrayLayout
K420Layout
type Quad source · line 83 · raw
Type
a 4:2:0 quad's four samples: packed pixels, the level plane, whether it is the neutral level, and the chrominance sums so far
Quad@pix:Array<U32> -> @ys:Array<U32> -> @fy:Bool -> @sb:U32 -> @sr:U32 -> Quad
type GTile source · line 87 · raw
Type
one gray MCU: packed pixels, the level plane, and whether it is the neutral level
GTile@pix:Array<U32> -> @ys:Array<U32> -> @fy:Bool -> GTile
type Tile source · line 91 · raw
Type
one MCU: packed pixels, three level planes, and whether each plane is the neutral level
Tile@pix:Array<U32> -> @ys:Array<U32> -> @bs:Array<U32> -> @rs:Array<U32> -> @fy:Bool -> @fb:Bool -> @fr:Bool -> Tile
type Scan source · line 95 · raw
Type
frequency plane, the open zero run, and the AC coder
Scan@arr:Array<U32> -> @run:U32 -> @ac:Array<U32> -> @bit:Put -> Scan
Definitions
def encode.join source · line 98 · raw
@aa:List<&2, U32> -> @bb:List<&2, U32> -> List<&2, U32>
def encode.len source · line 101 · raw
@xs:List<&2, U32> -> U32
def encode.seg source · line 104 · raw
@+mark:U32 -> @+body:List<&2, U32> -> List<&2, U32>
def encode.app0 source · line 108 · raw
List<&2, U32>
def encode.either source · line 112 · raw
@bb:Bool -> @+aa:U32 -> @+cc:U32 -> U32
the first value when bb holds, else the second
def encode.lumq source · line 122 · raw
List<&2, U32>
T.81 Annex K, Table K.1: the luminance quantisation table, row by row
def encode.chrq source · line 128 · raw
List<&2, U32>
T.81 Annex K, Table K.2: the chrominance quantisation table, row by row
def encode.qual source · line 134 · raw
@+qq:U32 -> U32
a quality below 1 is 1 and one above 100 is 100, as the IJG library takes it (jpeg_quality_scaling)
def encode.qscale source · line 138 · raw
@+qq:U32 -> U32
the IJG percentage of the Annex K tables for a quality of 1 to 100: 5000 / q below 50, else 200 - 2 q
def encode.qstep source · line 143 · raw
@+tt:U32 -> @+ss:U32 -> U32
one table entry at a percentage: (t s + 50) / 100, kept in 1 to 255 for a baseline table, as the IJG library rounds and clamps it (jpeg_add_quant_table with force_baseline)
def encode.qnat source · line 148 · raw
@xs:List<&2, U32> -> @+ss:U32 -> List<&2, U32>
each entry of a table at a percentage
def encode.qrows source · line 157 · raw
@+base:List<&2, U32> -> @+qq:U32 -> List<&2, U32>
a table for a quality, row by row
def encode.qzig source · line 161 · raw
@zig:List<&2, U32> -> @+qn:List<&2, U32> -> List<&2, U32>
a table's entries in zigzag order, as DQT holds them (T.81 B.2.4.1)
def encode.qz source · line 170 · raw
@+base:List<&2, U32> -> @+qq:U32 -> List<&2, U32>
the DQT entries of a table for a quality
def encode.qcol source · line 174 · raw
@+qn:List<&2, U32> -> @+cc:U32 -> Oct
frequency column cc of a table, row by row
def encode.qcols source · line 180 · raw
@+qn:List<&2, U32> -> List<&2, Oct>
a table's eight frequency columns, as the column pass divides them
def encode.dqtbody source · line 185 · raw
@+kd:Layout -> @+qq:U32 -> List<&2, U32>
the DQT body: luminance as table 0, chrominance as table 1; a gray frame's luminance table alone
def encode.dqt source · line 194 · raw
@+kd:Layout -> @+qq:U32 -> List<&2, U32>
def encode.sofcomps source · line 199 · raw
@+kd:Layout -> List<&2, U32>
the SOF0 components: Y sampled 1 by 1 with table 0, Cb and Cr 1 by 1 with table 1; or Y alone; or Y sampled 2 by 2, Cb and Cr 1 by 1
def encode.sofbody source · line 208 · raw
@+kd:Layout -> @+ww:U32 -> @+hh:U32 -> List<&2, U32>
def encode.sof source · line 212 · raw
@+kd:Layout -> @+ww:U32 -> @+hh:U32 -> List<&2, U32>
def encode.dccounts source · line 216 · raw
List<&2, U32>
T.81 Annex K, Table K.3: luminance DC code lengths
def encode.dcsyms source · line 220 · raw
List<&2, U32>
the DC symbols of either table: sizes 0 to 11
def encode.accounts source · line 224 · raw
List<&2, U32>
Table K.5: luminance AC code lengths
def encode.acsyms source · line 227 · raw
List<&2, U32>
def encode.cdccounts source · line 237 · raw
List<&2, U32>
Table K.4: chrominance DC code lengths
def encode.caccounts source · line 241 · raw
List<&2, U32>
Table K.6: chrominance AC code lengths
def encode.cacsyms source · line 244 · raw
List<&2, U32>
def encode.dht source · line 254 · raw
@+cls:U32 -> @+lc:List<&2, U32> -> @+ls:List<&2, U32> -> @+cc:List<&2, U32> -> @+cs:List<&2, U32> -> List<&2, U32>
one DHT segment holding a class's two tables: luminance as table 0, chrominance as table 1
def encode.dcbody source · line 264 · raw
@+kd:Layout -> List<&2, U32>
the DC DHT body: both DC tables; a gray frame's luminance table alone
def encode.acbody source · line 276 · raw
@+kd:Layout -> List<&2, U32>
the AC DHT body: both AC tables; a gray frame's luminance table alone
def encode.sosbody source · line 288 · raw
@+kd:Layout -> List<&2, U32>
the SOS body: Y with Huffman tables 0, Cb and Cr with tables 1; or Y alone
def encode.header source · line 297 · raw
@+ww:U32 -> @+hh:U32 -> @+qq:U32 -> @+kd:Layout -> List<&2, U32>
def encode.kern source · line 303 · raw
@+cs:List<&2, U32> -> Kern
C[0][0], C[0][2], C[0][6], and the first four weights of frequency 1
def encode.kern.drop source · line 307 · raw
@kern:Kern -> U32
def encode.ctx source · line 320 · raw
@+qq:U32 -> Ctx
the cosine kernel, the zigzag, and the quantisation columns of both tables at a quality
def encode.bad.b source · line 324 · raw
@bw:Bool -> @bh:Bool -> Bool
def encode.bad.h source · line 331 · raw
@zz:Bool -> @bw:Bool -> @bh:Bool -> Bool
def encode.bad.w source · line 338 · raw
@zz:Bool -> @zh:Bool -> @bw:Bool -> @bh:Bool -> Bool
def encode.bad source · line 345 · raw
@+ww:U32 -> @+hh:U32 -> Bool
def encode.put0 source · line 348 · raw
Put
def encode.stuff source · line 352 · raw
@out:List<&2, U32> -> @+bb:U32 -> Put
a finished byte. Bytes are kept as written; encode.pad stuffs them once, at the end.
def encode.bit.n source · line 355 · raw
@full:Bool -> @out:List<&2, U32> -> @+nb:U32 -> @+nn:U32 -> Put
def encode.bit source · line 362 · raw
@pp:Put -> @+bit:U32 -> Put
def encode.bits.go source · line 367 · raw
@left:Nat -> @pp:Put -> @+code:U32 -> Put
def encode.bits source · line 375 · raw
@pp:Put -> @+len:U32 -> @+code:U32 -> Put
def encode.stuff.put source · line 379 · raw
@ff:Bool -> @+bb:U32 -> @acc:List<&2, U32> -> List<&2, U32>
one byte put in front of the stuffed bytes after it: 255 is followed by a 0
def encode.stuff.all source · line 388 · raw
@out:List<&2, U32> -> @acc:List<&2, U32> -> List<&2, U32>
the written bytes, newest first, stuffed and put in order onto acc: every 255 is followed by a 0 (T.81 F.1.2.3). U32.is_eq, not a literal pattern, so a law reaches a symbolic byte.
def encode.pad.n source · line 395 · raw
@zz:Bool -> @out:List<&2, U32> -> @+buf:U32 -> @+nn:U32 -> List<&2, U32>
def encode.pad source · line 404 · raw
@pp:Put -> List<&2, U32>
the entropy-coded bytes: the open byte padded with 1 bits, then every byte stuffed, in order
def encode.drop source · line 409 · raw
@xs:List<&2, U32> -> U32
def encode.ldc source · line 416 · raw
Array<U32>
the codes of Annex K's tables, one word per symbol: a code's length in the high half, the code in the low half. They are the canonical codes of the counts and symbols DHT carries (T.81 C, K.3 to K.6), written out once; for every symbol, the decoder's table built from those counts decodes the book's code to the symbol (laws/JpegRoundTripKeepsSize.bend, jpeg_huff_dc and jpeg_huff_ac)
def encode.lac.lo source · line 421 · raw
Array<U32>
def encode.lac.hi source · line 448 · raw
Array<U32>
def encode.lac source · line 476 · raw
Array<U32>
its two halves, symbols 0 to 127 and 128 to 255
def encode.cdc source · line 479 · raw
Array<U32>
def encode.cac.lo source · line 484 · raw
Array<U32>
def encode.cac.hi source · line 511 · raw
Array<U32>
def encode.cac source · line 539 · raw
Array<U32>
its two halves, symbols 0 to 127 and 128 to 255
def encode.dcof source · line 543 · raw
@+cls:Bool -> Array<U32>
a class's DC book: luminance, or chrominance when cls is set
def encode.acof source · line 551 · raw
@+cls:Bool -> Array<U32>
a class's AC book
def encode.bookof source · line 559 · raw
@+cls:Bool -> Book
a class's books
def encode.cat.pick source · line 563 · raw
@lt:Bool -> @+cc:U32 -> @+rest:U32 -> U32
the first of two sizes when the value is below the limit, else the second
def encode.cat.go source · line 574 · raw
@left:Nat -> @+aa:U32 -> @+cc:U32 -> @+lim:U32 -> U32
the size of a magnitude: the first cc with aa below lim = 2^cc, left sizes tried, else cc. Each comparison is made with a constant limit, so a law over a symbolic value keeps one comparison per size.
def encode.cat source · line 583 · raw
@+vv:U32 -> U32
def encode.mag.s source · line 586 · raw
@+ss:U32 -> @+cat:U32 -> @+vv:U32 -> U32
def encode.mag source · line 593 · raw
@+cat:U32 -> @+vv:U32 -> U32
def encode.magp.z source · line 596 · raw
@zz:Bool -> @pp:Put -> @+cat:U32 -> @+vv:U32 -> Put
def encode.coded source · line 604 · raw
@got:Pair(Array<U32>, U32) -> Pair(Array<U32>, Code)
the indexed word is the length and the code
def encode.sym source · line 608 · raw
@aa:Array<U32> -> @+sym:U32 -> Pair(Array<U32>, Code)
def encode.dc.use source · line 611 · raw
@got:Pair(Array<U32>, Code) -> @pp:Put -> @+cat:U32 -> @+diff:U32 -> Pair(Array<U32>, Put)
def encode.dc source · line 616 · raw
@aa:Array<U32> -> @+pp:Put -> @+diff:U32 -> Pair(Array<U32>, Put)
def encode.clip.hi source · line 620 · raw
@hi:Bool -> @+vv:U32 -> @+lim:U32 -> U32
def encode.clip.lo source · line 627 · raw
@lo:Bool -> @+vv:U32 -> @+lim:U32 -> U32
def encode.clip.b source · line 635 · raw
@pos:Bool -> @+vv:U32 -> @+lim:U32 -> U32
by the sign, asked with U32.is_eq so a law reaches a symbolic value
def encode.clip source · line 642 · raw
@+vv:U32 -> @+lim:U32 -> U32
def encode.dcbias.b source · line 648 · raw
@pos:Bool -> @+vv:U32 -> U32
a DC clipped to T.81's range for 8-bit samples, -1024 to 1023, kept as that plus 1024 (0 to 2047), so the difference of two DCs has at most 11 bits (F.1.2.1) and is found without wrapping. The level shift keeps the forward DCT's DC in -1024..1015, so the clip never changes it.
def encode.dcbias source · line 656 · raw
@+vv:U32 -> U32
a DC clipped to -1024 to 1023, plus 1024
def encode.magp.n source · line 660 · raw
@zz:Bool -> @pp:Put -> @+cat:U32 -> @+mm:U32 -> Put
a negative DC difference -mm: its size's code, then its magnitude bits, 2^size - 1 - mm (F.1.2.1)
def encode.dc.use.neg source · line 669 · raw
@got:Pair(Array<U32>, Code) -> @pp:Put -> @+cat:U32 -> @+mm:U32 -> Pair(Array<U32>, Put)
the size's code of a negative DC difference, then its magnitude
def encode.dc.neg source · line 675 · raw
@aa:Array<U32> -> @+pp:Put -> @+mm:U32 -> Pair(Array<U32>, Put)
a negative DC difference, -mm
def encode.dcdiff.b source · line 680 · raw
@up:Bool -> @aa:Array<U32> -> @pp:Put -> @+bb:U32 -> @+pb:U32 -> Pair(Array<U32>, Put)
the DC difference of two biased DCs, by its sign
def encode.dcdiff source · line 688 · raw
@aa:Array<U32> -> @pp:Put -> @+bb:U32 -> @+pb:U32 -> Pair(Array<U32>, Put)
the DC difference of biased DC bb from biased predictor pb
def encode.emit source · line 691 · raw
@got:Pair(Array<U32>, Code) -> @pp:Put -> Pair(Array<U32>, Put)
def encode.eob source · line 696 · raw
@need:Bool -> @aa:Array<U32> -> @pp:Put -> Pair(Array<U32>, Put)
def encode.eob.on source · line 703 · raw
@need:Bool -> @st:Pair(Array<U32>, Put) -> Pair(Array<U32>, Put)
def encode.zrls.one source · line 708 · raw
@st:Pair(Array<U32>, Put) -> Pair(Array<U32>, Put)
def encode.zrls source · line 713 · raw
@left:Nat -> @st:Pair(Array<U32>, Put) -> Pair(Array<U32>, Put)
def encode.ac.mag source · line 720 · raw
@got:Pair(Array<U32>, Put) -> @+cat:U32 -> @+clip:U32 -> Pair(Array<U32>, Put)
def encode.ac.hit source · line 725 · raw
@got:Pair(Array<U32>, Put) -> @+sym:U32 -> @+cat:U32 -> @+clip:U32 -> Pair(Array<U32>, Put)
def encode.ac.step source · line 730 · raw
@+cc:U32 -> @+run:U32 -> @st:Pair(Array<U32>, Put) -> Pair(Array<U32>, Put)
def encode.ac.run source · line 739 · raw
@zero:Bool -> @+run:U32 -> U32
the zero run after one more coefficient
def encode.ac.at source · line 748 · raw
@zero:Bool -> @+cc:U32 -> @+run:U32 -> @st:Pair(Array<U32>, Put) -> Pair(Array<U32>, Put)
one more coefficient: a zero only lengthens the run
def encode.ac source · line 757 · raw
@zz:List<&2, U32> -> @+run:U32 -> @st:Pair(Array<U32>, Put) -> Pair(Array<U32>, Put)
the AC coefficients in zigzag order. U32.is_eq, not a literal pattern, so a law reaches a symbolic coefficient.
def encode.qnz source · line 764 · raw
@+qq:U32 -> U32
def encode.qdiv.s source · line 771 · raw
@+ss:U32 -> @+vv:U32 -> @+qq:U32 -> U32
def encode.qdiv source · line 778 · raw
@+vv:U32 -> @+qq:U32 -> U32
def encode.block.join source · line 781 · raw
@got:Pair(Array<U32>, Put) -> @dc2:Array<U32> -> @+dd:U32 -> Pair(Book, Pair(U32, Put))
def encode.block.dc source · line 785 · raw
@got:Pair(Array<U32>, Put) -> @ac:Array<U32> -> @+dd:U32 -> @rest:List<&2, U32> -> Pair(Book, Pair(U32, Put))
def encode.block.ac source · line 791 · raw
@book:Book -> @pp:Put -> @+pred:U32 -> @+dc0:U32 -> @rest:List<&2, U32> -> Pair(Book, Pair(U32, Put))
the DC, clipped to T.81's 8-bit range and biased by 1024, is written as its difference from the last and kept, so the next block can predict from it
def encode.block.go source · line 797 · raw
@book:Book -> @pp:Put -> @+pred:U32 -> @zz:List<&2, U32> -> Pair(Book, Pair(U32, Put))
def encode.add64.acc source · line 804 · raw
@+ph:U32 -> @+pl:U32 -> @acc:Pair(U32, U32) -> Pair(U32, U32)
def encode.add64 source · line 811 · raw
@prod:Pair(U32, U32) -> @acc:Pair(U32, U32) -> Pair(U32, U32)
add a signed product onto a 64-bit accumulator
def encode.mac source · line 817 · raw
@+coef:U32 -> @+samp:U32 -> @acc:Pair(U32, U32) -> Pair(U32, U32)
one more product on the accumulator
def encode.q17 source · line 822 · raw
@acc:Pair(U32, U32) -> @+fine:Bool -> U32
a finished sum rounded as the decoder's passes round it: the row pass (fine) keeps four fraction bits, the column pass takes them off, so a coefficient is rounded once
def encode.scale source · line 827 · raw
@+coef:U32 -> @+samp:U32 -> @+fine:Bool -> U32
def encode.two source · line 830 · raw
@+c0:U32 -> @+x0:U32 -> @+c1:U32 -> @+x1:U32 -> @+fine:Bool -> U32
def encode.two.n source · line 833 · raw
@+c0:U32 -> @+x0:U32 -> @+c1:U32 -> @+x1:U32 -> @+fine:Bool -> U32
def encode.four source · line 836 · raw
@ws:Four -> @+d0:U32 -> @+d1:U32 -> @+d2:U32 -> @+d3:U32 -> @+fine:Bool -> U32
def encode.even source · line 842 · raw
@samp:Oct -> @+k0:U32 -> @+k2:U32 -> @+k6:U32 -> @+fine:Bool -> Oct
even frequencies: symmetric samples share one weight
def encode.odd source · line 855 · raw
@+d0:U32 -> @+d1:U32 -> @+d2:U32 -> @+d3:U32 -> @os:Four -> @+fine:Bool -> Oct
odd frequencies: antisymmetric samples share one weight
def encode.dct8.od source · line 865 · raw
@+f0:U32 -> @+f2:U32 -> @+f4:U32 -> @+f6:U32 -> @od:Oct -> Oct
def encode.dct8.at source · line 871 · raw
@ev:Oct -> @od:Oct -> Oct
def encode.dct8 source · line 878 · raw
@samp:Oct -> @kern:Kern -> @+fine:Bool -> Oct
one 8-point transform, fine for the row pass. Pairing is the matrix product, so the rounded value matches.
def encode.put8 source · line 884 · raw
@oo:Oct -> @aa:Array<U32> -> @+at:U32 -> @+step:U32 -> Array<U32>
def encode.lay source · line 897 · raw
@oo:Oct -> @aa:Array<U32> -> @+at:U32 -> Array<U32>
def encode.scatter source · line 900 · raw
@oo:Oct -> @aa:Array<U32> -> @+at:U32 -> Array<U32>
def encode.oct.g7 source · line 903 · raw
@got:Pair(Array<U32>, U32) -> @+s0:U32 -> @+s1:U32 -> @+s2:U32 -> @+s3:U32 -> @+s4:U32 -> @+s5:U32 -> @+s6:U32 -> Pair(Array<U32>, Oct)
def encode.oct.g6 source · line 916 · raw
@got:Pair(Array<U32>, U32) -> @+s0:U32 -> @+s1:U32 -> @+s2:U32 -> @+s3:U32 -> @+s4:U32 -> @+s5:U32 -> @+i7:U32 -> Pair(Array<U32>, Oct)
def encode.oct.g5 source · line 929 · raw
@got:Pair(Array<U32>, U32) -> @+s0:U32 -> @+s1:U32 -> @+s2:U32 -> @+s3:U32 -> @+s4:U32 -> @+i6:U32 -> @+i7:U32 -> Pair(Array<U32>, Oct)
def encode.oct.g4 source · line 942 · raw
@got:Pair(Array<U32>, U32) -> @+s0:U32 -> @+s1:U32 -> @+s2:U32 -> @+s3:U32 -> @+i5:U32 -> @+i6:U32 -> @+i7:U32 -> Pair(Array<U32>, Oct)
def encode.oct.g3 source · line 955 · raw
@got:Pair(Array<U32>, U32) -> @+s0:U32 -> @+s1:U32 -> @+s2:U32 -> @+i4:U32 -> @+i5:U32 -> @+i6:U32 -> @+i7:U32 -> Pair(Array<U32>, Oct)
def encode.oct.g2 source · line 968 · raw
@got:Pair(Array<U32>, U32) -> @+s0:U32 -> @+s1:U32 -> @+i3:U32 -> @+i4:U32 -> @+i5:U32 -> @+i6:U32 -> @+i7:U32 -> Pair(Array<U32>, Oct)
def encode.oct.g1 source · line 981 · raw
@got:Pair(Array<U32>, U32) -> @+s0:U32 -> @+i2:U32 -> @+i3:U32 -> @+i4:U32 -> @+i5:U32 -> @+i6:U32 -> @+i7:U32 -> Pair(Array<U32>, Oct)
def encode.oct.g0 source · line 994 · raw
@got:Pair(Array<U32>, U32) -> @+i1:U32 -> @+i2:U32 -> @+i3:U32 -> @+i4:U32 -> @+i5:U32 -> @+i6:U32 -> @+i7:U32 -> Pair(Array<U32>, Oct)
def encode.oct.stride source · line 1008 · raw
@aa:Array<U32> -> @+at:U32 -> @+step:U32 -> Pair(Array<U32>, Oct)
eight samples starting at at, every step slots
def encode.col.use source · line 1018 · raw
@got:Pair(Array<U32>, Oct) -> @kern:Kern -> Pair(Array<U32>, Oct)
def encode.col source · line 1024 · raw
@arr:Array<U32> -> @+at:U32 -> @kern:Kern -> Pair(Array<U32>, Oct)
one frequency column, read straight from the plane
def encode.pix.sink source · line 1027 · raw
@aa:Array<U32> -> U32
def encode.book.sink source · line 1034 · raw
@book:Book -> U32
def encode.quant8 source · line 1040 · raw
@oo:Oct -> @qq:Oct -> Oct
a frequency column divided by its quantisation steps, each rounded half away from zero
def encode.qdrop source · line 1049 · raw
@qs:List<&2, Oct> -> U32
a table's columns, when no longer read
def encode.pass2.done source · line 1056 · raw
@st:Planes -> @kern:Kern -> @qs:List<&2, Oct> -> Array<U32>
def encode.pass2.put source · line 1065 · raw
@got:Pair(Array<U32>, Oct) -> @dst:Array<U32> -> @+at:U32 -> @qq:Oct -> Planes
def encode.pass2.step source · line 1070 · raw
@st:Planes -> @kern:Kern -> @qq:Oct -> Planes
def encode.pass2 source · line 1076 · raw
@left:Nat -> @st:Planes -> @+kern:Kern -> @qs:List<&2, Oct> -> Array<U32>
the column transforms, each column divided by its quantisation steps. left columns are still unread.
def encode.pass.rows.done source · line 1087 · raw
@st:Planes -> @kern:Kern -> Array<U32>
def encode.pass.rows.lay source · line 1095 · raw
@got:Pair(Array<U32>, Oct) -> @+kern:Kern -> @dst:Array<U32> -> @+at:U32 -> Planes
def encode.pass.rows.next source · line 1100 · raw
@st:Planes -> @+kern:Kern -> Planes
def encode.pass.rows source · line 1106 · raw
@left:Nat -> @st:Planes -> @+kern:Kern -> Array<U32>
eight row transforms. left rows are still unread.
def encode.pass.mid source · line 1113 · raw
@src:Array<U32> -> @+kern:Kern -> Array<U32>
def encode.freq source · line 1117 · raw
@src:Array<U32> -> @+kern:Kern -> @qs:List<&2, Oct> -> Array<U32>
level plane in, quantised natural-order coefficients out
def encode.sat source · line 1120 · raw
@over:Bool -> @+xx:U32 -> @+lim:U32 -> U32
def encode.sat8 source · line 1127 · raw
@over:Bool -> @+vv:U32 -> U32
def encode.y source · line 1134 · raw
@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32
def encode.cb source · line 1137 · raw
@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32
def encode.cr source · line 1140 · raw
@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32
def encode.ych source · line 1143 · raw
@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32
def encode.cbch source · line 1147 · raw
@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32
def encode.crch source · line 1151 · raw
@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32
def encode.pix.load source · line 1156 · raw
@left:Nat -> @px:List<&2, U32> -> @aa:Array<U32> -> @+ii:U32 -> Array<U32>
the first left samples, then the rest of the list is unused
def encode.flat.both source · line 1167 · raw
@aa:Bool -> @bb:Bool -> Bool
both samples are the neutral level
def encode.nx source · line 1176 · raw
@more:Bool -> @+mx:U32 -> U32
def encode.ny source · line 1183 · raw
@more:Bool -> @+my:U32 -> U32
def encode.scan.hit source · line 1190 · raw
@got:Pair(Array<U32>, Put) -> @arr:Array<U32> -> Scan
def encode.scan.skip source · line 1194 · raw
@sc:Scan -> @+cc:U32 -> Scan
def encode.scan.keep source · line 1200 · raw
@sc:Scan -> @+cc:U32 -> Scan
def encode.scan.bump source · line 1205 · raw
@zz:Bool -> @sc:Scan -> @+cc:U32 -> Scan
def encode.scan.val source · line 1213 · raw
@got:Pair(Array<U32>, U32) -> @+run:U32 -> @st:Pair(Array<U32>, Put) -> Scan
step is 1, so the frequency is the coefficient
def encode.scan.step source · line 1218 · raw
@sc:Scan -> @+gg:U32 -> Scan
def encode.scan.end source · line 1223 · raw
@sc:Scan -> Pair(Array<U32>, Put)
def encode.scan.ac source · line 1230 · raw
@rest:List<&2, U32> -> @sc:Scan -> Pair(Array<U32>, Put)
the rest of the zigzag, indexed in the frequency plane
def encode.scan.book source · line 1237 · raw
@got:Pair(Array<U32>, Put) -> @dc:Array<U32> -> @+dd:U32 -> Pair(Book, Pair(U32, Put))
def encode.scan.join source · line 1241 · raw
@got:Pair(Array<U32>, Put) -> @ac:Array<U32> -> @+dd:U32 -> @rest:List<&2, U32> -> @arr:Array<U32> -> Pair(Book, Pair(U32, Put))
def encode.scan.dc source · line 1251 · raw
@book:Book -> @pp:Put -> @+pred:U32 -> @+d0:U32 -> @rest:List<&2, U32> -> @arr:Array<U32> -> Pair(Book, Pair(U32, Put))
def encode.scan.open source · line 1264 · raw
@rest:List<&2, U32> -> @got:Pair(Array<U32>, U32) -> @book:Book -> @pp:Put -> @+pred:U32 -> Pair(Book, Pair(U32, Put))
def encode.scan.none source · line 1274 · raw
@book:Book -> @pp:Put -> @arr:Array<U32> -> @+pred:U32 -> Pair(Book, Pair(U32, Put))
def encode.scan source · line 1280 · raw
@book:Book -> @pp:Put -> @+pred:U32 -> @arr:Array<U32> -> @zig:List<&2, U32> -> Pair(Book, Pair(U32, Put))
DC at the first zigzag index, then the AC run, both read from the frequency plane
def encode.chan.flat source · line 1287 · raw
@plane:Array<U32> -> @book:Book -> @pp:Put -> @+pred:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+qs:List<&2, Oct> -> Pair(Book, Pair(U32, Put))
def encode.chan.mix source · line 1302 · raw
@plane:Array<U32> -> @book:Book -> @pp:Put -> @+pred:U32 -> @+kern:Kern -> @zig:List<&2, U32> -> @qs:List<&2, Oct> -> Pair(Book, Pair(U32, Put))
def encode.chan.go source · line 1313 · raw
@flat:Bool -> @plane:Array<U32> -> @book:Book -> @pp:Put -> @+pred:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+qs:List<&2, Oct> -> Pair(Book, Pair(U32, Put))
def encode.pix.at source · line 1329 · raw
@aa:Array<U32> -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> Pair(Array<U32>, U32)
def encode.tile.store source · line 1332 · raw
@got:Pair(Array<U32>, U32) -> @ys:Array<U32> -> @bs:Array<U32> -> @rs:Array<U32> -> @fy:Bool -> @fb:Bool -> @fr:Bool -> @+ii:U32 -> Tile
def encode.tile.pix source · line 1353 · raw
@tt:Tile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> Tile
def encode.tile.row source · line 1358 · raw
@left:Nat -> @tt:Tile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> Tile
def encode.tile.rows source · line 1366 · raw
@left:Nat -> @tt:Tile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> Tile
def encode.tile source · line 1375 · raw
@aa:Array<U32> -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> Tile
three level planes from one walk of this MCU
def encode.gtile.store source · line 1379 · raw
@got:Pair(Array<U32>, U32) -> @ys:Array<U32> -> @fy:Bool -> @+ii:U32 -> GTile
def encode.gtile.pix source · line 1384 · raw
@tt:GTile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> GTile
def encode.gtile.row source · line 1389 · raw
@left:Nat -> @tt:GTile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> GTile
def encode.gtile.rows source · line 1397 · raw
@left:Nat -> @tt:GTile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> GTile
def encode.gtile source · line 1406 · raw
@aa:Array<U32> -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> GTile
a gray MCU's level plane: each sample's blue, which is its red and green and so its luminance
def encode.gstep.end source · line 1409 · raw
@got:Pair(Book, Pair(U32, Put)) -> @aa:Array<U32> -> Pair(Array<U32>, Pair(Book, Pair(U32, Put)))
def encode.gstep.tile source · line 1414 · raw
@tt:GTile -> @lb:Book -> @bit:Put -> @+py:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+ql:List<&2, Oct> -> Pair(Array<U32>, Pair(Book, Pair(U32, Put)))
a gray MCU's one block, with the luminance book and table
def encode.gstep source · line 1427 · raw
@got:Pair(Array<U32>, Pair(Book, Pair(U32, Put))) -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(U32, Put)))
def encode.gmcus.done source · line 1440 · raw
@got:Pair(Array<U32>, Pair(Book, Pair(U32, Put))) -> Put
def encode.gmcus source · line 1447 · raw
@left:Nat -> @got:Pair(Array<U32>, Pair(Book, Pair(U32, Put))) -> @+mx:U32 -> @+my:U32 -> @+mw:U32 -> @+ww:U32 -> @+hh:U32 -> @+ctx:Ctx -> Put
def encode.step.end source · line 1467 · raw
@got:Pair(Book, Pair(U32, Put)) -> @lb:Book -> @aa:Array<U32> -> @+ydc:U32 -> @+bdc:U32 -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
def encode.step.cr source · line 1477 · raw
@got:Pair(Book, Pair(U32, Put)) -> @lb:Book -> @aa:Array<U32> -> @rp:Plane -> @+ydc:U32 -> @+pr:U32 -> @+cd:Coder -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
def encode.step.cb source · line 1491 · raw
@got:Pair(Book, Pair(U32, Put)) -> @cb:Book -> @aa:Array<U32> -> @bp:Plane -> @rp:Plane -> @+pb:U32 -> @+pr:U32 -> @+cd:Coder -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
def encode.step.tile source · line 1508 · raw
@tt:Tile -> @lb:Book -> @cb:Book -> @bit:Put -> @+py:U32 -> @+pb:U32 -> @+pr:U32 -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
Y with the luminance book and table, then Cb and Cr with the chrominance book and table. Each clipped DC is the next predictor.
def encode.step.y source · line 1524 · raw
@got:Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put)))))) -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
one walk of the MCU, then its three blocks
def encode.mcus.done source · line 1537 · raw
@got:Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put)))))) -> Put
def encode.mcus source · line 1545 · raw
@left:Nat -> @got:Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put)))))) -> @+mx:U32 -> @+my:U32 -> @+mw:U32 -> @+ww:U32 -> @+hh:U32 -> @+ctx:Ctx -> Put
def encode.quad.store source · line 1565 · raw
@got:Pair(Array<U32>, U32) -> @ys:Array<U32> -> @fy:Bool -> @+sb:U32 -> @+sr:U32 -> @+ii:U32 -> Quad
def encode.quad.pix source · line 1574 · raw
@qd:Quad -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> Quad
def encode.quad.put source · line 1580 · raw
@qd:Quad -> @bs:Array<U32> -> @rs:Array<U32> -> @fb:Bool -> @fr:Bool -> @+ci:U32 -> Tile
a quad's chrominance: the four samples' mean, rounded with the bias, stored at ci
def encode.quad source · line 1590 · raw
@tt:Tile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> @+ci:U32 -> @+bias:U32 -> Tile
the 2 by 2 samples at x, y: luminance at ii, ii + 1, ii + 8 and ii + 9, and one chrominance sample at ci, their mean plus the bias (1, or 2 at an odd chrominance column, as libjpeg's h2v2 downsampling rounds) over 4
def encode.quad.row source · line 1599 · raw
@left:Nat -> @tt:Tile -> @+sp:Spot -> @+ii:U32 -> @+ci:U32 -> @+bias:U32 -> Tile
def encode.quad.rows source · line 1608 · raw
@left:Nat -> @tt:Tile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> @+ci:U32 -> Tile
def encode.quad.block source · line 1618 · raw
@tt:Tile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ci:U32 -> Tile
one 8 by 8 luminance block of a 4:2:0 MCU at x, y, and the quarter of the chrominance planes it covers, from ci
def encode.h2.end source · line 1622 · raw
@got:Pair(Book, Pair(U32, Put)) -> @lb:Book -> @pix:Array<U32> -> @+py:U32 -> @+pb:U32 -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
the 4:2:0 MCU's last block, Cr, and the loop's state after it
def encode.h2.cr source · line 1632 · raw
@got:Pair(Book, Pair(U32, Put)) -> @lb:Book -> @pix:Array<U32> -> @rp:Plane -> @+py:U32 -> @+pr:U32 -> @+cd:Coder -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
def encode.h2.cb source · line 1647 · raw
@pix:Array<U32> -> @bp:Plane -> @rp:Plane -> @lb:Book -> @bit:Put -> @+py:U32 -> @pd:Pend -> @+cd:Coder -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
the 4:2:0 MCU's Cb and Cr blocks, after its four Y blocks
def encode.h2.n4 source · line 1662 · raw
@got:Pair(Book, Pair(U32, Put)) -> @pix:Array<U32> -> @bp:Plane -> @rp:Plane -> @pd:Pend -> @+sp:Spot -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
after the 4:2:0 MCU's Y block 3: the chrominance blocks
def encode.h2.y3 source · line 1679 · raw
@tt:Tile -> @lb:Book -> @bit:Put -> @+py:U32 -> @pd:Pend -> @+sp:Spot -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
the 4:2:0 MCU's Y block 3 (of 0 to 3, left to right, top to bottom), then the rest
def encode.h2.n3 source · line 1694 · raw
@got:Pair(Book, Pair(U32, Put)) -> @pix:Array<U32> -> @bp:Plane -> @rp:Plane -> @pd:Pend -> @+sp:Spot -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
after the 4:2:0 MCU's Y block 2: the next Y block and its quarter of the chrominance
def encode.h2.y2 source · line 1710 · raw
@tt:Tile -> @lb:Book -> @bit:Put -> @+py:U32 -> @pd:Pend -> @+sp:Spot -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
the 4:2:0 MCU's Y block 2 (of 0 to 3, left to right, top to bottom), then the rest
def encode.h2.n2 source · line 1725 · raw
@got:Pair(Book, Pair(U32, Put)) -> @pix:Array<U32> -> @bp:Plane -> @rp:Plane -> @pd:Pend -> @+sp:Spot -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
after the 4:2:0 MCU's Y block 1: the next Y block and its quarter of the chrominance
def encode.h2.y1 source · line 1741 · raw
@tt:Tile -> @lb:Book -> @bit:Put -> @+py:U32 -> @pd:Pend -> @+sp:Spot -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
the 4:2:0 MCU's Y block 1 (of 0 to 3, left to right, top to bottom), then the rest
def encode.h2.n1 source · line 1756 · raw
@got:Pair(Book, Pair(U32, Put)) -> @pix:Array<U32> -> @bp:Plane -> @rp:Plane -> @pd:Pend -> @+sp:Spot -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
after the 4:2:0 MCU's Y block 0: the next Y block and its quarter of the chrominance
def encode.h2.y0 source · line 1772 · raw
@tt:Tile -> @lb:Book -> @bit:Put -> @+py:U32 -> @pd:Pend -> @+sp:Spot -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
the 4:2:0 MCU's Y block 0 (of 0 to 3, left to right, top to bottom), then the rest
def encode.h2.step source · line 1788 · raw
@got:Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put)))))) -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))
one 4:2:0 MCU at x, y: four Y blocks with the luminance book and table, each walked with its quarter of the chrominance planes, then Cb and Cr with the chrominance book and table
def encode.h2.mcus source · line 1803 · raw
@left:Nat -> @got:Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put)))))) -> @+mx:U32 -> @+my:U32 -> @+mw:U32 -> @+ww:U32 -> @+hh:U32 -> @+ctx:Ctx -> Put
def encode.arm3 source · line 1824 · raw
@+ww:U32 -> @+hh:U32 -> @+qq:U32 -> @px:List<&2, U32> -> List<&2, U32>
the entropy-coded bytes of an accepted size at a quality, three components, MCU by MCU
def encode.armg source · line 1833 · raw
@+ww:U32 -> @+hh:U32 -> @+qq:U32 -> @px:List<&2, U32> -> List<&2, U32>
the entropy-coded bytes of an accepted size at a quality, one gray component, MCU by MCU
def encode.arm2 source · line 1841 · raw
@+ww:U32 -> @+hh:U32 -> @+qq:U32 -> @px:List<&2, U32> -> List<&2, U32>
the entropy-coded bytes of an accepted size at a quality, 4:2:0, MCU by MCU: 16 by 16 samples each
def encode.arm source · line 1850 · raw
@+ww:U32 -> @+hh:U32 -> @+qq:U32 -> @+kd:Layout -> @px:List<&2, U32> -> List<&2, U32>
the entropy-coded bytes of an accepted size at a quality, in the frame of kind kd
def encode.gray.one source · line 1860 · raw
@+pp:U32 -> Bool
one sample is gray: its red, green and blue the same
def encode.gray.all source · line 1865 · raw
@xs:List<&2, U32> -> @ok:Bool -> Bool
every sample is gray, while ok holds
def encode.kind.sub source · line 1879 · raw
@sub:Bool -> Layout
a colour frame: 4:2:0 when sub is set, else 4:4:4
def encode.kind.pick source · line 1888 · raw
@gray:Bool -> @+sub:Bool -> Layout
the kind of frame for the samples: one gray component when every sample is gray, else 4:2:0 when sub is set, else 4:4:4
def encode.kindof source · line 1896 · raw
@+sub:Bool -> @+px:List<&2, U32> -> Layout
def encode.finish source · line 1899 · raw
@+ww:U32 -> @+hh:U32 -> @+qq:U32 -> @+kd:Layout -> @ent:List<&2, U32> -> List<&2, U32>
def encode.pick source · line 1902 · raw
@bad:Bool -> @+ww:U32 -> @+hh:U32 -> @+qq:U32 -> @+kd:Layout -> @px:List<&2, U32> -> List<&2, U32>
def encode source · line 1915 · raw
@+ww:U32 -> @+hh:U32 -> @+qq:U32 -> @+sub:Bool -> @+px:List<&2, U32> -> List<&2, U32>
baseline sequential JPEG bytes for packed RGB samples at a quality of 1 to 100 (a quality outside it is the nearest end), 4:2:0 when sub is set, else 4:4:4, one gray component when every sample is gray; or SOI EOI when the size is rejected