~/bend-docscommunity

src/mp3_enc.bend checks

raw source on the hub · import emerging-ezaudio@0.6.0.0/src/mp3_enc.bend as Mp3_enc

MPEG-1 Layer III encoder: analysis filterbank, MDCT, quantiser, Huffman.

2 imports
import Base
import ./mp3_tab.bend as Tab

Types

type Ya source · line 56 · raw

Type

64 partials. Each windowed sample indexes one bin; a list walks from the head.

type Xs source · line 82 · raw

Type

delay sample handed back beside the ring Array.get just read

type Yr source · line 90 · raw

Type

ring delay beside the 64 partial bins while windowing

type Cf source · line 110 · raw

Type

a cosine table handed back beside the coefficient Array.get just read

type As source · line 153 · raw

Type

subband result: ring delay returned beside the cosine table and 32 bands

type An source · line 172 · raw

Type

analysis delay ring (2^9 slots) and finished subband blocks, newest block first

type Aw source · line 206 · raw

Type

the delay line paired with the cosine table, which has one owner

type Ld source · line 259 · raw

Data

ldexp_q2 residual: mantissa and the exponent still to apply

type Bv source · line 417 · raw

Data

big_values scan across the 22 long scalefactor bands

type Ht source · line 478 · raw

Data

Huffman words of tables 13, 15, 16 and 24 (16-23 and 24-31 share codes), 2^10 leaves

type Hk source · line 626 · raw

Data

Huffman bits of a granule so far, newest first, and whether every pair fit

type Hcnt source · line 668 · raw

Data

a count of one table's bits before linbits: code lengths and signs, and the escapes

type Cand source · line 713 · raw

Data

a candidate table and its bit count

type Sr source · line 789 · raw

Data

binary search for the finest global_gain that fits the bit budget, with its table and values

type Gr source · line 1033 · raw

Data

one coded granule: part2_3_length, big_values, global_gain, table, the quantized values, the bits

type Bf source · line 1120 · raw

Type

a matrix coefficient handed back beside the Array.get just read

type Br source · line 1186 · raw

Type

one MDCT row handed back beside the matrix

type Sa source · line 1238 · raw

Type

576 MDCT bins. Each butterfly reads and writes two of them; a list walks from the head.

type Bw source · line 1397 · raw

Data

bit packer. completed bytes are newest-first until bw.bytes reverses them.

type Chs source · line 1620 · raw

Data

deinterleaved channels, newest sample first until split.go reverses them

Definitions

def f32.bits source · line 5 · raw

@+w:U32 -> F32

def f32.word source · line 10 · raw

@x:F32 -> U32

def u.nth.m source · line 15 · raw

@m:Maybe<&2, U32> -> U32

def u.nth source · line 22 · raw

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

def f.nth.m source · line 25 · raw

@m:Maybe<&2, F32> -> F32

def f.nth source · line 32 · raw

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

def f.put source · line 35 · raw

@xs:List<&2, F32> -> @+ii:U32 -> @+vv:F32 -> List<&2, F32>

def f.of source · line 38 · raw

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

def f.rev source · line 45 · raw

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

def y.wrap source · line 48 · raw

@last:Bool -> @+ii:U32 -> U32

def ya.of source · line 59 · raw

@got:Pair(Array<F32>, F32) -> Ya

def y.store source · line 63 · raw

@got:Ya -> @+ii:U32 -> @+vv:F32 -> Array<F32>

def y.add source · line 68 · raw

@acc:Array<F32> -> @+ii:U32 -> @+vv:F32 -> Array<F32>

def y.pull source · line 71 · raw

@hop:Nat -> @got:Ya -> @+ii:U32 -> @acc:List<&2, F32> -> List<&2, F32>

def y.list source · line 78 · raw

@acc:Array<F32> -> List<&2, F32>

def xs.of source · line 85 · raw

@got:Pair(Array<F32>, F32) -> Xs

def y.step source · line 93 · raw

@got:Xs -> @bins:Array<F32> -> @+w:F32 -> @+ii:U32 -> Yr

def y.ring source · line 99 · raw

@win:List<&2, F32> -> @got:Yr -> @+head:U32 -> @+k:U32 -> @+ii:U32 -> Yr

window the 512-slot ring in place: multiply by win and fold into 64 bins

def cf.of source · line 113 · raw

@got:Pair(Array<F32>, F32) -> Cf

def dot.go source · line 117 · raw

@tl:List<&2, F32> -> @got:Cf -> @+base:U32 -> @+hd:F32 -> @acc:F32 -> Pair(Array<F32>, F32)

def dot.row source · line 126 · raw

@ys:List<&2, F32> -> @tab:Array<F32> -> @+base:U32 -> @acc:F32 -> Pair(Array<F32>, F32)

tab.cos is 2048 F32s. Each tap reads that table with Array.get.

