~/bend-docscommunity

src/jpeg_enc.bend checks

raw source on the hub · import emerging-ezimg@1.4.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

type Kern source · line 31 · raw

Data

cosine weights shared by symmetric samples: DC, two even weights, four odd weights

type Ctx source · line 35 · raw

Data

the cosine kernel, the zigzag, and each table's quantisation steps, one Oct per frequency column

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

type Code source · line 43 · raw

Data

one looked-up Huffman code

type Oct source · line 47 · raw

Data

eight values, the first at frequency 0

type Planes source · line 51 · raw

Type

the sample plane, the frequency plane, and the next column of one forward DCT

type Layout source · line 56 · 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)

type Quad source · line 63 · 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

type GTile source · line 67 · raw

Type

one gray MCU: packed pixels, the level plane, and whether it is the neutral level

type Tile source · line 71 · raw

Type

one MCU: packed pixels, three level planes, and whether each plane is the neutral level

type Scan source · line 75 · raw

Type

frequency plane, the open zero run, and the AC coder

Definitions

def encode.join source · line 78 · raw

@aa:List<&2, U32> -> @bb:List<&2, U32> -> List<&2, U32>

def encode.len source · line 81 · raw

@xs:List<&2, U32> -> U32

def encode.seg source · line 84 · raw

@+mark:U32 -> @+body:List<&2, U32> -> List<&2, U32>

def encode.app0 source · line 88 · raw

List<&2, U32>

def encode.either source · line 92 · raw

@bb:Bool -> @+aa:U32 -> @+cc:U32 -> U32

the first value when bb holds, else the second

def encode.lumq source · line 102 · raw

List<&2, U32>

T.81 Annex K, Table K.1: the luminance quantisation table, row by row

def encode.chrq source · line 108 · raw

List<&2, U32>

T.81 Annex K, Table K.2: the chrominance quantisation table, row by row

def encode.qual source · line 114 · 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 118 · 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 123 · 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 128 · raw

@xs:List<&2, U32> -> @+ss:U32 -> List<&2, U32>

each entry of a table at a percentage

def encode.qrows source · line 137 · raw

@+base:List<&2, U32> -> @+qq:U32 -> List<&2, U32>

a table for a quality, row by row

def encode.qzig source · line 141 · 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 150 · raw

@+base:List<&2, U32> -> @+qq:U32 -> List<&2, U32>

the DQT entries of a table for a quality

def encode.qcol source · line 154 · raw

@+qn:List<&2, U32> -> @+cc:U32 -> Oct

frequency column cc of a table, row by row

def encode.qcols source · line 160 · 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 165 · 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 174 · raw

@+kd:Layout -> @+qq:U32 -> List<&2, U32>

def encode.sofcomps source · line 179 · 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 188 · raw

@+kd:Layout -> @+ww:U32 -> @+hh:U32 -> List<&2, U32>

def encode.sof source · line 192 · raw

@+kd:Layout -> @+ww:U32 -> @+hh:U32 -> List<&2, U32>

def encode.dccounts source · line 196 · raw

List<&2, U32>

T.81 Annex K, Table K.3: luminance DC code lengths

def encode.dcsyms source · line 200 · raw

List<&2, U32>

the DC symbols of either table: sizes 0 to 11

def encode.accounts source · line 204 · raw

List<&2, U32>

Table K.5: luminance AC code lengths

def encode.acsyms source · line 207 · raw

List<&2, U32>

def encode.cdccounts source · line 217 · raw

List<&2, U32>

Table K.4: chrominance DC code lengths

def encode.caccounts source · line 221 · raw

List<&2, U32>

Table K.6: chrominance AC code lengths

def encode.cacsyms source · line 224 · raw

List<&2, U32>

def encode.dht source · line 234 · 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 244 · 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 256 · 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 268 · 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 277 · raw

@+ww:U32 -> @+hh:U32 -> @+qq:U32 -> @+kd:Layout -> List<&2, U32>

def encode.kern source · line 283 · 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 287 · raw

@kern:Kern -> U32

def encode.ctx source · line 300 · 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 304 · raw

@bw:Bool -> @bh:Bool -> Bool

def encode.bad.h source · line 311 · raw

@zz:Bool -> @bw:Bool -> @bh:Bool -> Bool

def encode.bad.w source · line 318 · raw

