src/mp3_enc.bend checks
raw source on the hub · import emerging-ezaudio@0.7.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.
Ya@acc:Array<F32> -> @cur:F32 -> Ya
type Xs source · line 82 · raw
Type
delay sample handed back beside the ring Array.get just read
Xs@x:Array<F32> -> @samp:F32 -> Xs
type Yr source · line 90 · raw
Type
ring delay beside the 64 partial bins while windowing
Yr@x:Array<F32> -> @bins:Array<F32> -> Yr
type Cf source · line 114 · raw
Type
a cosine table handed back beside the coefficient Array.get just read
Cf@tab:Array<F32> -> @co:F32 -> Cf
type As source · line 165 · raw
Type
subband result: ring delay returned beside the cosine table and 32 bands
As@x:Array<F32> -> @cos:Array<F32> -> @sb:List<&2, F32> -> As
type An source · line 187 · raw
Type
analysis delay ring (2^9 slots) and finished subband blocks, newest block first
An@x:Array<F32> -> @head:U32 -> @out:List<&2, List<&2, F32>> -> An
type Aw source · line 212 · raw
Type
the delay line paired with the cosine table, which has one owner
Aw@st:An -> @cos:Array<F32> -> Aw
type Ld source · line 264 · raw
Data
ldexp_q2 residual: mantissa and the exponent still to apply
Ld@yy:F32 -> @ee:U32 -> Ld
type Bv source · line 422 · raw
Data
big_values scan across the 22 long scalefactor bands
Bv@ix:List<&2, U32> -> @last:U32 -> @acc:U32 -> Bv
type Ht source · line 483 · raw
Data
Huffman words of tables 13, 15, 16 and 24 (16-23 and 24-31 share codes), 2^10 leaves
Hleaf@w:U32 -> Ht
Hnode@lo:Ht -> @hi:Ht -> Ht
type Hk source · line 631 · raw
Data
Huffman bits of a granule so far, newest first, and whether every pair fit
Hk@bits:List<&2, U32> -> @ok:Bool -> Hk
type Hcnt source · line 673 · raw
Data
a count of one table's bits before linbits: code lengths and signs, and the escapes
Hcnt@nn:U32 -> @esc:U32 -> @ok:Bool -> Hcnt
type Cand source · line 718 · raw
Data
a candidate table and its bit count
Cand@tab:U32 -> @nn:U32 -> @ok:Bool -> Cand
type Sr source · line 794 · raw
Data
binary search for the finest global_gain that fits the bit budget, with its table and values
Sr@lo:U32 -> @hi:U32 -> @gg:U32 -> @tab:U32 -> @ix:List<&2, U32> -> @ok:Bool -> Sr
type Sw source · line 798 · raw
Data
the search window: the gains still open and the one tried this step
Sw@lo:U32 -> @hi:U32 -> @mid:U32 -> Sw
type Bs source · line 802 · raw
Data
the finest gain that fit so far, with its table and values
Bs@gg:U32 -> @tab:U32 -> @ix:List<&2, U32> -> @ok:Bool -> Bs
type Gr source · line 958 · raw
Data
one coded granule: part2_3_length, big_values, global_gain, table, the quantized values, the bits
Gr@part:U32 -> @big:U32 -> @gain:U32 -> @tab:U32 -> @ix:List<&2, U32> -> @bits:List<&2, U32> -> Gr
type Bf source · line 1045 · raw
Type
a matrix coefficient handed back beside the Array.get just read
Bf@tab:Array<F32> -> @co:F32 -> Bf
type Br source · line 1125 · raw
Type
one MDCT row handed back beside the matrix
Br@tab:Array<F32> -> @row:List<&2, F32> -> Br
type Sa source · line 1187 · raw
Type
576 MDCT bins. Each butterfly reads and writes two of them; a list walks from the head.
Sa@acc:Array<F32> -> @cur:F32 -> Sa
type Bw source · line 1358 · raw
Data
bit packer. completed bytes are newest-first until bw.bytes reverses them.
Bw@acc:U32 -> @n:U32 -> @out:List<&2, U32> -> Bw
type Chs source · line 1581 · raw
Data
deinterleaved channels, newest sample first until split.go reverses them
Chs@l:List<&2, F32> -> @r:List<&2, F32> -> Chs
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 117 · raw
@got:Pair(Array<F32>, F32) -> Cf
def dot.go source · line 121 · raw
@tl:List<&2, F32> -> @got:Cf -> @+base:U32 -> @+hd:F32 -> @acc:F32 -> Pair(Array<F32>, F32)
def dot.row source · line 130 · 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 137 · 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 151 · 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 168 · raw
@x:Array<F32> -> @got:Pair(Array<F32>, List<&2, F32>) -> As
def an.sb1 source · line 172 · raw
@got:Yr -> @cos:Array<F32> -> As
def an.sb source · line 178 · 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 190 · raw
@+head:U32 -> @out:List<&2, List<&2, F32>> -> @got:As -> Pair(An, Array<F32>)
def an.write source · line 196 · 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 205 · raw
@st:An -> @blk:List<&2, F32> -> @+win:List<&2, F32> -> @cos:Array<F32> -> Pair(An, Array<F32>)
def aw.of source · line 215 · raw
@got:Pair(An, Array<F32>) -> Aw
def an.go source · line 219 · raw
@xs:List<&2, F32> -> @got:Aw -> @+win:List<&2, F32> -> Pair(An, Array<F32>)
def an.walk source · line 229 · raw
@xs:List<&2, F32> -> @st:An -> @+win:List<&2, F32> -> @cos:Array<F32> -> Pair(An, Array<F32>)
def an.zero source · line 233 · raw
An
2^9 slots: 512-sample analysis delay, zero-filled, head at the oldest sample.
def f.revs source · line 237 · 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 240 · raw
@st:An -> List<&2, List<&2, F32>>
def cos.put source · line 245 · raw
@xs:List<&2, F32> -> @a:Array<F32> -> @+ii:U32 -> Array<F32>
def cos.of source · line 253 · raw
Array<F32>
2^11 slots: tab.cos is 2048 coefficients, filled in list order.
def an.fin source · line 256 · raw
@got:Pair(An, Array<F32>) -> List<&2, List<&2, F32>>
def an.run source · line 260 · raw
@xs:List<&2, F32> -> List<&2, List<&2, F32>>
def ex.of source · line 267 · raw
@+ee:U32 -> F32
def ld.scale source · line 278 · raw
@+ee:U32 -> F32
def ld.once source · line 281 · raw
@+yy:F32 -> @+ee:U32 -> F32
def ld.minp source · line 284 · raw
@small:Bool -> @+ee:U32 -> U32
def ld.cut source · line 291 · raw
@+yy:F32 -> @+ee:U32 -> @+cut:U32 -> Ld
def ld.step source · line 294 · raw
@st:Ld -> Ld
def ld.go source · line 301 · raw
@hop:Nat -> @st:Ld -> Ld
def ld.y source · line 308 · raw
@st:Ld -> F32
def gain.of source · line 314 · raw
@+gg:U32 -> F32
minimp3 dequant gain for a global_gain. ix = round((|xr| / gain) ^ 0.75).
def q.sign source · line 317 · raw
@neg:Bool -> @+mag:U32 -> U32
def q.pws source · line 324 · raw
@neg:Bool -> @+pp:F32 -> F32
def q.pw source · line 332 · 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 335 · raw
@xs:List<&2, F32> -> List<&2, F32>
def q.big source · line 343 · raw
@fit:Bool -> @+vv:F32 -> U32
8206 = 15 + 8191, the largest value table 31 holds
def q.amp source · line 350 · raw
@+vv:F32 -> U32
def q.one source · line 354 · 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 357 · raw
@xs:List<&2, F32> -> @+ginv:F32 -> List<&2, U32>
def gain.inv source · line 364 · raw
@+gg:U32 -> F32
def i.neg source · line 367 · raw
@+vv:U32 -> Bool
def i.ab source · line 370 · raw
@neg:Bool -> @+vv:U32 -> U32
def i.abs source · line 377 · raw
@+vv:U32 -> U32
def scf.row source · line 380 · raw
@+hz:U32 -> U32
def scf.at source · line 389 · raw
@+hz:U32 -> @+band:U32 -> U32
def nz.n source · line 392 · raw
@hop:Nat -> @xs:List<&2, U32> -> Bool
def drop.u source · line 403 · raw
@hop:Nat -> @xs:List<&2, U32> -> List<&2, U32>
def take.u source · line 412 · raw
@hop:Nat -> @xs:List<&2, U32> -> @acc:List<&2, U32> -> List<&2, U32>
def bv.put source · line 425 · raw
@ix:List<&2, U32> -> @+last:U32 -> @+acc:U32 -> @hit:Bool -> Bv
def bv.got source · line 432 · raw
@ix:List<&2, U32> -> @+last:U32 -> @+acc:U32 -> @+width:U32 -> @hit:Bool -> Bv
def bv.band source · line 435 · raw
@+ix:List<&2, U32> -> @+last:U32 -> @+acc:U32 -> @+width:U32 -> Bv
def bv.at source · line 438 · raw
@st:Bv -> @+hz:U32 -> @+band:U32 -> Bv
def bv.go source · line 443 · raw
@hop:Nat -> @st:Bv -> @+hz:U32 -> @+band:U32 -> Bv
def bv.last source · line 450 · raw
@st:Bv -> U32
def bv.of source · line 455 · raw
@ix:List<&2, U32> -> @+hz:U32 -> U32
def ix.p source · line 458 · raw
@zz:Bool -> @+mm:U32 -> @+aa:U32 -> U32
def ix.up source · line 465 · raw
@+mm:U32 -> @+aa:U32 -> U32
def ix.max source · line 468 · raw
@xs:List<&2, U32> -> @+mm:U32 -> U32
def b.u source · line 475 · raw
@bb:Bool -> U32
def ht.leaves source · line 487 · raw
@xs:List<&2, U32> -> List<&2, Ht>
def ht.pair source · line 494 · raw
@xs:List<&2, Ht> -> List<&2, Ht>
def ht.up source · line 501 · raw
@hop:Nat -> @xs:List<&2, Ht> -> List<&2, Ht>
def ht.root source · line 508 · raw
@xs:List<&2, Ht> -> Ht
def ht.cat source · line 515 · 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 524 · raw
Ht
built once per clip and shared by every granule
def ht.sel source · line 528 · raw
@bit:Bool -> @lo:Ht -> @hi:Ht -> Ht
def ht.get source · line 536 · raw
@hop:Nat -> @tt:Ht -> @+ix:U32 -> U32
the leaf at ix, its high bit first
def ht.hi source · line 546 · raw
@big:Bool -> U32
the subtree of a table: 13, 15, 16-23, 24-31
def ht.slot source · line 553 · raw
@+tab:U32 -> U32
def ht.word source · line 563 · 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 566 · raw
@+tab:U32 -> U32
def lim.p source · line 570 · 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 577 · raw
@+lin:U32 -> U32
def esc.of source · line 581 · raw
@+lin:U32 -> @+aa:U32 -> Bool
a value of 15 and up is the escape 15 plus linbits
def cap.p source · line 584 · raw
@big:Bool -> @+aa:U32 -> U32
def cap.of source · line 591 · raw
@+lin:U32 -> @+aa:U32 -> U32
def hb.field source · line 595 · 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 602 · raw
@zz:Bool -> @bs:List<&2, U32> -> @+lin:U32 -> @+ext:U32 -> List<&2, U32>
def hb.sgn source · line 609 · raw
@zz:Bool -> @bs:List<&2, U32> -> @+vv:U32 -> List<&2, U32>
def hb.pair source · line 617 · 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 634 · raw
@ok:Bool -> @bits:List<&2, U32> -> Hk
def hk.fits source · line 641 · raw
@+ww:U32 -> @+aa:U32 -> @+bb:U32 -> @+lin:U32 -> Bool
def hk.word source · line 644 · raw
@st:Hk -> @+ww:U32 -> @+av:U32 -> @+bv:U32 -> @+aa:U32 -> @+bb:U32 -> @+lin:U32 -> Hk
def hk.abs source · line 649 · raw
@st:Hk -> @+ht:Ht -> @+tab:U32 -> @+lin:U32 -> @+av:U32 -> @+bv:U32 -> @+aa:U32 -> @+bb:U32 -> Hk
def hk.go source · line 652 · raw
@xs:List<&2, U32> -> @+ht:Ht -> @+tab:U32 -> @+lin:U32 -> @st:Hk -> Hk
def hk.fin source · line 661 · raw
@st:Hk -> Maybe<&2, List<&2, U32>>
def hf.code source · line 669 · 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 676 · raw
@grp:Bool -> @+aa:U32 -> U32
def hc.cap source · line 683 · raw
@grp:Bool -> @+aa:U32 -> U32
def hc.fit source · line 690 · raw
@grp:Bool -> @+aa:U32 -> @+bb:U32 -> Bool
def hc.add source · line 697 · raw
@st:Hcnt -> @+ww:U32 -> @+aa:U32 -> @+bb:U32 -> @+ea:U32 -> @+eb:U32 -> @fit:Bool -> Hcnt
def hc.pair source · line 703 · raw
@st:Hcnt -> @+ht:Ht -> @+slot:U32 -> @+grp:Bool -> @+aa:U32 -> @+bb:U32 -> Hcnt
def hc.go source · line 708 · 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 721 · raw
@+tab:U32 -> @+lin:U32 -> @st:Hcnt -> Cand
def cd.take source · line 726 · raw
@bok:Bool -> @bb:Bool -> Bool
def cd.keep source · line 733 · raw
@take:Bool -> @aa:Cand -> @bb:Cand -> Cand
def cd.cmp source · line 740 · raw
@+an:U32 -> @aok:Bool -> @bok:Bool -> @+bn:U32 -> Bool
def cd.min source · line 748 · raw
@aa:Cand -> @bb:Cand -> Cand
the first candidate unless the second fits and is strictly shorter
def cd.plain source · line 754 · 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 762 · raw
@+got:U32 -> @fit:Bool -> @+tab:U32 -> U32
def grp.tab source · line 770 · 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 777 · raw
@none:Bool -> @+tab:U32 -> @+ht:Ht -> @+xs:List<&2, U32> -> @+slot:U32 -> Cand
def cd.grp source · line 785 · 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 789 · 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.keep source · line 806 · raw
@+lo:U32 -> @+hi:U32 -> @old:Bs -> Sr
the best so far stays, under the new window
def sr.fit.at source · line 813 · raw
@good:Bool -> @+lo:U32 -> @+hi:U32 -> @+mid:U32 -> @+tab:U32 -> @ix:List<&2, U32> -> @old:Bs -> Sr
a gain that fits narrows the search to finer gains and becomes the best; one that does not narrows it to coarser gains and keeps the best so far
def sr.fit source · line 820 · raw
@good:Bool -> @w:Sw -> @+tab:U32 -> @ix:List<&2, U32> -> @old:Bs -> Sr
def sr.good source · line 825 · raw
@ok:Bool -> @+nn:U32 -> @+bud:U32 -> @+mx:U32 -> Bool
def sr.cd source · line 828 · raw
@cd:Cand -> @+mx:U32 -> @+bud:U32 -> @ix:List<&2, U32> -> @w:Sw -> @old:Bs -> Sr
def sr.mx source · line 833 · raw
@+mx:U32 -> @+xs:List<&2, U32> -> @+ht:Ht -> @+bud:U32 -> @ix:List<&2, U32> -> @w:Sw -> @old:Bs -> Sr
def sr.pairs source · line 836 · raw
@+xs:List<&2, U32> -> @ix:List<&2, U32> -> @+ht:Ht -> @+bud:U32 -> @w:Sw -> @old:Bs -> Sr
def sr.zero source · line 839 · raw
@zz:Bool -> @+big:U32 -> @+ix:List<&2, U32> -> @+ht:Ht -> @+bud:U32 -> @w:Sw -> @old:Bs -> Sr
def sr.big source · line 846 · raw
@+big:U32 -> @+ix:List<&2, U32> -> @+ht:Ht -> @+bud:U32 -> @w:Sw -> @old:Bs -> Sr
def sr.q source · line 849 · raw
@+ix:List<&2, U32> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> @w:Sw -> @old:Bs -> Sr
def sr.try source · line 852 · raw
@+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> @w:Sw -> @old:Bs -> Sr
def sr.stop source · line 858 · raw
@w:Sw -> @old:Bs -> Sr
the search is closed: the window and the best so far, as they are
def sr.live source · line 863 · raw
@go:Bool -> @+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> @w:Sw -> @old:Bs -> Sr
def sr.step source · line 870 · raw
@+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> @st:Sr -> Sr
def sr.go source · line 876 · 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 883 · raw
@+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> Sr
def pk.p source · line 886 · raw
@zz:Bool -> @+mm:F32 -> @+aa:F32 -> F32
def pk.up source · line 893 · raw
@+mm:F32 -> @+aa:F32 -> F32
def pk.go source · line 896 · raw
@xs:List<&2, F32> -> @+mm:F32 -> F32
def dz.one source · line 903 · raw
@zz:Bool -> @+vv:F32 -> F32
def dz.apply source · line 910 · raw
@xs:List<&2, F32> -> @+thr:F32 -> List<&2, F32>
def dz.on source · line 917 · 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 933 · raw
@st:Sr -> @+spec:List<&2, F32> -> @+pk:F32 -> @+thr:U32 -> @+hz:U32 -> @+bud:U32 -> @+ht:Ht -> Sr
def dz.go source · line 939 · 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 954 · raw
List<&2, U32>
def gr.part source · line 961 · raw
@gg:Gr -> U32
def gr.big source · line 966 · raw
@gg:Gr -> U32
def gr.tab source · line 971 · raw
@gg:Gr -> U32
def gr.ix source · line 976 · raw
@gg:Gr -> List<&2, U32>
def gr.bits source · line 981 · raw
@gg:Gr -> List<&2, U32>
def gr.zero source · line 987 · raw
Gr
a granule of zeros: no bits, no big_values
def gr.fit source · line 990 · raw
@ok:Bool -> @+bits:List<&2, U32> -> @+big:U32 -> @ix:List<&2, U32> -> @+gg:U32 -> @+tab:U32 -> Gr
def gr.code source · line 997 · 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 1011 · raw
@+big:U32 -> @+ht:Ht -> @+ix:List<&2, U32> -> @+gg:U32 -> @+tab:U32 -> @+bud:U32 -> Gr
def gr.make source · line 1015 · 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 1018 · raw
@ok:Bool -> @+ht:Ht -> @ix:List<&2, U32> -> @+gg:U32 -> @+tab:U32 -> @+hz:U32 -> @+bud:U32 -> Gr
def gr.pack source · line 1025 · raw
@+ht:Ht -> @st:Sr -> @+hz:U32 -> @+bud:U32 -> Gr
def gr.tiny source · line 1030 · raw
@zz:Bool -> @+pk:F32 -> @+ht:Ht -> @+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> Gr
def gr.pk source · line 1037 · raw
@+pk:F32 -> @+ht:Ht -> @+spec:List<&2, F32> -> @+hz:U32 -> @+bud:U32 -> Gr
def gr.of source · line 1041 · 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 1048 · raw
@got:Pair(Array<F32>, F32) -> Bf
def bt.go source · line 1052 · raw
@tl:List<&2, F32> -> @got:Bf -> @+base:U32 -> @+hd:F32 -> @acc:F32 -> Pair(Array<F32>, F32)
def bt.dot source · line 1061 · 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 1068 · raw
@hop:Nat -> @xs:List<&2, List<&2, F32>> -> @+band:U32 -> @acc:List<&2, F32> -> List<&2, F32>
def band.step source · line 1082 · 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 1096 · 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 1109 · 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 1117 · raw
@xs:List<&2, List<&2, F32>> -> List<&2, F32>
def br.of source · line 1128 · raw
@got:Pair(Array<F32>, List<&2, F32>) -> Br
def spec.step source · line 1132 · 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 1147 · 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 1161 · raw
@hop:Nat -> @xs:List<&2, List<&2, F32>> -> List<&2, List<&2, F32>>
def take.b source · line 1170 · 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 1183 · raw
@+blocks:List<&2, List<&2, F32>> -> @tab:Array<F32> -> Pair(Array<F32>, List<&2, F32>)
def sa.of source · line 1190 · raw
@got:Pair(Array<F32>, F32) -> Sa
def al.fill source · line 1194 · raw
@xs:List<&2, F32> -> @a:Array<F32> -> @+ii:U32 -> Array<F32>
def al.arr source · line 1202 · raw
@xs:List<&2, F32> -> Array<F32>
2^10 slots: one granule is 576 coefficients, filled in list order.
def al.pull source · line 1205 · raw
@hop:Nat -> @got:Sa -> @+ii:U32 -> @acc:List<&2, F32> -> List<&2, F32>
def al.list source · line 1212 · raw
@acc:Array<F32> -> List<&2, F32>
def al.write source · line 1215 · raw
@acc:Array<F32> -> @+up:F32 -> @+dp:F32 -> @+c0:F32 -> @+c1:F32 -> @+hi:U32 -> @+lo:U32 -> Array<F32>
def al.use source · line 1227 · raw
@got:Sa -> @+dp:F32 -> @+c0:F32 -> @+c1:F32 -> @+hi:U32 -> @+lo:U32 -> Array<F32>
def al.both source · line 1232 · raw
@got:Sa -> @+c0:F32 -> @+c1:F32 -> @+hi:U32 -> @+lo:U32 -> Array<F32>
def al.one source · line 1237 · raw
@acc:Array<F32> -> @+aa:List<&2, F32> -> @+bb:U32 -> @+ii:U32 -> Array<F32>
def al.i source · line 1242 · raw
@hop:Nat -> @acc:Array<F32> -> @+aa:List<&2, F32> -> @+bb:U32 -> @+ii:U32 -> Array<F32>
def al.band source · line 1249 · raw
@acc:Array<F32> -> @+aa:List<&2, F32> -> @+bb:U32 -> Array<F32>
def al.go source · line 1252 · raw
@hop:Nat -> @acc:Array<F32> -> @+aa:List<&2, F32> -> @+bb:U32 -> Array<F32>
def al.fin source · line 1259 · raw
@acc:Array<F32> -> List<&2, F32>
def al.run source · line 1262 · raw
@xs:List<&2, F32> -> List<&2, F32>
def spec.read source · line 1265 · raw
@got:Br -> Pair(Array<F32>, List<&2, F32>)
def spec.gran source · line 1270 · raw
@+blocks:List<&2, List<&2, F32>> -> @tab:Array<F32> -> Pair(Array<F32>, List<&2, F32>)
def grans.step source · line 1273 · 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 1285 · 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 1297 · raw
@z:Bool -> @+nb:U32 -> U32
def grans.n source · line 1304 · raw
@+nb:U32 -> U32
def bt.put source · line 1307 · raw
@xs:List<&2, F32> -> @a:Array<F32> -> @+ii:U32 -> Array<F32>
def bt.of source · line 1315 · raw
Array<F32>
2^10 slots: tab.bt is 648 coefficients, filled in list order.
def gran.fin source · line 1318 · raw
@got:Pair(Array<F32>, List<&2, List<&2, F32>>) -> List<&2, List<&2, F32>>
def gran.all source · line 1322 · raw
@+blocks:List<&2, List<&2, F32>> -> List<&2, List<&2, F32>>
def flip.samp source · line 1326 · raw
@z:Bool -> @+vv:F32 -> F32
def flip.go source · line 1333 · raw
@xs:List<&2, F32> -> @+ii:U32 -> @acc:List<&2, F32> -> @+odd:Bool -> List<&2, F32>
def flip.one source · line 1340 · raw
@blk:List<&2, F32> -> @odd:Bool -> List<&2, F32>
def flip.all source · line 1343 · 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 1351 · 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 1354 · raw
@xs:List<&2, F32> -> List<&2, List<&2, F32>>
def bw.empty source · line 1361 · raw
Bw
def bw.put source · line 1364 · raw
@full:Bool -> @+acc:U32 -> @+n:U32 -> @out:List<&2, U32> -> Bw
def bw.bit source · line 1371 · raw
@st:Bw -> @+bit:U32 -> Bw
def bw.field source · line 1376 · raw
@hop:Nat -> @st:Bw -> @+val:U32 -> Bw
def bw.tail source · line 1383 · raw
@empty:Bool -> @+acc:U32 -> @+n:U32 -> @out:List<&2, U32> -> List<&2, U32>
def bw.bytes source · line 1390 · raw
@st:Bw -> List<&2, U32>
def side.priv source · line 1395 · raw
@+ch:U32 -> U32
def side.head source · line 1402 · raw
@st:Bw -> @+ch:U32 -> Bw
def side.mid source · line 1405 · raw
@st:Bw -> @+part:U32 -> @+big:U32 -> @+gain:U32 -> Bw
def side.tabs source · line 1409 · 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 1416 · raw
@st:Bw -> Bw
def side.gr source · line 1419 · raw
@st:Bw -> @g:Gr -> Bw
def side.grs source · line 1424 · raw
@gs:List<&2, Gr> -> @st:Bw -> Bw
def side.bytes source · line 1431 · raw
@gs:List<&2, Gr> -> @+ch:U32 -> List<&2, U32>
def body.bits source · line 1434 · raw
@xs:List<&2, U32> -> @st:Bw -> Bw
def body.one source · line 1441 · raw
@g:Gr -> @st:Bw -> Bw
def body.grs source · line 1446 · raw
@gs:List<&2, Gr> -> @st:Bw -> Bw
def gr.take source · line 1453 · raw
@hop:Nat -> @gs:List<&2, Gr> -> @acc:List<&2, Gr> -> List<&2, Gr>
def gr.drop source · line 1462 · raw
@hop:Nat -> @gs:List<&2, Gr> -> List<&2, Gr>
def fr.data source · line 1472 · 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 1475 · 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 1488 · raw
@ls:List<&2, Gr> -> @rs:List<&2, Gr> -> @acc:List<&2, Gr> -> List<&2, Gr>
def f.fix source · line 1496 · raw
@hop:Nat -> @xs:List<&2, F32> -> List<&2, F32>
exactly hop samples: the list, then zeros
def enc.chgr source · line 1508 · 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 1511 · raw
@neg:Bool -> @+ww:U32 -> F32
def samp.sign source · line 1518 · raw
@neg:Bool -> U32
def samp.big source · line 1526 · raw
@nan:Bool -> @neg:Bool -> U32
NaN is 0; infinities and magnitudes past 1 are -1 or 1
def samp.pick source · line 1533 · raw
@ok:Bool -> @+ww:U32 -> U32
def samp.sat source · line 1541 · 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 1544 · raw
@+kind:U32 -> @+ww:U32 -> F32
def samp.zero source · line 1552 · 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 1559 · raw
@aa:Bool -> @bb:Bool -> Bool
def pcm.quiet source · line 1566 · raw
@xs:List<&2, U32> -> @+kind:U32 -> @acc:Bool -> Bool
def pcm.go source · line 1573 · raw
@+kind:U32 -> @xs:List<&2, U32> -> @acc:List<&2, F32> -> List<&2, F32>
def split.rev source · line 1584 · raw
@c:Chs -> Chs
def split.on source · line 1589 · raw
@leftb:Bool -> @+v:F32 -> @l:List<&2, F32> -> @r:List<&2, F32> -> Chs
def split.put source · line 1596 · raw
@c:Chs -> @+v:F32 -> @+phase:U32 -> Chs
def split.flip source · line 1601 · raw
@z:Bool -> U32
def split.ph source · line 1608 · raw
@mono:Bool -> @+phase:U32 -> U32
def split.next source · line 1615 · raw
@+ch:U32 -> @+phase:U32 -> U32
def split.go source · line 1618 · raw
@xs:List<&2, F32> -> @+ch:U32 -> @c:Chs -> @+phase:U32 -> Chs
def enc.chs source · line 1625 · 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 1640 · raw
@cc:Chs -> @+hz:U32 -> @+ch:U32 -> @+nf:U32 -> @+bud:U32 -> List<&2, Gr>
def enc.live source · line 1645 · raw
@+hz:U32 -> @+ch:U32 -> @+kind:U32 -> @frames:List<&2, U32> -> @+nf:U32 -> @+bud:U32 -> List<&2, Gr>
def enc.quiet source · line 1656 · 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 1672 · 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