def sb.go source · line 133 · raw

@hop:Nat -> @got:Cf -> @+ys:List<&2, F32> -> @+row:U32 -> @acc:List<&2, F32> -> Pair(Array<F32>, List<&2, F32>)

def sb.rows source · line 143 · raw

@hop:Nat -> @tab:Array<F32> -> @+ys:List<&2, F32> -> @+row:U32 -> @acc:List<&2, F32> -> Pair(Array<F32>, List<&2, F32>)

def as.of source · line 156 · raw

@x:Array<F32> -> @got:Pair(Array<F32>, List<&2, F32>) -> As

def an.sb1 source · line 160 · raw

@got:Yr -> @cos:Array<F32> -> As

def an.sb source · line 166 · raw

@x:Array<F32> -> @+head:U32 -> @+win:List<&2, F32> -> @cos:Array<F32> -> As

subband samples of one ring state. head indexes the oldest of 512 samples.

def an.done source · line 175 · raw

@+head:U32 -> @out:List<&2, List<&2, F32>> -> @got:As -> Pair(An, Array<F32>)

def an.write source · line 181 · raw

@hop:Nat -> @x:Array<F32> -> @+at:U32 -> @blk:List<&2, F32> -> Array<F32>

overwrite the oldest 32 ring slots, then advance head

def an.push source · line 190 · raw

@st:An -> @blk:List<&2, F32> -> @+win:List<&2, F32> -> @cos:Array<F32> -> Pair(An, Array<F32>)

def an.blk source · line 196 · raw

@+s00:F32 -> @+s01:F32 -> @+s02:F32 -> @+s03:F32 -> @+s04:F32 -> @+s05:F32 -> @+s06:F32 -> @+s07:F32 -> @+s08:F32 -> @+s09:F32 -> @+s10:F32 -> @+s11:F32 -> @+s12:F32 -> @+s13:F32 -> @+s14:F32 -> @+s15:F32 -> @+s16:F32 -> @+s17:F32 -> @+s18:F32 -> @+s19:F32 -> @+s20:F32 -> @+s21:F32 -> @+s22:F32 -> @+s23:F32 -> @+s24:F32 -> @+s25:F32 -> @+s26:F32 -> @+s27:F32 -> @+s28:F32 -> @+s29:F32 -> @+s30:F32 -> @+s31:F32 -> List<&2, F32>

def aw.of source · line 209 · raw

@got:Pair(An, Array<F32>) -> Aw

def an.go source · line 213 · raw

@xs:List<&2, F32> -> @got:Aw -> @+win:List<&2, F32> -> Pair(An, Array<F32>)

def an.walk source · line 224 · raw

@xs:List<&2, F32> -> @st:An -> @+win:List<&2, F32> -> @cos:Array<F32> -> Pair(An, Array<F32>)

def an.zero source · line 228 · raw

An

2^9 slots: 512-sample analysis delay, zero-filled, head at the oldest sample.

def f.revs source · line 232 · raw

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

subband frames, newest block first. each block is 32 bands.

def an.out source · line 235 · raw

@st:An -> List<&2, List<&2, F32>>

def cos.put source · line 240 · raw

@xs:List<&2, F32> -> @a:Array<F32> -> @+ii:U32 -> Array<F32>

def cos.of source · line 248 · raw

Array<F32>

2^11 slots: tab.cos is 2048 coefficients, filled in list order.

def an.fin source · line 251 · raw

@got:Pair(An, Array<F32>) -> List<&2, List<&2, F32>>

def an.run source · line 255 · raw

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

def ex.of source · line 262 · raw

@+ee:U32 -> F32

def ld.scale source · line 273 · raw

@+ee:U32 -> F32

def ld.once source · line 276 · raw

@+yy:F32 -> @+ee:U32 -> F32

def ld.minp source · line 279 · raw

@small:Bool -> @+ee:U32 -> U32

def ld.cut source · line 286 · raw

@+yy:F32 -> @+ee:U32 -> @+cut:U32 -> Ld

def ld.step source · line 289 · raw

@st:Ld -> Ld

def ld.go source · line 296 · raw

@hop:Nat -> @st:Ld -> Ld

def ld.y source · line 303 · raw

@st:Ld -> F32

def gain.of source · line 309 · raw

@+gg:U32 -> F32

minimp3 dequant gain for a global_gain. ix = round((|xr| / gain) ^ 0.75).

def q.sign source · line 312 · raw

@neg:Bool -> @+mag:U32 -> U32

def q.pws source · line 319 · raw

@neg:Bool -> @+pp:F32 -> F32

def q.pw source · line 327 · raw

@+xr:F32 -> F32

|xr| ^ 0.75 with the sign of xr, once per granule rather than once per gain tried

def pw.all source · line 330 · raw

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

def q.big source · line 338 · raw

@fit:Bool -> @+vv:F32 -> U32