@zz:Bool -> @zh:Bool -> @bw:Bool -> @bh:Bool -> Bool

def encode.bad source · line 325 · raw

@+ww:U32 -> @+hh:U32 -> Bool

def encode.put0 source · line 328 · raw

Put

def encode.stuff source · line 332 · 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 335 · raw

@full:Bool -> @out:List<&2, U32> -> @+nb:U32 -> @+nn:U32 -> Put

def encode.bit source · line 342 · raw

@pp:Put -> @+bit:U32 -> Put

def encode.bits.go source · line 347 · raw

@left:Nat -> @pp:Put -> @+code:U32 -> Put

def encode.bits source · line 355 · raw

@pp:Put -> @+len:U32 -> @+code:U32 -> Put

def encode.stuff.put source · line 359 · 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 368 · 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 375 · raw

@zz:Bool -> @out:List<&2, U32> -> @+buf:U32 -> @+nn:U32 -> List<&2, U32>

def encode.pad source · line 384 · 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 389 · raw

@xs:List<&2, U32> -> U32

def encode.ldc source · line 396 · 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 source · line 401 · raw

Array<U32>

def encode.cdc source · line 453 · raw

Array<U32>

def encode.cac source · line 458 · raw

Array<U32>

def encode.dcof source · line 511 · raw

@+cls:Bool -> Array<U32>

a class's DC book: luminance, or chrominance when cls is set

def encode.acof source · line 519 · raw

@+cls:Bool -> Array<U32>

a class's AC book

def encode.bookof source · line 527 · raw

@+cls:Bool -> Book

a class's books

def encode.cat.pick source · line 531 · 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 542 · 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 551 · raw

@+vv:U32 -> U32

def encode.mag.s source · line 554 · raw

@+ss:U32 -> @+cat:U32 -> @+vv:U32 -> U32

def encode.mag source · line 561 · raw

@+cat:U32 -> @+vv:U32 -> U32

def encode.magp.z source · line 564 · raw

@zz:Bool -> @pp:Put -> @+cat:U32 -> @+vv:U32 -> Put

def encode.coded source · line 572 · raw

@got:Pair(Array<U32>, U32) -> Pair(Array<U32>, Code)

the indexed word is the length and the code

def encode.sym source · line 576 · raw

@aa:Array<U32> -> @+sym:U32 -> Pair(Array<U32>, Code)

def encode.dc.use source · line 579 · raw

@got:Pair(Array<U32>, Code) -> @pp:Put -> @+cat:U32 -> @+diff:U32 -> Pair(Array<U32>, Put)

def encode.dc source · line 584 · raw

@aa:Array<U32> -> @+pp:Put -> @+diff:U32 -> Pair(Array<U32>, Put)

def encode.clip.hi source · line 588 · raw

@hi:Bool -> @+vv:U32 -> @+lim:U32 -> U32

def encode.clip.lo source · line 595 · raw

@lo:Bool -> @+vv:U32 -> @+lim:U32 -> U32

def encode.clip.b source · line 603 · 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 610 · raw

@+vv:U32 -> @+lim:U32 -> U32

def encode.dcbias.b source · line 616 · 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 624 · raw

@+vv:U32 -> U32

a DC clipped to -1024 to 1023, plus 1024

def encode.magp.n source · line 628 · 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 637 · 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 643 · raw

@aa:Array<U32> -> @+pp:Put -> @+mm:U32 -> Pair(Array<U32>, Put)

a negative DC difference, -mm

def encode.dcdiff.b source · line 648 · 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 656 · 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 659 · raw

@got:Pair(Array<U32>, Code) -> @pp:Put -> Pair(Array<U32>, Put)

def encode.eob source · line 664 · raw

@need:Bool -> @aa:Array<U32> -> @pp:Put -> Pair(Array<U32>, Put)

def encode.eob.on source · line 671 · raw

@need:Bool -> @st:Pair(Array<U32>, Put) -> Pair(Array<U32>, Put)

def encode.zrls.one source · line 676 · raw

@st:Pair(Array<U32>, Put) -> Pair(Array<U32>, Put)

def encode.zrls source · line 681 · raw

@left:Nat -> @st:Pair(Array<U32>, Put) -> Pair(Array<U32>, Put)

def encode.ac.mag source · line 688 · raw