8206 = 15 + 8191, the largest value table 31 holds

def q.amp source · line 345 · raw

@+vv:F32 -> U32

def q.one source · line 349 · raw

@+pp:F32 -> @+ginv:F32 -> U32

ix = round((|xr| / gain) ^ 0.75), from |xr| ^ 0.75 and gain ^ -0.75

def q.all source · line 352 · raw

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

def gain.inv source · line 359 · raw

@+gg:U32 -> F32

def i.neg source · line 362 · raw

@+vv:U32 -> Bool

def i.ab source · line 365 · raw

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

def i.abs source · line 372 · raw

@+vv:U32 -> U32

def scf.row source · line 375 · raw

@+hz:U32 -> U32

def scf.at source · line 384 · raw

@+hz:U32 -> @+band:U32 -> U32

def nz.n source · line 387 · raw

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

def drop.u source · line 398 · raw

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

def take.u source · line 407 · raw

@hop:Nat -> @xs:List<&2, U32> -> @acc:List<&2, U32> -> List<&2, U32>

def bv.put source · line 420 · raw

@ix:List<&2, U32> -> @+last:U32 -> @+acc:U32 -> @hit:Bool -> Bv

def bv.got source · line 427 · raw

@ix:List<&2, U32> -> @+last:U32 -> @+acc:U32 -> @+width:U32 -> @hit:Bool -> Bv

def bv.band source · line 430 · raw

@+ix:List<&2, U32> -> @+last:U32 -> @+acc:U32 -> @+width:U32 -> Bv

def bv.at source · line 433 · raw

@st:Bv -> @+hz:U32 -> @+band:U32 -> Bv

def bv.go source · line 438 · raw

@hop:Nat -> @st:Bv -> @+hz:U32 -> @+band:U32 -> Bv

def bv.last source · line 445 · raw

@st:Bv -> U32

def bv.of source · line 450 · raw

@ix:List<&2, U32> -> @+hz:U32 -> U32

def ix.p source · line 453 · raw

@zz:Bool -> @+mm:U32 -> @+aa:U32 -> U32

def ix.up source · line 460 · raw

@+mm:U32 -> @+aa:U32 -> U32

def ix.max source · line 463 · raw

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

def b.u source · line 470 · raw

@bb:Bool -> U32

def ht.leaves source · line 482 · raw

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

def ht.pair source · line 489 · raw

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

def ht.up source · line 496 · raw

@hop:Nat -> @xs:List<&2, Ht> -> List<&2, Ht>

def ht.root source · line 503 · raw

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

def ht.cat source · line 510 · raw

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

def ht.of source · line 519 · raw

Ht

built once per clip and shared by every granule

def ht.sel source · line 523 · raw

@bit:Bool -> @lo:Ht -> @hi:Ht -> Ht

def ht.get source · line 531 · raw

@hop:Nat -> @tt:Ht -> @+ix:U32 -> U32

the leaf at ix, its high bit first

def ht.hi source · line 541 · raw

@big:Bool -> U32

the subtree of a table: 13, 15, 16-23, 24-31

def ht.slot source · line 548 · raw

@+tab:U32 -> U32

def ht.word source · line 558 · raw

@+ht:Ht -> @+slot:U32 -> @+ca:U32 -> @+cb:U32 -> U32

a code word: its length in the high half, the code in the low half

def lin.of source · line 561 · raw

@+tab:U32 -> U32

def lim.p source · line 565 · raw

@zz:Bool -> @+lin:U32 -> U32

values that fit a table: 0-15 without linbits, below 15 + 2^linbits with them

def lim.of source · line 572 · raw

@+lin:U32 -> U32

def esc.of source · line 576 · raw

@+lin:U32 -> @+aa:U32 -> Bool

a value of 15 and up is the escape 15 plus linbits

def cap.p source · line 579 · raw

@big:Bool -> @+aa:U32 -> U32

def cap.of source · line 586 · raw

@+lin:U32 -> @+aa:U32 -> U32

def hb.field source · line 590 · raw

@hop:Nat -> @bs:List<&2, U32> -> @+val:U32 -> List<&2, U32>

bits newest first: a field pushed from its high bit

def hb.lin source · line 597 · raw

@zz:Bool -> @bs:List<&2, U32> -> @+lin:U32 -> @+ext:U32 -> List<&2, U32>

def hb.sgn source · line 604 · raw

@zz:Bool -> @bs:List<&2, U32> -> @+vv:U32 -> List<&2, U32>

def hb.pair source · line 612 · raw

@bs:List<&2, U32> -> @+ww:U32 -> @+av:U32 -> @+bv:U32 -> @+aa:U32 -> @+bb:U32 -> @+lin:U32 -> List<&2, U32>

ISO/IEC 11172-3 2.4.2.7: the pair's code word, then x's linbits and sign, then y's