@got:Pair(Array<U32>, Put) -> @+cat:U32 -> @+clip:U32 -> Pair(Array<U32>, Put)

def encode.ac.hit source · line 693 · raw

@got:Pair(Array<U32>, Put) -> @+sym:U32 -> @+cat:U32 -> @+clip:U32 -> Pair(Array<U32>, Put)

def encode.ac.step source · line 698 · raw

@+cc:U32 -> @+run:U32 -> @st:Pair(Array<U32>, Put) -> Pair(Array<U32>, Put)

def encode.ac.run source · line 707 · raw

@zero:Bool -> @+run:U32 -> U32

the zero run after one more coefficient

def encode.ac.at source · line 716 · 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 725 · 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 732 · raw

@+qq:U32 -> U32

def encode.qdiv.s source · line 739 · raw

@+ss:U32 -> @+vv:U32 -> @+qq:U32 -> U32

def encode.qdiv source · line 746 · raw

@+vv:U32 -> @+qq:U32 -> U32

def encode.block.join source · line 749 · raw

@got:Pair(Array<U32>, Put) -> @dc2:Array<U32> -> @+dd:U32 -> Pair(Book, Pair(U32, Put))

def encode.block.dc source · line 753 · 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 759 · 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 765 · raw

@book:Book -> @pp:Put -> @+pred:U32 -> @zz:List<&2, U32> -> Pair(Book, Pair(U32, Put))

def encode.add64.acc source · line 772 · raw

@+ph:U32 -> @+pl:U32 -> @acc:Pair(U32, U32) -> Pair(U32, U32)

def encode.add64 source · line 779 · 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 785 · raw

@+coef:U32 -> @+samp:U32 -> @acc:Pair(U32, U32) -> Pair(U32, U32)

one more product on the accumulator

def encode.q17 source · line 790 · 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 795 · raw

@+coef:U32 -> @+samp:U32 -> @+fine:Bool -> U32

def encode.two source · line 798 · raw

@+c0:U32 -> @+x0:U32 -> @+c1:U32 -> @+x1:U32 -> @+fine:Bool -> U32

def encode.two.n source · line 801 · raw

@+c0:U32 -> @+x0:U32 -> @+c1:U32 -> @+x1:U32 -> @+fine:Bool -> U32

def encode.four source · line 804 · raw

@+c0:U32 -> @+s0:U32 -> @+c1:U32 -> @+s1:U32 -> @+c2:U32 -> @+s2:U32 -> @+c3:U32 -> @+s3:U32 -> @+fine:Bool -> U32

def encode.even source · line 818 · raw

@+s0:U32 -> @+s1:U32 -> @+s2:U32 -> @+s3:U32 -> @+s4:U32 -> @+s5:U32 -> @+s6:U32 -> @+s7:U32 -> @+k0:U32 -> @+k2:U32 -> @+k6:U32 -> @+fine:Bool -> Oct

even frequencies: symmetric samples share one weight

def encode.odd source · line 842 · raw

@+d0:U32 -> @+d1:U32 -> @+d2:U32 -> @+d3:U32 -> @+o0:U32 -> @+o1:U32 -> @+o2:U32 -> @+o3:U32 -> @+fine:Bool -> Oct

odd frequencies: antisymmetric samples share one weight

def encode.dct8.od source · line 859 · raw

@+f0:U32 -> @+f2:U32 -> @+f4:U32 -> @+f6:U32 -> @od:Oct -> Oct

def encode.dct8.at source · line 865 · raw

@ev:Oct -> @od:Oct -> Oct

def encode.dct8.k source · line 871 · raw

@+s0:U32 -> @+s1:U32 -> @+s2:U32 -> @+s3:U32 -> @+s4:U32 -> @+s5:U32 -> @+s6:U32 -> @+s7:U32 -> @kern:Kern -> @+fine:Bool -> Oct

def encode.dct8 source · line 889 · 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 894 · raw

@+f0:U32 -> @+f1:U32 -> @+f2:U32 -> @+f3:U32 -> @+f4:U32 -> @+f5:U32 -> @+f6:U32 -> @+f7:U32 -> @aa:Array<U32> -> @+at:U32 -> @+step:U32 -> Array<U32>

def encode.lay source · line 917 · raw

@oo:Oct -> @aa:Array<U32> -> @+at:U32 -> Array<U32>