def hk.put source · line 629 · raw

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

def hk.fits source · line 636 · raw

@+ww:U32 -> @+aa:U32 -> @+bb:U32 -> @+lin:U32 -> Bool

def hk.word source · line 639 · raw

@st:Hk -> @+ww:U32 -> @+av:U32 -> @+bv:U32 -> @+aa:U32 -> @+bb:U32 -> @+lin:U32 -> Hk

def hk.abs source · line 644 · raw

@st:Hk -> @+ht:Ht -> @+tab:U32 -> @+lin:U32 -> @+av:U32 -> @+bv:U32 -> @+aa:U32 -> @+bb:U32 -> Hk

def hk.go source · line 647 · raw

@xs:List<&2, U32> -> @+ht:Ht -> @+tab:U32 -> @+lin:U32 -> @st:Hk -> Hk

def hk.fin source · line 656 · raw

@st:Hk -> Maybe<&2, List<&2, U32>>

def hf.code source · line 664 · raw

@+ht:Ht -> @xs:List<&2, U32> -> @+tab:U32 -> Maybe<&2, List<&2, U32>>

the big_values pairs in table tab, in stream order; none when a value or pair does not fit it

def hc.esc source · line 671 · raw

@grp:Bool -> @+aa:U32 -> U32

def hc.cap source · line 678 · raw

@grp:Bool -> @+aa:U32 -> U32

def hc.fit source · line 685 · raw

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

def hc.add source · line 692 · raw

@st:Hcnt -> @+ww:U32 -> @+aa:U32 -> @+bb:U32 -> @+ea:U32 -> @+eb:U32 -> @fit:Bool -> Hcnt

def hc.pair source · line 698 · raw

@st:Hcnt -> @+ht:Ht -> @+slot:U32 -> @+grp:Bool -> @+aa:U32 -> @+bb:U32 -> Hcnt

def hc.go source · line 703 · raw

@xs:List<&2, U32> -> @+ht:Ht -> @+slot:U32 -> @+grp:Bool -> @st:Hcnt -> Hcnt

grp: the table has linbits, so 15 and up count as an escape

def cd.of source · line 716 · raw

@+tab:U32 -> @+lin:U32 -> @st:Hcnt -> Cand

def cd.take source · line 721 · raw

@bok:Bool -> @bb:Bool -> Bool

def cd.keep source · line 728 · raw

@take:Bool -> @aa:Cand -> @bb:Cand -> Cand

def cd.cmp source · line 735 · raw

@+an:U32 -> @aok:Bool -> @bok:Bool -> @+bn:U32 -> Bool

def cd.min source · line 743 · raw

@aa:Cand -> @bb:Cand -> Cand

the first candidate unless the second fits and is strictly shorter

def cd.plain source · line 749 · raw

@small:Bool -> @+ht:Ht -> @+xs:List<&2, U32> -> Cand

tables 15 then 13: no linbits, values up to 15

def grp.keep source · line 757 · raw

@+got:U32 -> @fit:Bool -> @+tab:U32 -> U32

def grp.tab source · line 765 · raw

@hop:Nat -> @+tab:U32 -> @+mx:U32 -> @+got:U32 -> U32

the first table of a group whose linbits hold the largest value, or 0

def cd.at source · line 772 · raw

@none:Bool -> @+tab:U32 -> @+ht:Ht -> @+xs:List<&2, U32> -> @+slot:U32 -> Cand

def cd.grp source · line 780 · raw

@+tab:U32 -> @+ht:Ht -> @+xs:List<&2, U32> -> @+slot:U32 -> Cand

tables sharing one code differ by linbits: the fewest that hold mx cost the least

def cd.best source · line 784 · raw

@+ht:Ht -> @+xs:List<&2, U32> -> @+mx:U32 -> Cand

ISO/IEC 11172-3 tables 13, 15, 16-23, 24-31: the cheapest that codes the pairs

def sr.fit source · line 792 · raw

@good:Bool -> @+lo:U32 -> @+hi:U32 -> @+mid:U32 -> @+tab:U32 -> @ix:List<&2, U32> -> @+ogg:U32 -> @+otab:U32 -> @oix:List<&2, U32> -> @ook:Bool -> Sr

def sr.good source · line 810 · raw

@ok:Bool -> @+nn:U32 -> @+bud:U32 -> @+mx:U32 -> Bool

def sr.cd source · line 813 · raw

@cd:Cand -> @+mx:U32 -> @+bud:U32 -> @ix:List<&2, U32> -> @+lo:U32 -> @+hi:U32 -> @+mid:U32 -> @+ogg:U32 -> @+otab:U32 -> @oix:List<&2, U32> -> @ook:Bool -> Sr

def sr.mx source · line 830 · raw