def encode.scatter source · line 922 · raw

@oo:Oct -> @aa:Array<U32> -> @+at:U32 -> Array<U32>

def encode.oct.pack source · line 927 · raw

@+s0:U32 -> @+s1:U32 -> @+s2:U32 -> @+s3:U32 -> @+s4:U32 -> @+s5:U32 -> @+s6:U32 -> @+s7:U32 -> @aa:Array<U32> -> Pair(Array<U32>, Oct)

def encode.oct.g7 source · line 940 · 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 953 · 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 966 · 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 979 · 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 992 · 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 1005 · 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 1018 · 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 1031 · 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 1045 · 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 1055 · raw

@got:Pair(Array<U32>, Oct) -> @kern:Kern -> Pair(Array<U32>, Oct)

def encode.col source · line 1061 · 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 1064 · raw

@aa:Array<U32> -> U32

def encode.book.sink source · line 1071 · raw

@book:Book -> U32

def encode.quant8 source · line 1077 · 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 1086 · raw

@qs:List<&2, Oct> -> U32

a table's columns, when no longer read

def encode.pass2.done source · line 1093 · raw

@st:Planes -> @kern:Kern -> @qs:List<&2, Oct> -> Array<U32>

def encode.pass2.put source · line 1102 · raw

@got:Pair(Array<U32>, Oct) -> @dst:Array<U32> -> @+at:U32 -> @qq:Oct -> Planes

def encode.pass2.step source · line 1107 · raw

@st:Planes -> @kern:Kern -> @qq:Oct -> Planes

def encode.pass2 source · line 1113 · 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 1124 · raw

@st:Planes -> @kern:Kern -> Array<U32>

def encode.pass.rows.lay source · line 1132 · raw

@got:Pair(Array<U32>, Oct) -> @+kern:Kern -> @dst:Array<U32> -> @+at:U32 -> Planes

def encode.pass.rows.next source · line 1137 · raw

@st:Planes -> @+kern:Kern -> Planes

def encode.pass.rows source · line 1143 · raw

@left:Nat -> @st:Planes -> @+kern:Kern -> Array<U32>

eight row transforms. left rows are still unread.

def encode.pass.mid source · line 1150 · raw

@src:Array<U32> -> @+kern:Kern -> Array<U32>

def encode.freq source · line 1154 · 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 1157 · raw

@over:Bool -> @+xx:U32 -> @+lim:U32 -> U32

def encode.sat8 source · line 1164 · raw

@over:Bool -> @+vv:U32 -> U32

def encode.y source · line 1171 · raw

@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32

def encode.cb source · line 1174 · raw

@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32

def encode.cr source · line 1177 · raw

@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32

def encode.ych source · line 1180 · raw

@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32

def encode.cbch source · line 1184 · raw

@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32

def encode.crch source · line 1188 · raw

@+rr:U32 -> @+gg:U32 -> @+bb:U32 -> U32

def encode.pix.load source · line 1193 · 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 1204 · raw

@aa:Bool -> @bb:Bool -> Bool

both samples are the neutral level

def encode.nx source · line 1213 · raw

@more:Bool -> @+mx:U32 -> U32

def encode.ny source · line 1220 · raw

@more:Bool -> @+my:U32 -> U32

def encode.scan.hit source · line 1227 · raw

@got:Pair(Array<U32>, Put) -> @arr:Array<U32> -> Scan

def encode.scan.skip source · line 1231 · raw

@sc:Scan -> @+cc:U32 -> Scan

def encode.scan.keep source · line 1237 · raw

@sc:Scan -> @+cc:U32 -> Scan

def encode.scan.bump source · line 1242 · raw

@zz:Bool -> @sc:Scan -> @+cc:U32 -> Scan

def encode.scan.val source · line 1250 · 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 1255 · raw

@sc:Scan -> @+gg:U32 -> Scan

def encode.scan.end source · line 1260 · raw

@sc:Scan -> Pair(Array<U32>, Put)

def encode.scan.ac source · line 1267 · 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 1274 · raw

@got:Pair(Array<U32>, Put) -> @dc:Array<U32> -> @+dd:U32 -> Pair(Book, Pair(U32, Put))

def encode.scan.join source · line 1278 · 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 1288 · 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 1301 · 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 1311 · raw