@+mx:U32 -> @+xs:List<&2, U32> -> @+ht:Ht -> @+bud:U32 -> @ix:List<&2, U32> -> @+lo:U32 -> @+hi:U32 -> @+mid:U32 -> @+ogg:U32 -> @+otab:U32 -> @oix:List<&2, U32> -> @ook:Bool -> Sr

def sr.pairs source · line 846 · raw

@+xs:List<&2, U32> -> @ix:List<&2, U32> -> @+ht:Ht -> @+bud:U32 -> @+lo:U32 -> @+hi:U32 -> @+mid:U32 -> @+ogg:U32 -> @+otab:U32 -> @oix:List<&2, U32> -> @ook:Bool -> Sr

def sr.zero source · line 861 · raw

@zz:Bool -> @+big:U32 -> @+ix:List<&2, U32> -> @+ht:Ht -> @+bud:U32 -> @+lo:U32 -> @+hi:U32 -> @+mid:U32 -> @+ogg:U32 -> @+otab:U32 -> @oix:List<&2, U32> -> @ook:Bool -> Sr

def sr.big source · line 881 · raw

@+big:U32 -> @+ix:List<&2, U32> -> @+ht:Ht -> @+bud:U32 -> @+lo:U32 -> @+hi:U32 -> @+mid:U32 -> @+ogg:U32 -> @+otab:U32 -> @oix:List<&2, U32> -> @ook:Bool -> Sr

def sr.q source · line 896 · raw

@+ix:List<&2, U32> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> @+lo:U32 -> @+hi:U32 -> @+mid:U32 -> @+ogg:U32 -> @+otab:U32 -> @oix:List<&2, U32> -> @ook:Bool -> Sr

def sr.try source · line 911 · raw

@+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> @+lo:U32 -> @+hi:U32 -> @+mid:U32 -> @+gg:U32 -> @+tab:U32 -> @ix:List<&2, U32> -> @ok:Bool -> Sr

def sr.live source · line 926 · raw

@go:Bool -> @+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> @+lo:U32 -> @+hi:U32 -> @+gg:U32 -> @+tab:U32 -> @ix:List<&2, U32> -> @ok:Bool -> Sr

def sr.step source · line 945 · raw

@+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> @st:Sr -> Sr

def sr.go source · line 951 · raw

@hop:Nat -> @+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> @st:Sr -> Sr

8 halvings settle a global_gain in 0..255; spec holds |xr| ^ 0.75

def sr.run source · line 958 · raw

@+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> Sr

def pk.p source · line 961 · raw

@zz:Bool -> @+mm:F32 -> @+aa:F32 -> F32

def pk.up source · line 968 · raw

@+mm:F32 -> @+aa:F32 -> F32

def pk.go source · line 971 · raw

@xs:List<&2, F32> -> @+mm:F32 -> F32

def dz.one source · line 978 · raw

@zz:Bool -> @+vv:F32 -> F32

def dz.apply source · line 985 · raw

@xs:List<&2, F32> -> @+thr:F32 -> List<&2, F32>

def dz.on source · line 992 · raw

@done:Bool -> @st:Sr -> @+spec:List<&2, F32> -> @+pk:F32 -> @+thr:U32 -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> Sr

def dz.try source · line 1008 · raw

@st:Sr -> @+spec:List<&2, F32> -> @+pk:F32 -> @+thr:U32 -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> Sr

def dz.go source · line 1014 · raw

@thrs:List<&2, U32> -> @+spec:List<&2, F32> -> @+pk:F32 -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> @st:Sr -> Sr

a dead zone below thr * peak, wider until a gain fits

def dz.thrs source · line 1029 · raw

List<&2, U32>

def gr.part source · line 1036 · raw

@gg:Gr -> U32

def gr.big source · line 1041 · raw

@gg:Gr -> U32

def gr.tab source · line 1046 · raw

@gg:Gr -> U32

def gr.ix source · line 1051 · raw

@gg:Gr -> List<&2, U32>

def gr.bits source · line 1056 · raw

@gg:Gr -> List<&2, U32>

def gr.zero source · line 1062 · raw

Gr

a granule of zeros: no bits, no big_values

def gr.fit source · line 1065 · raw

@ok:Bool -> @+bits:List<&2, U32> -> @+big:U32 -> @ix:List<&2, U32> -> @+gg:U32 -> @+tab:U32 -> Gr

def gr.code source · line 1072 · raw

@got:Maybe<&2, List<&2, U32>> -> @+big:U32 -> @ix:List<&2, U32> -> @+gg:U32 -> @+tab:U32 -> @+bud:U32 -> Gr

def gr.big.of source · line 1086 · raw

@+big:U32 -> @+ht:Ht -> @+ix:List<&2, U32> -> @+gg:U32 -> @+tab:U32 -> @+bud:U32 -> Gr

def gr.make source · line 1090 · raw