@book:Book -> @pp:Put -> @arr:Array<U32> -> @+pred:U32 -> Pair(Book, Pair(U32, Put))

def encode.scan source · line 1317 · 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 1324 · 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 1339 · 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 1350 · 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 1366 · raw

@aa:Array<U32> -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> Pair(Array<U32>, U32)

def encode.tile.store source · line 1369 · 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 1390 · raw

@tt:Tile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> Tile

def encode.tile.row source · line 1395 · raw

@left:Nat -> @tt:Tile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> Tile

def encode.tile.rows source · line 1403 · raw

@left:Nat -> @tt:Tile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> Tile

def encode.tile source · line 1412 · 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 1416 · raw

@got:Pair(Array<U32>, U32) -> @ys:Array<U32> -> @fy:Bool -> @+ii:U32 -> GTile

def encode.gtile.pix source · line 1421 · raw

@tt:GTile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> GTile

def encode.gtile.row source · line 1426 · raw

@left:Nat -> @tt:GTile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> GTile

def encode.gtile.rows source · line 1434 · raw

@left:Nat -> @tt:GTile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> GTile

def encode.gtile source · line 1443 · 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 1446 · raw

@got:Pair(Book, Pair(U32, Put)) -> @aa:Array<U32> -> Pair(Array<U32>, Pair(Book, Pair(U32, Put)))

def encode.gstep.tile source · line 1451 · 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 1464 · raw

@aa:Array<U32> -> @lb:Book -> @bit:Put -> @+py:U32 -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+ctx:Ctx -> Pair(Array<U32>, Pair(Book, Pair(U32, Put)))

def encode.gmcus.done source · line 1479 · raw

@got:Pair(Array<U32>, Pair(Book, Pair(U32, Put))) -> Put

def encode.gmcus source · line 1486 · 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 1507 · 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 1517 · raw

@got:Pair(Book, Pair(U32, Put)) -> @lb:Book -> @aa:Array<U32> -> @rs:Array<U32> -> @fr:Bool -> @+ydc:U32 -> @+pr:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+qc:List<&2, Oct> -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))

def encode.step.cb source · line 1532 · raw

@got:Pair(Book, Pair(U32, Put)) -> @cb:Book -> @aa:Array<U32> -> @bs:Array<U32> -> @rs:Array<U32> -> @fb:Bool -> @fr:Bool -> @+pb:U32 -> @+pr:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+qc:List<&2, Oct> -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))

def encode.step.tile source · line 1551 · raw

@tt:Tile -> @lb:Book -> @cb:Book -> @bit:Put -> @+py:U32 -> @+pb:U32 -> @+pr:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+ql:List<&2, Oct> -> @+qc:List<&2, Oct> -> 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 1570 · raw

@aa:Array<U32> -> @lb:Book -> @cb:Book -> @bit:Put -> @+py:U32 -> @+pb:U32 -> @+pr:U32 -> @+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 1588 · raw

@got:Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put)))))) -> Put

def encode.mcus source · line 1596 · 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 1618 · raw

@got:Pair(Array<U32>, U32) -> @ys:Array<U32> -> @fy:Bool -> @+sb:U32 -> @+sr:U32 -> @+ii:U32 -> Quad

one sample of a 4:2:0 quad: its luminance at ii, its chrominance added to the sums

def encode.quad.pix source · line 1627 · raw

@qd:Quad -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> Quad

def encode.quad.put source · line 1633 · 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 1643 · 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 1652 · raw

@left:Nat -> @tt:Tile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> @+ci:U32 -> @+bias:U32 -> Tile

def encode.quad.rows source · line 1671 · raw

@left:Nat -> @tt:Tile -> @+ww:U32 -> @+hh:U32 -> @+xx:U32 -> @+yy:U32 -> @+ii:U32 -> @+ci:U32 -> Tile

def encode.quad.block source · line 1681 · 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 1685 · 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 1695 · raw

@got:Pair(Book, Pair(U32, Put)) -> @lb:Book -> @pix:Array<U32> -> @rs:Array<U32> -> @fr:Bool -> @+py:U32 -> @+pr:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+qc:List<&2, Oct> -> Pair(Array<U32>, Pair(Book, Pair(Book, Pair(U32, Pair(U32, Pair(U32, Put))))))

def encode.h2.cb source · line 1711 · raw

@pix:Array<U32> -> @bs:Array<U32> -> @rs:Array<U32> -> @fb:Bool -> @fr:Bool -> @lb:Book -> @cb:Book -> @bit:Put -> @+py:U32 -> @+pb:U32 -> @+pr:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+qc:List<&2, Oct> -> 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 1730 · raw

@got:Pair(Book, Pair(U32, Put)) -> @pix:Array<U32> -> @bs:Array<U32> -> @rs:Array<U32> -> @fb:Bool -> @fr:Bool -> @cb:Book -> @+pb:U32 -> @+pr:U32 -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+ql:List<&2, Oct> -> @+qc:List<&2, Oct> -> 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 1755 · raw

@tt:Tile -> @lb:Book -> @cb:Book -> @bit:Put -> @+py:U32 -> @+pb:U32 -> @+pr:U32 -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+ql:List<&2, Oct> -> @+qc:List<&2, Oct> -> 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 1778 · raw

@got:Pair(Book, Pair(U32, Put)) -> @pix:Array<U32> -> @bs:Array<U32> -> @rs:Array<U32> -> @fb:Bool -> @fr:Bool -> @cb:Book -> @+pb:U32 -> @+pr:U32 -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+ql:List<&2, Oct> -> @+qc:List<&2, Oct> -> 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 1803 · raw

@tt:Tile -> @lb:Book -> @cb:Book -> @bit:Put -> @+py:U32 -> @+pb:U32 -> @+pr:U32 -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+ql:List<&2, Oct> -> @+qc:List<&2, Oct> -> 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 1826 · raw

@got:Pair(Book, Pair(U32, Put)) -> @pix:Array<U32> -> @bs:Array<U32> -> @rs:Array<U32> -> @fb:Bool -> @fr:Bool -> @cb:Book -> @+pb:U32 -> @+pr:U32 -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+ql:List<&2, Oct> -> @+qc:List<&2, Oct> -> 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 1850 · raw

@tt:Tile -> @lb:Book -> @cb:Book -> @bit:Put -> @+py:U32 -> @+pb:U32 -> @+pr:U32 -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+ql:List<&2, Oct> -> @+qc:List<&2, Oct> -> 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 1873 · raw

@got:Pair(Book, Pair(U32, Put)) -> @pix:Array<U32> -> @bs:Array<U32> -> @rs:Array<U32> -> @fb:Bool -> @fr:Bool -> @cb:Book -> @+pb:U32 -> @+pr:U32 -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+ql:List<&2, Oct> -> @+qc:List<&2, Oct> -> 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 1897 · raw

@tt:Tile -> @lb:Book -> @cb:Book -> @bit:Put -> @+py:U32 -> @+pb:U32 -> @+pr:U32 -> @+xx:U32 -> @+yy:U32 -> @+ww:U32 -> @+hh:U32 -> @+kern:Kern -> @+zig:List<&2, U32> -> @+ql:List<&2, Oct> -> @+qc:List<&2, Oct> -> 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 1921 · raw

@aa:Array<U32> -> @lb:Book -> @cb:Book -> @bit:Put -> @+py:U32 -> @+pb:U32 -> @+pr:U32 -> @+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 1940 · 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 1962 · 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 1971 · 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 1979 · 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 1988 · 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 1998 · raw

@+pp:U32 -> Bool

one sample is gray: its red, green and blue the same

def encode.gray.all source · line 2003 · raw

@xs:List<&2, U32> -> @ok:Bool -> Bool

every sample is gray, while ok holds

def encode.kind.sub source · line 2017 · raw

@sub:Bool -> Layout

a colour frame: 4:2:0 when sub is set, else 4:4:4

def encode.kind.pick source · line 2026 · 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 2034 · raw

@+sub:Bool -> @+px:List<&2, U32> -> Layout

def encode.finish source · line 2037 · raw

@+ww:U32 -> @+hh:U32 -> @+qq:U32 -> @+kd:Layout -> @ent:List<&2, U32> -> List<&2, U32>

def encode.pick source · line 2040 · raw

@bad:Bool -> @+ww:U32 -> @+hh:U32 -> @+qq:U32 -> @+kd:Layout -> @px:List<&2, U32> -> List<&2, U32>

def encode source · line 2053 · 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