@+ht:Ht -> @+ix:List<&2, U32> -> @+gg:U32 -> @+tab:U32 -> @+hz:U32 -> @+bud:U32 -> Gr

big_values and the bits both come from ix: part2_3_length is the length of those bits

def gr.ok source · line 1093 · raw

@ok:Bool -> @+ht:Ht -> @ix:List<&2, U32> -> @+gg:U32 -> @+tab:U32 -> @+hz:U32 -> @+bud:U32 -> Gr

def gr.pack source · line 1100 · raw

@+ht:Ht -> @st:Sr -> @+hz:U32 -> @+bud:U32 -> Gr

def gr.tiny source · line 1105 · raw

@zz:Bool -> @+pk:F32 -> @+ht:Ht -> @+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> Gr

def gr.pk source · line 1112 · raw

@+pk:F32 -> @+ht:Ht -> @+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> Gr

def gr.of source · line 1116 · raw

@+ht:Ht -> @+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> Gr

one granule of 576 MDCT lines at most bud bits

def bf.of source · line 1123 · raw

@got:Pair(Array<F32>, F32) -> Bf

def bt.go source · line 1127 · raw

@tl:List<&2, F32> -> @got:Bf -> @+base:U32 -> @+hd:F32 -> @acc:F32 -> Pair(Array<F32>, F32)

def bt.dot source · line 1136 · raw

@vec:List<&2, F32> -> @tab:Array<F32> -> @+base:U32 -> @acc:F32 -> Pair(Array<F32>, F32)

tab.bt is 648 F32s. Each tap reads that table with Array.get.

def col.b source · line 1143 · raw

@hop:Nat -> @xs:List<&2, List<&2, F32>> -> @+band:U32 -> @acc:List<&2, F32> -> List<&2, F32>

def band.step source · line 1154 · raw

@hop:Nat -> @+vec:List<&2, F32> -> @got:Bf -> @+kk:U32 -> @acc:List<&2, F32> -> Pair(Array<F32>, List<&2, F32>)

def band.k source · line 1164 · raw

@hop:Nat -> @+vec:List<&2, F32> -> @tab:Array<F32> -> @+kk:U32 -> @acc:List<&2, F32> -> Pair(Array<F32>, List<&2, F32>)

def band.row source · line 1173 · raw

@+aa:List<&2, List<&2, F32>> -> @+cc:List<&2, List<&2, F32>> -> @tab:Array<F32> -> @+band:U32 -> Pair(Array<F32>, List<&2, F32>)

def flat.bands source · line 1178 · raw

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

def br.of source · line 1189 · raw

@got:Pair(Array<F32>, List<&2, F32>) -> Br

def spec.step source · line 1193 · raw

@hop:Nat -> @+aa:List<&2, List<&2, F32>> -> @+cc:List<&2, List<&2, F32>> -> @got:Br -> @+band:U32 -> @acc:List<&2, List<&2, F32>> -> Pair(Array<F32>, List<&2, F32>)

def spec.bands source · line 1204 · raw

@hop:Nat -> @+aa:List<&2, List<&2, F32>> -> @+cc:List<&2, List<&2, F32>> -> @tab:Array<F32> -> @+band:U32 -> @acc:List<&2, List<&2, F32>> -> Pair(Array<F32>, List<&2, F32>)

def drop.b source · line 1214 · raw

@hop:Nat -> @xs:List<&2, List<&2, F32>> -> List<&2, List<&2, F32>>

def take.b source · line 1223 · raw

@hop:Nat -> @xs:List<&2, List<&2, F32>> -> @acc:List<&2, List<&2, F32>> -> List<&2, List<&2, F32>>

def spec.one source · line 1234 · raw

@+blocks:List<&2, List<&2, F32>> -> @tab:Array<F32> -> Pair(Array<F32>, List<&2, F32>)

def sa.of source · line 1241 · raw

@got:Pair(Array<F32>, F32) -> Sa

def al.fill source · line 1245 · raw

@xs:List<&2, F32> -> @a:Array<F32> -> @+ii:U32 -> Array<F32>

def al.arr source · line 1253 · raw

@xs:List<&2, F32> -> Array<F32>

2^10 slots: one granule is 576 coefficients, filled in list order.

def al.pull source · line 1256 · raw

@hop:Nat -> @got:Sa -> @+ii:U32 -> @acc:List<&2, F32> -> List<&2, F32>

def al.list source · line 1263 · raw

@acc:Array<F32> -> List<&2, F32>

def al.write source · line 1266 · raw

@acc:Array<F32> -> @+up:F32 -> @+dp:F32 -> @+c0:F32 -> @+c1:F32 -> @+hi:U32 -> @+lo:U32 -> Array<F32>

def al.use source · line 1272 · raw

@got:Sa -> @+dp:F32 -> @+c0:F32 -> @+c1:F32 -> @+hi:U32 -> @+lo:U32 -> Array<F32>

def al.both source · line 1277 · raw

@got:Sa -> @+c0:F32 -> @+c1:F32 -> @+hi:U32 -> @+lo:U32 -> Array<F32>

def al.one source · line 1282 · raw

@acc:Array<F32> -> @+aa:List<&2, F32> -> @+bb:U32 -> @+ii:U32 -> Array<F32>

def al.i source · line 1287 · raw

@hop:Nat -> @acc:Array<F32> -> @+aa:List<&2, F32> -> @+bb:U32 -> @+ii:U32 -> Array<F32>

def al.band source · line 1294 · raw

@acc:Array<F32> -> @+aa:List<&2, F32> -> @+bb:U32 -> Array<F32>

def al.go source · line 1297 · raw

@hop:Nat -> @acc:Array<F32> -> @+aa:List<&2, F32> -> @+bb:U32 -> Array<F32>

def al.fin source · line 1304 · raw

@acc:Array<F32> -> List<&2, F32>

def al.run source · line 1307 · raw

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

def spec.read source · line 1310 · raw

@got:Br -> Pair(Array<F32>, List<&2, F32>)

def spec.gran source · line 1315 · raw

@+blocks:List<&2, List<&2, F32>> -> @tab:Array<F32> -> Pair(Array<F32>, List<&2, F32>)

def grans.step source · line 1318 · raw

@hop:Nat -> @+blocks:List<&2, List<&2, F32>> -> @got:Br -> @acc:List<&2, List<&2, F32>> -> Pair(Array<F32>, List<&2, List<&2, F32>>)

def grans.go source · line 1327 · raw

@hop:Nat -> @+blocks:List<&2, List<&2, F32>> -> @tab:Array<F32> -> @acc:List<&2, List<&2, F32>> -> Pair(Array<F32>, List<&2, List<&2, F32>>)

def grans.np source · line 1336 · raw

@z:Bool -> @+nb:U32 -> U32

def grans.n source · line 1343 · raw

@+nb:U32 -> U32

def bt.put source · line 1346 · raw

@xs:List<&2, F32> -> @a:Array<F32> -> @+ii:U32 -> Array<F32>

def bt.of source · line 1354 · raw

Array<F32>

2^10 slots: tab.bt is 648 coefficients, filled in list order.

def gran.fin source · line 1357 · raw

@got:Pair(Array<F32>, List<&2, List<&2, F32>>) -> List<&2, List<&2, F32>>

def gran.all source · line 1361 · raw

@+blocks:List<&2, List<&2, F32>> -> List<&2, List<&2, F32>>

def flip.samp source · line 1365 · raw

@z:Bool -> @+vv:F32 -> F32

def flip.go source · line 1372 · raw

@xs:List<&2, F32> -> @+ii:U32 -> @acc:List<&2, F32> -> @+odd:Bool -> List<&2, F32>

def flip.one source · line 1379 · raw

@blk:List<&2, F32> -> @odd:Bool -> List<&2, F32>

def flip.all source · line 1382 · raw

@xs:List<&2, List<&2, F32>> -> @+ii:U32 -> @acc:List<&2, List<&2, F32>> -> List<&2, List<&2, F32>>

def ch.prime source · line 1390 · raw

List<&2, List<&2, F32>>

ISO/IEC 11172-3 Annex C: the first granule's MDCT window starts on a granule of zeros

def ch.specs source · line 1393 · raw

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

def bw.empty source · line 1400 · raw

Bw

def bw.put source · line 1403 · raw

@full:Bool -> @+acc:U32 -> @+n:U32 -> @out:List<&2, U32> -> Bw

def bw.bit source · line 1410 · raw

@st:Bw -> @+bit:U32 -> Bw

def bw.field source · line 1415 · raw

@hop:Nat -> @st:Bw -> @+val:U32 -> Bw

def bw.tail source · line 1422 · raw

@empty:Bool -> @+acc:U32 -> @+n:U32 -> @out:List<&2, U32> -> List<&2, U32>

def bw.bytes source · line 1429 · raw

@st:Bw -> List<&2, U32>

def side.priv source · line 1434 · raw

@+ch:U32 -> U32

def side.head source · line 1441 · raw

@st:Bw -> @+ch:U32 -> Bw

def side.mid source · line 1444 · raw

@st:Bw -> @+part:U32 -> @+big:U32 -> @+gain:U32 -> Bw

def side.tabs source · line 1448 · raw

@none:Bool -> @st:Bw -> @+tab:U32 -> Bw

three table_select fields, region0_count 15 and region1_count 5; all zero without big_values

def side.end source · line 1455 · raw

@st:Bw -> Bw

def side.gr source · line 1458 · raw

@st:Bw -> @g:Gr -> Bw

def side.grs source · line 1463 · raw

@gs:List<&2, Gr> -> @st:Bw -> Bw

def side.bytes source · line 1470 · raw

@gs:List<&2, Gr> -> @+ch:U32 -> List<&2, U32>

def body.bits source · line 1473 · raw

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

def body.one source · line 1480 · raw

@g:Gr -> @st:Bw -> Bw

def body.grs source · line 1485 · raw

@gs:List<&2, Gr> -> @st:Bw -> Bw

def gr.take source · line 1492 · raw

@hop:Nat -> @gs:List<&2, Gr> -> @acc:List<&2, Gr> -> List<&2, Gr>

def gr.drop source · line 1501 · raw

@hop:Nat -> @gs:List<&2, Gr> -> List<&2, Gr>

def fr.data source · line 1511 · raw

@+gs:List<&2, Gr> -> @+ch:U32 -> List<&2, U32>

one frame after its header: side information, then the granules' main data

def pk.chan source · line 1514 · raw

@specs:List<&2, List<&2, F32>> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> @acc:List<&2, Gr> -> List<&2, Gr>

def pk.zip source · line 1527 · raw

@ls:List<&2, Gr> -> @rs:List<&2, Gr> -> @acc:List<&2, Gr> -> List<&2, Gr>

def f.fix source · line 1535 · raw

@hop:Nat -> @xs:List<&2, F32> -> List<&2, F32>

exactly hop samples: the list, then zeros

def enc.chgr source · line 1547 · raw

@xs:List<&2, F32> -> @+hz:U32 -> @+nf:U32 -> @+bud:U32 -> @+ht:Ht -> List<&2, Gr>

a channel of nf frames: nf * 1152 samples, zero-padded, two granules a frame

def s16.f source · line 1550 · raw

@neg:Bool -> @+ww:U32 -> F32

def samp.sign source · line 1557 · raw

@neg:Bool -> U32

def samp.big source · line 1565 · raw

@nan:Bool -> @neg:Bool -> U32

NaN is 0; infinities and magnitudes past 1 are -1 or 1

def samp.pick source · line 1572 · raw

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

def samp.sat source · line 1580 · raw

@+ww:U32 -> U32

a binary32 word kept when finite with magnitude at most 1, its magnitude bits at most 1.0's

def samp.of source · line 1583 · raw

@+kind:U32 -> @+ww:U32 -> F32

def samp.zero source · line 1591 · raw

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

a zero sample: s16 0, or a binary32 word whose sanitized magnitude is 0

def q.both source · line 1598 · raw

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

def pcm.quiet source · line 1605 · raw

@xs:List<&2, U32> -> @+kind:U32 -> @acc:Bool -> Bool

def pcm.go source · line 1612 · raw

@+kind:U32 -> @xs:List<&2, U32> -> @acc:List<&2, F32> -> List<&2, F32>

def split.rev source · line 1623 · raw

@c:Chs -> Chs

def split.on source · line 1628 · raw

@leftb:Bool -> @+v:F32 -> @l:List<&2, F32> -> @r:List<&2, F32> -> Chs

def split.put source · line 1635 · raw

@c:Chs -> @+v:F32 -> @+phase:U32 -> Chs

def split.flip source · line 1640 · raw

@z:Bool -> U32

def split.ph source · line 1647 · raw

@mono:Bool -> @+phase:U32 -> U32

def split.next source · line 1654 · raw

@+ch:U32 -> @+phase:U32 -> U32

def split.go source · line 1657 · raw

@xs:List<&2, F32> -> @+ch:U32 -> @c:Chs -> @+phase:U32 -> Chs

def enc.chs source · line 1664 · raw

@mono:Bool -> @+hz:U32 -> @left:List<&2, F32> -> @right:List<&2, F32> -> @+nf:U32 -> @+bud:U32 -> @+ht:Ht -> List<&2, Gr>

def enc.from source · line 1679 · raw

@cc:Chs -> @+hz:U32 -> @+ch:U32 -> @+nf:U32 -> @+bud:U32 -> List<&2, Gr>

def enc.live source · line 1684 · raw

@+hz:U32 -> @+ch:U32 -> @+kind:U32 -> @frames:List<&2, U32> -> @+nf:U32 -> @+bud:U32 -> List<&2, Gr>

def enc.quiet source · line 1695 · raw

@quiet:Bool -> @+hz:U32 -> @+ch:U32 -> @+kind:U32 -> @frames:List<&2, U32> -> @+nf:U32 -> @+bud:U32 -> List<&2, Gr>

silence skips the filterbank: zero samples make zero lines, and zero lines a zero granule

def enc.grans source · line 1711 · raw

@+hz:U32 -> @+ch:U32 -> @+kind:U32 -> @+frames:List<&2, U32> -> @+nf:U32 -> @+bud:U32 -> List<&2, Gr>

nf frames of granules in stream order: per frame granule 0 then 1, each channel 0 then 1