1 use nihav_core::formats::*;
2 use nihav_core::frame::*;
3 use nihav_core::codecs::*;
4 use nihav_core::io::bitreader::*;
5 use nihav_codec_support::dsp::fft::*;
9 const BLOCK_LEN: usize = 256;
10 const NBLOCKS: usize = 6;
11 const MAX_CHANNELS: usize = 5;
12 const MAX_CPLBANDS: usize = 18;
13 const MAX_BANDS: usize = 50;
15 const MAGIC_BYTE0: u8 = 0x0B;
16 const MAGIC_BYTE1: u8 = 0x77;
18 const STRATEGY_REUSE: u8 = 0;
20 const LFE_CHANNEL: usize = MAX_CHANNELS;
21 const CPL_CHANNEL: usize = MAX_CHANNELS + 1;
24 xsincos: [FFTComplex; BLOCK_LEN/2],
29 struct IMDCTWorkspace {
30 z: [FFTComplex; BLOCK_LEN / 2],
31 y: [FFTComplex; BLOCK_LEN / 2],
32 out: [f32; BLOCK_LEN * 2],
36 fn new(bits: usize) -> Self {
38 let size4 = 1 << (bits - 2);
39 let mut xsincos: [FFTComplex; 512/4] = [FFTC_ZERO; 512/4];
41 let factor = 2.0 * consts::PI * ((8 * k + 1) as f32) / ((8 * size) as f32);
42 xsincos[k].re = -factor.cos();
43 xsincos[k].im = -factor.sin();
45 let fft = FFTBuilder::new_fft(size/4, false);
46 IMDCTContext { xsincos, size, fft }
48 #[allow(non_snake_case)]
49 fn do_imdct(&mut self, coeffs: &[i32; BLOCK_LEN], tmp: &mut IMDCTWorkspace) {
50 do_imdct_core(&mut self.fft, &self.xsincos, self.size, false, coeffs, &mut tmp.z, &mut tmp.y);
51 let w = &TS102366_WINDOW;
52 let N2 = self.size / 2;
53 let N4 = self.size / 4;
54 let N8 = self.size / 8;
56 tmp.out[ 2 * n] = -tmp.y[N8 + n] .im * w[ 2 * n];
57 tmp.out[ 2 * n + 1] = tmp.y[N8 - n - 1].re * w[ 2 * n + 1];
58 tmp.out[ N4 + 2 * n] = -tmp.y[ n] .re * w[N4 + 2 * n];
59 tmp.out[ N4 + 2 * n + 1] = tmp.y[N4 - n - 1].im * w[N4 + 2 * n + 1];
60 tmp.out[ N2 + 2 * n] = -tmp.y[N8 + n] .re * w[N2 - 2 * n - 1];
61 tmp.out[ N2 + 2 * n + 1] = tmp.y[N8 - n - 1].im * w[N2 - 2 * n - 2];
62 tmp.out[3 * N4 + 2 * n] = tmp.y[ n] .im * w[N4 - 2 * n - 1];
63 tmp.out[3 * N4 + 2 * n + 1] = -tmp.y[N4 - n - 1].re * w[N4 - 2 * n - 2];
66 #[allow(non_snake_case)]
67 fn do_imdct_ileave(&mut self, coeffs: &[i32; BLOCK_LEN], tmp: &mut IMDCTWorkspace) {
68 let mut ziter = tmp.z.chunks_mut(self.size / 4);
69 let z1 = ziter.next().unwrap();
70 let z2 = ziter.next().unwrap();
71 let mut yiter = tmp.y.chunks_mut(self.size / 4);
72 let y1 = yiter.next().unwrap();
73 let y2 = yiter.next().unwrap();
74 do_imdct_core(&mut self.fft, &self.xsincos, self.size, true, coeffs, z1, y1);
75 do_imdct_core(&mut self.fft, &self.xsincos, self.size, true, &coeffs[1..], z2, y2);
76 let w = &TS102366_WINDOW;
77 let N2 = self.size / 2;
78 let N4 = self.size / 4;
79 let N8 = self.size / 8;
81 tmp.out[ 2 * n] = -y1[ n] .im * w[ 2 * n];
82 tmp.out[ 2 * n + 1] = y1[N8 - n - 1].re * w[ 2 * n + 1];
83 tmp.out[ N4 + 2 * n] = -y1[ n] .re * w[N4 + 2 * n];
84 tmp.out[ N4 + 2 * n + 1] = y1[N8 - n - 1].im * w[N4 + 2 * n + 1];
85 tmp.out[ N2 + 2 * n] = -y2[ n] .re * w[N2 - 2 * n - 1];
86 tmp.out[ N2 + 2 * n + 1] = y2[N8 - n - 1].im * w[N2 - 2 * n - 2];
87 tmp.out[3 * N4 + 2 * n] = y2[ n] .im * w[N4 - 2 * n - 1];
88 tmp.out[3 * N4 + 2 * n + 1] = -y2[N8 - n - 1].re * w[N4 - 2 * n - 2];
93 #[allow(non_snake_case)]
94 fn do_imdct_core(fft: &mut FFT, xsc: &[FFTComplex; BLOCK_LEN/2], size: usize, ilace: bool, coeffs: &[i32], z: &mut [FFTComplex], y: &mut [FFTComplex]) {
98 let scale = 1.0 / ((1 << 24) as f32);
100 let (c0, c1) = if !ilace {
101 ((coeffs[N2 - 2 * k - 1] as f32) * scale,
102 (coeffs[ 2 * k] as f32) * scale)
104 ((coeffs[N - 4 * k - 2] as f32) * scale,
105 (coeffs[ 4 * k] as f32) * scale)
107 let c = FFTComplex { re: c0, im: c1 };
110 fft.do_ifft_inplace(z);
112 y[k] = z[k] * xsc[k];
116 struct AudioDecoder {
117 info: NACodecInfoRef,
119 imdct512: IMDCTContext,
120 imdct256: IMDCTContext,
122 delay: [[f32; BLOCK_LEN]; MAX_CHANNELS + 1],
128 info: NACodecInfo::new_dummy(),
129 ablk: AudioBlock::new(),
130 imdct512: IMDCTContext::new(9),
131 imdct256: IMDCTContext::new(8),
132 tmp: IMDCTWorkspace {
133 z: [FFTC_ZERO; BLOCK_LEN / 2],
134 y: [FFTC_ZERO; BLOCK_LEN / 2],
135 out: [0.0; BLOCK_LEN * 2],
137 delay: [[0.0; BLOCK_LEN]; MAX_CHANNELS + 1],
142 const SAMPLE_RATES: [u32; 4] = [ 48000, 44100, 32000, 0 ];
144 const FRAME_SIZES: [[usize; 64]; 4] = [
146 64, 64, 80, 80, 96, 96, 112, 112,
147 128, 128, 160, 160, 192, 192, 224, 224,
148 256, 256, 320, 320, 384, 384, 448, 448,
149 512, 512, 640, 640, 768, 768, 896, 896,
150 1024, 1024, 1152, 1152, 1280, 1280,
151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
154 69, 70, 87, 88, 104, 105, 121, 122,
155 139, 140, 174, 175, 208, 209, 243, 244,
156 278, 279, 348, 349, 417, 418, 487, 488,
157 557, 558, 696, 697, 835, 836, 975, 976,
158 1114, 1115, 1253, 1254, 1393, 1394,
159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
162 96, 96, 120, 120, 144, 144, 168, 168,
163 192, 192, 240, 240, 288, 288, 336, 336,
164 384, 384, 480, 480, 576, 576, 672, 672,
165 768, 768, 960, 960, 1152, 1152, 1344, 1344,
166 1536, 1536, 1728, 1728, 1920, 1920,
167 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
168 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
172 #[derive(Debug,Clone,Copy)]
182 fn read(br: &mut BitReader) -> DecoderResult<Self> {
183 let syncword = br.read(16)?;
184 validate!(syncword == (u32::from(MAGIC_BYTE0) * 256) + u32::from(MAGIC_BYTE1));
185 let crc1 = br.read(16)? as u16;
186 let fscod = br.read(2)? as usize;
187 let frmsizecod = br.read(6)? as usize;
188 Ok(Syncinfo { crc1, fscod: fscod as u8, frmsizecod: frmsizecod as u8,
189 samplerate: SAMPLE_RATES[fscod], frame_size: FRAME_SIZES[fscod][frmsizecod] * 2 })
191 fn is_valid(&self) -> bool {
192 (self.samplerate != 0) && (self.frame_size != 0)
197 fn read_optional8(&mut self) -> BitReaderResult<Option<u8>>;
198 fn read_optional16(&mut self, bits: u8) -> BitReaderResult<Option<u16>>;
201 impl<'a> ReadOptional for BitReader<'a> {
202 fn read_optional8(&mut self) -> BitReaderResult<Option<u8>> {
203 if self.read_bool()? {
204 Ok(Some(self.read(8)? as u8))
209 fn read_optional16(&mut self, bits: u8) -> BitReaderResult<Option<u16>> {
210 if self.read_bool()? {
211 Ok(Some(self.read(bits)? as u16))
218 #[derive(Debug,Clone,Copy,PartialEq)]
231 fn get_num_channels(self) -> usize {
233 ACMode::DualMono => 2,
236 ACMode::Mode3_0 => 3,
237 ACMode::Mode2_1 => 3,
238 ACMode::Mode3_1 => 4,
239 ACMode::Mode2_2 => 4,
240 ACMode::Mode3_2 => 5,
243 fn get_channel_map_str(self) -> &'static str {
245 ACMode::DualMono => "C,C",
247 ACMode::Stereo => "L,R",
248 ACMode::Mode3_0 => "L,C,R",
249 ACMode::Mode2_1 => "L,R,Cs",
250 ACMode::Mode3_1 => "L,C,R,Cs",
251 ACMode::Mode2_2 => "L,R,Ls,Rs",
252 ACMode::Mode3_2 => "L,C,R,Ls,Rs",
255 fn get_channel_map(self, has_lfe: bool) -> NAChannelMap {
256 let mut chmap = NAChannelMap::from_str(self.get_channel_map_str()).unwrap();
258 chmap.add_channel(NAChannelType::LFE);
262 fn is_3_x(self) -> bool {
266 ACMode::Mode3_2 => true,
270 fn is_surround(self) -> bool {
275 ACMode::Mode3_2 => true,
281 const AC_MODES: [ACMode; 8] = [
282 ACMode::DualMono, ACMode::Mono, ACMode::Stereo,
283 ACMode::Mode3_0, ACMode::Mode2_1,
284 ACMode::Mode3_1, ACMode::Mode2_2,
288 #[derive(Debug,Clone,Copy)]
293 mixlevel: Option<u8>,
298 fn read(br: &mut BitReader) -> DecoderResult<Self> {
299 let dialnorm = br.read(5)? as u8;
300 let compr = br.read_optional8()?;
301 let langcod = br.read_optional8()?;
302 let (mixlevel, roomtyp) = if br.read_bool()? {
303 let mlev = br.read(5)? as u8;
304 let rt = br.read(2)? as u8;
306 (Some(mlev), Some(rt))
310 Ok(Mixinfo { dialnorm, compr, langcod, mixlevel, roomtyp })
314 #[derive(Debug,Clone,Copy)]
321 surmixlev: Option<u8>,
325 mixinfo2: Option<Mixinfo>,
328 timecod1: Option<u16>,
329 timecod2: Option<u16>,
334 fn read(br: &mut BitReader) -> DecoderResult<BSI> {
335 let bsid = br.read(5)? as u8;
336 validate!(bsid <= 10);
337 let shift = if bsid < 9 { 0 } else { bsid - 9 + 1 };
338 let bsmod = br.read(3)? as u8;
339 let acmod_id = br.read(3)? as usize;
340 validate!(acmod_id < AC_MODES.len());
341 let acmod = AC_MODES[acmod_id];
342 let cmixlev = if acmod.is_3_x() {
343 let cl = br.read(2)? as u8;
347 let surmixlev = if acmod.is_surround() {
348 let sml = br.read(2)? as u8;
352 let dsurmod = if acmod == ACMode::Stereo {
353 let dsm = br.read(2)? as u8;
357 let lfeon = br.read_bool()?;
358 let mixinfo = Mixinfo::read(br)?;
359 let mixinfo2 = if acmod == ACMode::DualMono {
360 Some(Mixinfo::read(br)?)
364 let copysmth = br.read_bool()?;
365 let origbs = br.read_bool()?;
366 let timecod1 = br.read_optional16(14)?;
367 let timecod2 = br.read_optional16(14)?;
368 let has_addb = br.read_bool()?;
370 bsid, shift, bsmod, acmod, lfeon,
371 cmixlev, surmixlev, dsurmod,
373 copysmth, origbs, timecod1, timecod2, has_addb,
378 #[derive(Clone, Copy)]
385 cplcoexp: [u8; MAX_CPLBANDS],
386 cplcomant: [u8; MAX_CPLBANDS],
415 const GROUPS: [usize; 4] = [ 0, 3, 6, 12 ];
416 const GROUP_BIAS: [usize; 4] = [ 0, 0, 3, 9 ];
418 fn decode_exps(br: &mut BitReader, dst: &mut [u8], mut prev: u8, grplen: usize) -> DecoderResult<()> {
419 let repeat = grplen / 3;
421 for out in dst.chunks_mut(grplen) {
422 let val = br.read(7)? as u8;
423 validate!(val < 125);
424 let diff: [u8; 3] = [ val / 25, (val / 5) % 5, val % 5 ];
425 for (i, exps) in out.chunks_mut(repeat).enumerate() {
426 exps[0] = (prev + diff[i]).wrapping_sub(2);
427 validate!(exps[0] <= 24);
438 macro_rules! read_bap {
439 ($br: expr, $tab:ident, $nbits:expr) => ({
440 let val = $br.read($nbits)? as usize;
441 validate!(val < $tab.len());
444 ($br:expr, $tab:ident, $nbits:expr, $bufidx:expr, $bap_buf:expr, $bap_buf_fill:expr) => (
445 if $bap_buf_fill[$bufidx] > 0 {
446 $bap_buf_fill[$bufidx] -= 1;
447 $bap_buf[$bufidx][$bap_buf_fill[$bufidx]]
449 let val = $br.read($nbits)? as usize;
450 validate!(val < $tab.len());
451 for i in 1..$tab[0].len() {
452 $bap_buf[$bufidx][i - 1] = $tab[val][i];
454 $bap_buf_fill[$bufidx] = $tab[0].len() - 1;
468 cplcoexp: [0; MAX_CPLBANDS],
469 cplcomant: [0; MAX_CPLBANDS],
498 fn read_strategy(&mut self, br: &mut BitReader, blk_no: usize) -> DecoderResult<()> {
499 self.expstr = br.read(2)? as u8;
500 validate!(blk_no != 0 || self.expstr != STRATEGY_REUSE);
501 if self.expstr != STRATEGY_REUSE {
502 if self.startmant > 0 {
503 self.groups = (self.endmant - self.startmant) / GROUPS[self.expstr as usize];
504 } else if self.endmant != 0{
505 let idx = self.expstr as usize;
506 self.groups = (self.endmant + GROUP_BIAS[idx] - 1) / GROUPS[idx];
513 fn read_exps(&mut self, br: &mut BitReader, is_cpl: bool, is_lfe: bool) -> DecoderResult<()> {
514 if self.expstr == STRATEGY_REUSE { return Ok(()); }
515 let grpsize = GROUPS[self.expstr as usize];
516 self.exps = [0; 256];
518 let first = (br.read(4)? as u8) << 1;
519 let out = &mut self.exps[self.startmant..self.endmant];
520 decode_exps(br, out, first, grpsize)?;
522 self.exps[0] = br.read(4)? as u8;
523 let first = self.exps[0];
524 let out = &mut self.exps[1..self.endmant];
525 decode_exps(br, out, first, grpsize)?;
526 self.gainrng = br.read(2)? as u8;
528 self.exps[0] = br.read(4)? as u8;
529 let first = self.exps[0];
530 let out = &mut self.exps[1..7];
531 decode_exps(br, out, first, grpsize)?;
535 fn read_snr(&mut self, br: &mut BitReader) -> DecoderResult<()> {
536 self.fsnroffst = br.read(4)? as u8;
537 self.fgaincod = br.read(3)? as usize;
540 fn read_deltbai(&mut self, br: &mut BitReader) -> DecoderResult<()> {
541 if self.deltbae == 1 {
542 self.deltnseg = (br.read(3)? as usize) + 1;
543 for seg in 0..self.deltnseg {
544 self.deltoffst[seg] = br.read(5)? as u8;
545 self.deltlen[seg] = br.read(4)? as usize;
546 self.deltba[seg] = br.read(3)? as u8;
552 fn compute_bndpsd(&mut self) {
553 let start = self.startmant;
554 let end = self.endmant;
555 let exps = &mut self.exps;
556 let psd = &mut self.psd;
557 let bndpsd = &mut self.bndpsd;
559 for bin in start..end {
560 psd[bin] = 3072 - (i16::from(exps[bin]) << 7);
564 let mut band = TS102366_BIN_TO_BAND[bin] as usize;
567 lastbin = ((TS102366_BAND_START[band] as usize) + (TS102366_BAND_SIZE[band] as usize)).min(end);
568 bndpsd[band] = i32::from(psd[bin]);
570 while bin < lastbin {
571 bndpsd[band] = logadd(bndpsd[band], i32::from(psd[bin]));
575 if lastbin >= end { break; }
578 fn compute_mask(&mut self, mask: &mut [i32; MAX_BANDS], fscod: usize, sgain: u16, fdecay: u8, sdecay: u8,
579 dbknee: u16, cplfleak: u16, cplsleak: u16, shift: u8) {
580 let fgain = i32::from(TS102366_FAST_GAIN[self.fgaincod]);
582 let bndstart = TS102366_BIN_TO_BAND[self.startmant] as usize;
583 let bndend = (TS102366_BIN_TO_BAND[self.endmant - 1] as usize) + 1;
585 let mut excite: [i32; MAX_BANDS] = [0; MAX_BANDS];
591 let lowcomp0 = calc_lowcomp(0, self.bndpsd[0], self.bndpsd[1], 0);
592 excite[0] = self.bndpsd[0] - fgain - lowcomp0;
593 let lowcomp1 = calc_lowcomp(lowcomp0, self.bndpsd[1], self.bndpsd[2], 1);
594 excite[1] = self.bndpsd[1] - fgain - lowcomp1;
596 let mut lowcomp = lowcomp1;
600 let not_lfe_case = (bndend != 7) || (band != 6);
602 lowcomp = calc_lowcomp(lowcomp, self.bndpsd[band], self.bndpsd[band + 1], band);
604 fast_leak = self.bndpsd[band] - fgain;
605 slow_leak = self.bndpsd[band] - i32::from(sgain);
606 excite[band] = fast_leak - lowcomp;
607 if not_lfe_case && (self.bndpsd[band] <= self.bndpsd[band + 1]) {
612 for band in sband..bndend.min(22) {
613 if (bndend != 7) || (band != 6) {
614 lowcomp = calc_lowcomp(lowcomp, self.bndpsd[band], self.bndpsd[band + 1], band);
616 fast_leak = (fast_leak - i32::from(fdecay)).max(self.bndpsd[band] - fgain);
617 slow_leak = (slow_leak - i32::from(sdecay)).max(self.bndpsd[band] - i32::from(sgain));
618 excite[band] = slow_leak.max(fast_leak - lowcomp);
623 fast_leak = i32::from(cplfleak);
624 slow_leak = i32::from(cplsleak);
626 for band in begin..bndend {
627 fast_leak = (fast_leak - i32::from(fdecay)).max(self.bndpsd[band] - fgain);
628 slow_leak = (slow_leak - i32::from(sdecay)).max(self.bndpsd[band] - i32::from(sgain));
629 excite[band] = fast_leak.max(slow_leak);
631 for band in bndstart..bndend {
632 if self.bndpsd[band] < i32::from(dbknee) {
633 excite[band] += (i32::from(dbknee) - self.bndpsd[band]) >> 2;
635 mask[band] = excite[band].max(i32::from(TS102366_HTH[fscod][band >> shift]));
638 fn apply_delta_info(&mut self, mask: &mut [i32; MAX_BANDS]) {
639 if self.deltbae == 0 || self.deltbae == 1 {
640 let mut band = TS102366_BIN_TO_BAND[self.startmant] as usize;
641 for seg in 0..self.deltnseg {
642 band += self.deltoffst[seg] as usize;
643 let delta = if self.deltba[seg] >= 4 {
644 (i32::from(self.deltba[seg]) - 3) << 7
646 (i32::from(self.deltba[seg]) - 4) << 7
648 if band + self.deltlen[seg] > MAX_BANDS { break; }
649 for _ in 0..self.deltlen[seg] {
656 fn calc_snr_offset(&mut self, csnroffst: u8) {
657 self.snroffset = (((i32::from(csnroffst) - 15) << 4) + i32::from(self.fsnroffst)) << 2;
659 fn compute_bap(&mut self, mask: &mut [i32; MAX_BANDS], floor: u16) {
660 let end = self.endmant;
661 let mut band = TS102366_BIN_TO_BAND[self.startmant] as usize;
662 let mut bin = self.startmant;
665 lastbin = ((TS102366_BAND_START[band] as usize) + (TS102366_BAND_SIZE[band] as usize)).min(end);
666 mask[band] = (mask[band] - self.snroffset - i32::from(floor)).max(0) & 0x1FE0;
667 mask[band] += i32::from(floor);
668 while bin < lastbin {
669 let addr = ((i32::from(self.psd[bin]) - mask[band]) >> 5).min(63).max(0) as usize;
670 self.bap[bin] = TS102366_BAPTAB[addr];
673 if lastbin == end { break; }
677 fn read_mant(&mut self, br: &mut BitReader, bap_buf: &mut [[i32; 2]; 3], bap_buf_fill: &mut [usize; 3]) -> DecoderResult<()> {
678 self.mant = [0; BLOCK_LEN];
679 for bin in self.startmant..self.endmant {
680 self.mant[bin] = match self.bap[bin] {
688 1 => { read_bap!(br, TS102366_QUANT3_MAP, 5, 0, bap_buf, bap_buf_fill) },
689 2 => { read_bap!(br, TS102366_QUANT5_MAP, 7, 1, bap_buf, bap_buf_fill) },
690 3 => { read_bap!(br, TS102366_QUANT7_MAP, 3) },
691 4 => { read_bap!(br, TS102366_QUANT11_MAP, 7, 2, bap_buf, bap_buf_fill) },
692 5 => { read_bap!(br, TS102366_QUANT15_MAP, 4) },
694 validate!(self.bap[bin] < 15);
695 let nbits = TS102366_BAP_BITS[(self.bap[bin] as usize) - 6];
696 let val = br.read(nbits)? as i16;
697 i32::from(val << (16 - nbits)) << 9
700 self.mant[bin] >>= self.exps[bin];
705 fn synth(&mut self, imdct512: &mut IMDCTContext, imdct256: &mut IMDCTContext, tmp: &mut IMDCTWorkspace, delay: &mut [f32; BLOCK_LEN], dst: &mut [f32]) {
707 imdct512.do_imdct(&self.mant, tmp);
709 imdct256.do_imdct_ileave(&self.mant, tmp);
711 overlap(delay, &tmp.out, dst);
715 fn logadd(acc: i32, add: i32) -> i32 {
717 let addr = (c.abs() >> 1).min(255);
719 acc + i32::from(TS102366_LATAB[addr as usize])
721 add + i32::from(TS102366_LATAB[addr as usize])
725 fn calc_lowcomp(a: i32, b0: i32, b1: i32, band: usize) -> i32 {
727 if (b0 + 256) == b1 {
734 } else if band < 20 {
735 if (b0 + 256) == b1 {
747 fn overlap(delay: &mut [f32; BLOCK_LEN], src: &[f32; BLOCK_LEN * 2], out: &mut [f32]) {
750 for ((d, s), o) in dly.iter().zip(src.iter()).zip(out.iter_mut()) {
751 *o = (*d + *s) * 2.0;
754 delay.copy_from_slice(&src[BLOCK_LEN..]);
769 cplbndstrc: [bool; MAX_CPLBANDS],
771 phsflg: [bool; MAX_CPLBANDS],
775 chdata: [ChannelData; MAX_CHANNELS + 2],
791 bap_buf: [[i32; 2]; 3],
792 bap_buf_fill: [usize; 3],
798 chdata: [ChannelData::new(); MAX_CHANNELS + 2],
810 cplbndstrc: [false; MAX_CPLBANDS],
812 phsflg: [false; MAX_CPLBANDS],
814 rematflg: [false; 4],
830 bap_buf: [[0; 2]; 3],
831 bap_buf_fill: [0; 3],
834 fn read(&mut self, br: &mut BitReader, bsi: &BSI, fscod: usize, blk_no: usize) -> DecoderResult<bool> {
835 let channels = bsi.acmod.get_num_channels();
836 let is_stereo = bsi.acmod == ACMode::Stereo;
838 for ch in 0..channels {
839 self.chdata[ch].blksw = br.read_bool()?;
841 // dynamic range information
842 for ch in 0..channels {
843 self.chdata[ch].dithflag = br.read_bool()?;
845 self.dynrng = br.read_optional8()?;
846 if bsi.acmod == ACMode::DualMono {
847 self.dynrng2 = br.read_optional8()?;
849 // coupling strategy information
850 self.cplstre = br.read_bool()?;
851 validate!((blk_no != 0) || self.cplstre);
853 self.cplinu = br.read_bool()?;
855 for ch in 0..channels {
856 self.chdata[ch].chincpl = br.read_bool()?;
859 self.phsflginu = br.read_bool()?;
861 self.cplbegf = br.read(4)? as usize;
862 self.cplendf = (br.read(4)? as usize) + 3;
863 validate!(self.cplendf >= self.cplbegf);
864 self.ncplsubnd = self.cplendf - self.cplbegf;
865 self.ncplbnd = self.ncplsubnd;
866 self.chdata[CPL_CHANNEL].startmant = self.cplbegf * 12 + 37;
867 self.chdata[CPL_CHANNEL].endmant = self.cplendf * 12 + 37;
868 for bnd in 1..self.ncplsubnd {
869 self.cplbndstrc[bnd] = br.read_bool()?;
870 if self.cplbndstrc[bnd] {
876 // coupling coordinates
878 for c in 0..channels {
879 let ch = &mut self.chdata[c];
881 ch.cplcoe = br.read_bool()?;
883 ch.mstrcplco = br.read(2)? as u8;
884 for bnd in 0..self.ncplbnd {
885 ch.cplcoexp [bnd] = br.read(4)? as u8;
886 ch.cplcomant[bnd] = br.read(4)? as u8;
891 if is_stereo && self.phsflginu && (self.chdata[0].cplcoe || self.chdata[1].cplcoe) {
892 for bnd in 0..self.ncplbnd {
893 self.phsflg[bnd] = br.read_bool()?;
897 for ch in 0..channels {
898 self.chdata[ch].chincpl = false;
901 // stereo rematrixing
903 self.rematstr = br.read_bool()?;
905 if self.cplbegf > 2 || !self.cplinu {
907 self.rematflg[rbnd] = br.read_bool()?;
910 if self.cplbegf > 0 && self.cplbegf <= 2 && self.cplinu {
912 self.rematflg[rbnd] = br.read_bool()?;
915 if self.cplbegf == 0 && self.cplinu {
917 self.rematflg[rbnd] = br.read_bool()?;
924 self.chdata[CPL_CHANNEL].read_strategy(br, blk_no)?;
926 for ch in 0..channels {
927 self.chdata[ch].read_strategy(br, blk_no)?;
930 self.chdata[LFE_CHANNEL].expstr = br.read(1)? as u8;
931 validate!(blk_no != 0 || self.chdata[LFE_CHANNEL].expstr != STRATEGY_REUSE);
932 self.chdata[LFE_CHANNEL].groups = 2;
933 self.chdata[LFE_CHANNEL].startmant = 0;
934 self.chdata[LFE_CHANNEL].endmant = 7;
936 let cpl_startmant = self.chdata[CPL_CHANNEL].startmant;
937 for c in 0..channels {
938 let ch = &mut self.chdata[c];
939 if ch.expstr != STRATEGY_REUSE && !ch.chincpl {
940 ch.chbwcod = br.read(6)? as u8;
944 ch.endmant = ((ch.chbwcod as usize) + 12) * 3 + 37;
947 ch.endmant = cpl_startmant;
950 // set number of mantissas
952 self.chdata[CPL_CHANNEL].read_exps(br, true, false)?;
954 for ch in 0..channels {
955 self.chdata[ch].read_exps(br, false, false)?;
958 self.chdata[LFE_CHANNEL].read_exps(br, false, true)?;
960 // bit allocation parameters
961 self.baie = br.read_bool()?;
963 self.sdcycod = br.read(2)? as usize;
964 self.fdcycod = br.read(2)? as usize;
965 self.sgaincod = br.read(2)? as usize;
966 self.dbpbcod = br.read(2)? as usize;
967 self.floorcod = br.read(3)? as usize;
969 self.snroffste = br.read_bool()?;
971 self.csnroffst = br.read(6)? as u8;
973 self.chdata[CPL_CHANNEL].read_snr(br)?;
975 for ch in 0..channels {
976 self.chdata[ch].read_snr(br)?;
979 self.chdata[LFE_CHANNEL].read_snr(br)?;
983 self.cplleake = br.read_bool()?;
985 self.cplfleak = br.read(3)? as u8;
986 self.cplsleak = br.read(3)? as u8;
989 // delta bit allocation information
990 self.deltbaie = br.read_bool()?;
993 self.chdata[CPL_CHANNEL].deltbae = br.read(2)? as u8;
994 validate!(blk_no != 0 || self.chdata[CPL_CHANNEL].deltbae != 0);
995 validate!(self.chdata[CPL_CHANNEL].deltbae != 3);
997 for ch in 0..channels {
998 self.chdata[ch].deltbae = br.read(2)? as u8;
999 validate!(blk_no != 0 || self.chdata[ch].deltbae != 0);
1000 validate!(self.chdata[ch].deltbae != 3);
1003 self.chdata[CPL_CHANNEL].read_deltbai(br)?;
1005 for ch in 0..channels {
1006 self.chdata[ch].read_deltbai(br)?;
1010 if br.read_bool()? {
1011 let skipl = br.read(9)?;
1012 br.skip(skipl * 8)?;
1015 let all_zero = self.calc_bitalloc(bsi, channels, fscod);
1016 if all_zero { return Ok(true); }
1018 // quantised mantissa values
1019 let mut got_cplchan = false;
1020 for i in 0..self.bap_buf_fill.len() { self.bap_buf_fill[i] = 0; }
1021 for c in 0..channels {
1023 let ch = &mut self.chdata[c];
1024 ch.read_mant(br, &mut self.bap_buf, &mut self.bap_buf_fill)?;
1026 if self.cplinu && self.chdata[c].chincpl && !got_cplchan {
1027 let cplch = &mut self.chdata[CPL_CHANNEL];
1028 cplch.read_mant(br, &mut self.bap_buf, &mut self.bap_buf_fill)?;
1033 let lfech = &mut self.chdata[LFE_CHANNEL];
1034 lfech.read_mant(br, &mut self.bap_buf, &mut self.bap_buf_fill)?;
1038 fn calc_bitalloc(&mut self, bsi: &BSI, channels: usize, fscod: usize) -> bool {
1039 let sdecay1 = TS102366_SLOW_DECAY[self.sdcycod];
1040 let fdecay1 = TS102366_FAST_DECAY[self.fdcycod];
1042 let sdecay = sdecay1 >> bsi.shift;
1043 let fdecay = fdecay1 >> bsi.shift;
1044 let sgain = TS102366_SLOW_GAIN[self.sgaincod];
1045 let dbknee = TS102366_DBP_TAB[self.dbpbcod];
1046 let floor = TS102366_FLOOR_TAB[self.floorcod];
1048 let mut all_zero = self.csnroffst == 0;
1049 if !all_zero && self.chdata[LFE_CHANNEL].fsnroffst == 0 {
1050 for ch in 0..channels {
1051 if self.chdata[ch].fsnroffst != 0 {
1057 if all_zero { return true; }
1059 let mut mask: [i32; MAX_BANDS] = [0; MAX_BANDS];
1062 self.chdata[CPL_CHANNEL].compute_bndpsd();
1063 self.chdata[CPL_CHANNEL].compute_mask(&mut mask, fscod, sgain, fdecay, sdecay, dbknee,
1064 (u16::from(self.cplfleak) << 8) + 768, (u16::from(self.cplsleak) << 8) + 768, bsi.shift);
1065 self.chdata[CPL_CHANNEL].apply_delta_info(&mut mask);
1066 self.chdata[CPL_CHANNEL].calc_snr_offset(self.csnroffst);
1067 self.chdata[CPL_CHANNEL].compute_bap(&mut mask, floor);
1069 for ch in 0..channels {
1070 self.chdata[ch].compute_bndpsd();
1071 self.chdata[ch].compute_mask(&mut mask, fscod, sgain, fdecay, sdecay, dbknee, 0, 0, bsi.shift);
1072 self.chdata[ch].apply_delta_info(&mut mask);
1073 self.chdata[ch].calc_snr_offset(self.csnroffst);
1074 self.chdata[ch].compute_bap(&mut mask, floor);
1077 self.chdata[LFE_CHANNEL].compute_bndpsd();
1078 self.chdata[LFE_CHANNEL].compute_mask(&mut mask, fscod, sgain, fdecay, sdecay, dbknee,
1080 self.chdata[LFE_CHANNEL].calc_snr_offset(self.csnroffst);
1081 self.chdata[LFE_CHANNEL].compute_bap(&mut mask, floor);
1086 fn couple_channels(&mut self, acmod: ACMode) {
1087 if !self.cplinu { return; }
1088 for ch in 0..acmod.get_num_channels() {
1089 if !self.chdata[ch].chincpl { continue; }
1091 for band in self.cplbegf..self.cplendf {
1092 let cband = band - self.cplbegf;
1093 let comant = self.chdata[ch].cplcomant[cband];
1094 let mut cotemp = i32::from(if self.chdata[ch].cplcoexp[cband] == 15 { comant << 1 } else { comant + 16 });
1095 if (acmod == ACMode::Stereo) && (ch == 1) && self.phsflginu && self.phsflg[pband] {
1098 if !self.cplbndstrc[cband] {
1101 let exp = self.chdata[ch].cplcoexp[cband] + 3 * self.chdata[ch].mstrcplco + 5 - 3;
1102 let start = band * 12 + 37;
1104 self.chdata[ch].mant[start + bin] = (self.chdata[CPL_CHANNEL].mant[start + bin] * cotemp) >> exp;
1110 fn rematrix(&mut self) {
1111 let maxbin = self.chdata[0].endmant.min(self.chdata[1].endmant);
1112 if self.rematflg[0] {
1113 let end = maxbin.min(25);
1114 for bin in 13..end {
1115 let s = self.chdata[0].mant[bin] + self.chdata[1].mant[bin];
1116 let d = self.chdata[0].mant[bin] - self.chdata[1].mant[bin];
1117 self.chdata[0].mant[bin] = d;
1118 self.chdata[1].mant[bin] = s;
1120 if maxbin <= 25 { return; }
1122 if self.rematflg[1] {
1123 let end = maxbin.min(37);
1124 for bin in 25..end {
1125 let s = self.chdata[0].mant[bin] + self.chdata[1].mant[bin];
1126 let d = self.chdata[0].mant[bin] - self.chdata[1].mant[bin];
1127 self.chdata[0].mant[bin] = d;
1128 self.chdata[1].mant[bin] = s;
1130 if maxbin <= 37 { return; }
1132 if self.rematflg[2] {
1133 let end = maxbin.min(61);
1134 for bin in 37..end {
1135 let s = self.chdata[0].mant[bin] + self.chdata[1].mant[bin];
1136 let d = self.chdata[0].mant[bin] - self.chdata[1].mant[bin];
1137 self.chdata[0].mant[bin] = d;
1138 self.chdata[1].mant[bin] = s;
1140 if maxbin <= 61 { return; }
1142 if self.rematflg[3] {
1144 for bin in 61..end {
1145 let s = self.chdata[0].mant[bin] + self.chdata[1].mant[bin];
1146 let d = self.chdata[0].mant[bin] - self.chdata[1].mant[bin];
1147 self.chdata[0].mant[bin] = d;
1148 self.chdata[1].mant[bin] = s;
1152 fn synth_audio_block(&mut self, imdct512: &mut IMDCTContext, imdct256: &mut IMDCTContext, tmp: &mut IMDCTWorkspace, channel: usize, delay: &mut [f32; BLOCK_LEN], dst: &mut [f32]) {
1153 self.chdata[channel].synth(imdct512, imdct256, tmp, delay, dst);
1157 impl NADecoder for AudioDecoder {
1158 fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
1159 if let NACodecTypeInfo::Audio(_) = info.get_properties() {
1160 self.info = info.clone();
1163 Err(DecoderError::InvalidData)
1166 fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
1167 let info = pkt.get_stream().get_info();
1168 validate!(info.get_properties().is_audio());
1169 let pktbuf = pkt.get_buffer();
1170 validate!(pktbuf.len() > 5);
1173 if (pktbuf[0] == MAGIC_BYTE0) && (pktbuf[1] == MAGIC_BYTE1) {
1174 br = BitReader::new(pktbuf.as_slice(), BitReaderMode::BE);
1175 } else if (pktbuf[0] == MAGIC_BYTE1) && (pktbuf[1] == MAGIC_BYTE0) {
1176 br = BitReader::new(pktbuf.as_slice(), BitReaderMode::LE16MSB);
1178 return Err(DecoderError::InvalidData);
1181 let sinfo = Syncinfo::read(&mut br)?;
1182 validate!(sinfo.is_valid());
1184 let bsi = BSI::read(&mut br)?;
1186 let len = br.read(6)?;
1187 br.skip((len + 1) * 8)?;
1190 let duration = BLOCK_LEN * NBLOCKS;
1192 let core_channels = bsi.acmod.get_num_channels();
1193 let channels = core_channels + if bsi.lfeon { 1 } else { 0 };
1195 let ainfo = NAAudioInfo::new(sinfo.samplerate >> bsi.shift, channels as u8,
1196 SND_F32P_FORMAT, BLOCK_LEN);
1198 let abuf = alloc_audio_buffer(ainfo, duration, bsi.acmod.get_channel_map(bsi.lfeon))?;
1199 let mut adata = abuf.get_abuf_f32().unwrap();
1200 let output = adata.get_data_mut().unwrap();
1202 self.ablk = AudioBlock::new();
1203 for blk in 0..NBLOCKS {
1204 let all_zero = self.ablk.read(&mut br, &bsi, sinfo.fscod as usize, blk)?;
1205 let off = blk * BLOCK_LEN;
1206 self.ablk.couple_channels(bsi.acmod);
1207 if bsi.acmod == ACMode::Stereo {
1208 self.ablk.rematrix();
1210 for ch in 0..core_channels {
1211 let dpos = abuf.get_offset(ch) + off;
1212 let dst = &mut output[dpos..][..BLOCK_LEN];
1214 self.ablk.synth_audio_block(&mut self.imdct512, &mut self.imdct256, &mut self.tmp, ch, &mut self.delay[ch], dst);
1216 self.delay[ch] = [0.0; BLOCK_LEN];
1217 for el in dst.iter_mut().take(BLOCK_LEN) { *el = 0.0; }
1221 let dpos = abuf.get_offset(core_channels) + off;
1222 let dst = &mut output[dpos..][..BLOCK_LEN];
1224 self.ablk.synth_audio_block(&mut self.imdct512, &mut self.imdct256, &mut self.tmp, LFE_CHANNEL, &mut self.delay[LFE_CHANNEL], dst);
1226 self.delay[LFE_CHANNEL] = [0.0; BLOCK_LEN];
1227 for el in dst.iter_mut().take(BLOCK_LEN) { *el = 0.0; }
1232 //todo do errorcheck
1234 let mut frm = NAFrame::new_from_pkt(pkt, self.info.replace_info(NACodecTypeInfo::Audio(ainfo)), abuf);
1235 frm.set_keyframe(true);
1238 fn flush(&mut self) {
1239 self.delay = [[0.0; BLOCK_LEN]; MAX_CHANNELS + 1];
1243 pub fn get_decoder() -> Box<dyn NADecoder + Send> {
1244 Box::new(AudioDecoder::new())
1249 use nihav_core::codecs::RegisteredDecoders;
1250 use nihav_core::demuxers::RegisteredDemuxers;
1251 use nihav_codec_support::test::dec_video::test_decode_audio;
1252 use crate::generic_register_all_codecs;
1253 use nihav_realmedia::realmedia_register_all_demuxers;
1255 fn test_ts102366() {
1256 let mut dmx_reg = RegisteredDemuxers::new();
1257 realmedia_register_all_demuxers(&mut dmx_reg);
1258 let mut dec_reg = RegisteredDecoders::new();
1259 generic_register_all_codecs(&mut dec_reg);
1261 let file = "assets/RV/sp_sample1.rm";
1262 test_decode_audio("realmedia", file, Some(12000), None/*Some("ac3")*/, &dmx_reg, &dec_reg);
1266 const TS102366_SLOW_DECAY: [u8; 4] = [ 0x0F, 0x11, 0x13, 0x15 ];
1267 const TS102366_FAST_DECAY: [u8; 4] = [ 0x3F, 0x53, 0x67, 0x7B ];
1268 const TS102366_SLOW_GAIN: [u16; 4] = [ 0x540, 0x4D8, 0x478, 0x410 ];
1269 const TS102366_FAST_GAIN: [u16; 8] = [ 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400 ];
1270 const TS102366_DBP_TAB: [u16; 4] = [ 0x000, 0x700, 0x900, 0xB00 ];
1271 const TS102366_FLOOR_TAB: [u16; 8] = [ 0x02F0, 0x02B0, 0x0270, 0x0230, 0x01F0, 0x0170, 0x00F0, 0xF800 ];
1273 const TS102366_BIN_TO_BAND: [u8; 256] = [
1274 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
1275 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1276 20, 21, 22, 23, 24, 25, 26, 27, 28, 28,
1277 28, 29, 29, 29, 30, 30, 30, 31, 31, 31,
1278 32, 32, 32, 33, 33, 33, 34, 34, 34, 35,
1279 35, 35, 35, 35, 35, 36, 36, 36, 36, 36,
1280 36, 37, 37, 37, 37, 37, 37, 38, 38, 38,
1281 38, 38, 38, 39, 39, 39, 39, 39, 39, 40,
1282 40, 40, 40, 40, 40, 41, 41, 41, 41, 41,
1283 41, 41, 41, 41, 41, 41, 41, 42, 42, 42,
1284 42, 42, 42, 42, 42, 42, 42, 42, 42, 43,
1285 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
1286 43, 44, 44, 44, 44, 44, 44, 44, 44, 44,
1287 44, 44, 44, 45, 45, 45, 45, 45, 45, 45,
1288 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
1289 45, 45, 45, 45, 45, 45, 45, 46, 46, 46,
1290 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
1291 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
1292 46, 47, 47, 47, 47, 47, 47, 47, 47, 47,
1293 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
1294 47, 47, 47, 47, 47, 48, 48, 48, 48, 48,
1295 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
1296 48, 48, 48, 48, 48, 48, 48, 48, 48, 49,
1297 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
1298 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
1301 const TS102366_BAND_SIZE: [u8; MAX_BANDS] = [
1302 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1303 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1304 1, 1, 1, 1, 1, 1, 1, 1, 3, 3,
1305 3, 3, 3, 3, 3, 6, 6, 6, 6, 6,
1306 6, 12, 12, 12, 12, 24, 24, 24, 24, 24
1308 const TS102366_BAND_START: [u8; MAX_BANDS] = [
1309 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
1310 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1311 20, 21, 22, 23, 24, 25, 26, 27, 28, 31,
1312 34, 37, 40, 43, 46, 49, 55, 61, 67, 73,
1313 79, 85, 97, 109, 121, 133, 157, 181, 205, 229
1316 const TS102366_LATAB: [u16; 256] = [
1317 0x0040, 0x003f, 0x003e, 0x003d, 0x003c, 0x003b, 0x003a, 0x0039,
1318 0x0038, 0x0037, 0x0036, 0x0035, 0x0034, 0x0034, 0x0033, 0x0032,
1319 0x0031, 0x0030, 0x002f, 0x002f, 0x002e, 0x002d, 0x002c, 0x002c,
1320 0x002b, 0x002a, 0x0029, 0x0029, 0x0028, 0x0027, 0x0026, 0x0026,
1321 0x0025, 0x0024, 0x0024, 0x0023, 0x0023, 0x0022, 0x0021, 0x0021,
1322 0x0020, 0x0020, 0x001f, 0x001e, 0x001e, 0x001d, 0x001d, 0x001c,
1323 0x001c, 0x001b, 0x001b, 0x001a, 0x001a, 0x0019, 0x0019, 0x0018,
1324 0x0018, 0x0017, 0x0017, 0x0016, 0x0016, 0x0015, 0x0015, 0x0015,
1325 0x0014, 0x0014, 0x0013, 0x0013, 0x0013, 0x0012, 0x0012, 0x0012,
1326 0x0011, 0x0011, 0x0011, 0x0010, 0x0010, 0x0010, 0x000f, 0x000f,
1327 0x000f, 0x000e, 0x000e, 0x000e, 0x000d, 0x000d, 0x000d, 0x000d,
1328 0x000c, 0x000c, 0x000c, 0x000c, 0x000b, 0x000b, 0x000b, 0x000b,
1329 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x0009, 0x0009, 0x0009,
1330 0x0009, 0x0009, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
1331 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0006, 0x0006,
1332 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0005, 0x0005,
1333 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0004, 0x0004,
1334 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
1335 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003,
1336 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0002,
1337 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
1338 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
1339 0x0002, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
1340 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
1341 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
1342 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
1343 0x0001, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1344 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1345 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1346 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1347 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1348 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
1350 const TS102366_HTH: [[u16; MAX_BANDS]; 3] = [
1352 0x04D0, 0x04D0, 0x0440, 0x0400, 0x03E0, 0x03C0, 0x03B0, 0x03B0, 0x03A0, 0x03A0,
1353 0x03A0, 0x03A0, 0x03A0, 0x0390, 0x0390, 0x0390, 0x0380, 0x0380, 0x0370, 0x0370,
1354 0x0360, 0x0360, 0x0350, 0x0350, 0x0340, 0x0340, 0x0330, 0x0320, 0x0310, 0x0300,
1355 0x02F0, 0x02F0, 0x02F0, 0x02F0, 0x0300, 0x0310, 0x0340, 0x0390, 0x03E0, 0x0420,
1356 0x0460, 0x0490, 0x04A0, 0x0460, 0x0440, 0x0440, 0x0520, 0x0800, 0x0840, 0x0840,
1358 0x04F0, 0x04F0, 0x0460, 0x0410, 0x03E0, 0x03D0, 0x03C0, 0x03B0, 0x03B0, 0x03A0,
1359 0x03A0, 0x03A0, 0x03A0, 0x03A0, 0x0390, 0x0390, 0x0390, 0x0380, 0x0380, 0x0380,
1360 0x0370, 0x0370, 0x0360, 0x0360, 0x0350, 0x0350, 0x0340, 0x0340, 0x0320, 0x0310,
1361 0x0300, 0x02F0, 0x02F0, 0x02F0, 0x02F0, 0x0300, 0x0320, 0x0350, 0x0390, 0x03E0,
1362 0x0420, 0x0450, 0x04A0, 0x0490, 0x0460, 0x0440, 0x0480, 0x0630, 0x0840, 0x0840,
1364 0x0580, 0x0580, 0x04B0, 0x0450, 0x0420, 0x03F0, 0x03E0, 0x03D0, 0x03C0, 0x03B0,
1365 0x03B0, 0x03B0, 0x03A0, 0x03A0, 0x03A0, 0x03A0, 0x03A0, 0x03A0, 0x03A0, 0x03A0,
1366 0x0390, 0x0390, 0x0390, 0x0390, 0x0380, 0x0380, 0x0380, 0x0370, 0x0360, 0x0350,
1367 0x0340, 0x0330, 0x0320, 0x0310, 0x0300, 0x02F0, 0x02F0, 0x02F0, 0x0300, 0x0310,
1368 0x0330, 0x0350, 0x03C0, 0x0410, 0x0470, 0x04A0, 0x0460, 0x0440, 0x0450, 0x04E0,
1371 const TS102366_BAPTAB: [u8; 64] = [
1372 0, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6,
1373 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10,
1374 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14,
1375 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15
1378 const TS102366_QUANT3_MAP: [[i32; 3]; 27] = [
1379 [ -0x0AAAAAA, -0x0AAAAAA, -0x0AAAAAA ],
1380 [ -0x0AAAAAA, -0x0AAAAAA, 0x00000000 ],
1381 [ -0x0AAAAAA, -0x0AAAAAA, 0x00AAAAAA ],
1382 [ -0x0AAAAAA, 0x00000000, -0x0AAAAAA ],
1383 [ -0x0AAAAAA, 0x00000000, 0x00000000 ],
1384 [ -0x0AAAAAA, 0x00000000, 0x00AAAAAA ],
1385 [ -0x0AAAAAA, 0x00AAAAAA, -0x0AAAAAA ],
1386 [ -0x0AAAAAA, 0x00AAAAAA, 0x00000000 ],
1387 [ -0x0AAAAAA, 0x00AAAAAA, 0x00AAAAAA ],
1388 [ 0x00000000, -0x0AAAAAA, -0x0AAAAAA ],
1389 [ 0x00000000, -0x0AAAAAA, 0x00000000 ],
1390 [ 0x00000000, -0x0AAAAAA, 0x00AAAAAA ],
1391 [ 0x00000000, 0x00000000, -0x0AAAAAA ],
1392 [ 0x00000000, 0x00000000, 0x00000000 ],
1393 [ 0x00000000, 0x00000000, 0x00AAAAAA ],
1394 [ 0x00000000, 0x00AAAAAA, -0x0AAAAAA ],
1395 [ 0x00000000, 0x00AAAAAA, 0x00000000 ],
1396 [ 0x00000000, 0x00AAAAAA, 0x00AAAAAA ],
1397 [ 0x00AAAAAA, -0x0AAAAAA, -0x0AAAAAA ],
1398 [ 0x00AAAAAA, -0x0AAAAAA, 0x00000000 ],
1399 [ 0x00AAAAAA, -0x0AAAAAA, 0x00AAAAAA ],
1400 [ 0x00AAAAAA, 0x00000000, -0x0AAAAAA ],
1401 [ 0x00AAAAAA, 0x00000000, 0x00000000 ],
1402 [ 0x00AAAAAA, 0x00000000, 0x00AAAAAA ],
1403 [ 0x00AAAAAA, 0x00AAAAAA, -0x0AAAAAA ],
1404 [ 0x00AAAAAA, 0x00AAAAAA, 0x00000000 ],
1405 [ 0x00AAAAAA, 0x00AAAAAA, 0x00AAAAAA ]
1407 const TS102366_QUANT5_MAP: [[i32; 3]; 125] = [
1408 [ -0x0CCCCCC, -0x0CCCCCC, -0x0CCCCCC ], [ -0x0CCCCCC, -0x0CCCCCC, -0x0666666 ], [ -0x0CCCCCC, -0x0CCCCCC, 0x00000000 ],
1409 [ -0x0CCCCCC, -0x0CCCCCC, 0x00666666 ], [ -0x0CCCCCC, -0x0CCCCCC, 0x00CCCCCC ],
1410 [ -0x0CCCCCC, -0x0666666, -0x0CCCCCC ], [ -0x0CCCCCC, -0x0666666, -0x0666666 ], [ -0x0CCCCCC, -0x0666666, 0x00000000 ],
1411 [ -0x0CCCCCC, -0x0666666, 0x00666666 ], [ -0x0CCCCCC, -0x0666666, 0x00CCCCCC ],
1412 [ -0x0CCCCCC, 0x00000000, -0x0CCCCCC ], [ -0x0CCCCCC, 0x00000000, -0x0666666 ], [ -0x0CCCCCC, 0x00000000, 0x00000000 ],
1413 [ -0x0CCCCCC, 0x00000000, 0x00666666 ], [ -0x0CCCCCC, 0x00000000, 0x00CCCCCC ],
1414 [ -0x0CCCCCC, 0x00666666, -0x0CCCCCC ], [ -0x0CCCCCC, 0x00666666, -0x0666666 ], [ -0x0CCCCCC, 0x00666666, 0x00000000 ],
1415 [ -0x0CCCCCC, 0x00666666, 0x00666666 ], [ -0x0CCCCCC, 0x00666666, 0x00CCCCCC ],
1416 [ -0x0CCCCCC, 0x00CCCCCC, -0x0CCCCCC ], [ -0x0CCCCCC, 0x00CCCCCC, -0x0666666 ], [ -0x0CCCCCC, 0x00CCCCCC, 0x00000000 ],
1417 [ -0x0CCCCCC, 0x00CCCCCC, 0x00666666 ], [ -0x0CCCCCC, 0x00CCCCCC, 0x00CCCCCC ],
1418 [ -0x0666666, -0x0CCCCCC, -0x0CCCCCC ], [ -0x0666666, -0x0CCCCCC, -0x0666666 ], [ -0x0666666, -0x0CCCCCC, 0x00000000 ],
1419 [ -0x0666666, -0x0CCCCCC, 0x00666666 ], [ -0x0666666, -0x0CCCCCC, 0x00CCCCCC ],
1420 [ -0x0666666, -0x0666666, -0x0CCCCCC ], [ -0x0666666, -0x0666666, -0x0666666 ], [ -0x0666666, -0x0666666, 0x00000000 ],
1421 [ -0x0666666, -0x0666666, 0x00666666 ], [ -0x0666666, -0x0666666, 0x00CCCCCC ],
1422 [ -0x0666666, 0x00000000, -0x0CCCCCC ], [ -0x0666666, 0x00000000, -0x0666666 ], [ -0x0666666, 0x00000000, 0x00000000 ],
1423 [ -0x0666666, 0x00000000, 0x00666666 ], [ -0x0666666, 0x00000000, 0x00CCCCCC ],
1424 [ -0x0666666, 0x00666666, -0x0CCCCCC ], [ -0x0666666, 0x00666666, -0x0666666 ], [ -0x0666666, 0x00666666, 0x00000000 ],
1425 [ -0x0666666, 0x00666666, 0x00666666 ], [ -0x0666666, 0x00666666, 0x00CCCCCC ],
1426 [ -0x0666666, 0x00CCCCCC, -0x0CCCCCC ], [ -0x0666666, 0x00CCCCCC, -0x0666666 ], [ -0x0666666, 0x00CCCCCC, 0x00000000 ],
1427 [ -0x0666666, 0x00CCCCCC, 0x00666666 ], [ -0x0666666, 0x00CCCCCC, 0x00CCCCCC ],
1428 [ 0x00000000, -0x0CCCCCC, -0x0CCCCCC ], [ 0x00000000, -0x0CCCCCC, -0x0666666 ], [ 0x00000000, -0x0CCCCCC, 0x00000000 ],
1429 [ 0x00000000, -0x0CCCCCC, 0x00666666 ], [ 0x00000000, -0x0CCCCCC, 0x00CCCCCC ],
1430 [ 0x00000000, -0x0666666, -0x0CCCCCC ], [ 0x00000000, -0x0666666, -0x0666666 ], [ 0x00000000, -0x0666666, 0x00000000 ],
1431 [ 0x00000000, -0x0666666, 0x00666666 ], [ 0x00000000, -0x0666666, 0x00CCCCCC ],
1432 [ 0x00000000, 0x00000000, -0x0CCCCCC ], [ 0x00000000, 0x00000000, -0x0666666 ], [ 0x00000000, 0x00000000, 0x00000000 ],
1433 [ 0x00000000, 0x00000000, 0x00666666 ], [ 0x00000000, 0x00000000, 0x00CCCCCC ],
1434 [ 0x00000000, 0x00666666, -0x0CCCCCC ], [ 0x00000000, 0x00666666, -0x0666666 ], [ 0x00000000, 0x00666666, 0x00000000 ],
1435 [ 0x00000000, 0x00666666, 0x00666666 ], [ 0x00000000, 0x00666666, 0x00CCCCCC ],
1436 [ 0x00000000, 0x00CCCCCC, -0x0CCCCCC ], [ 0x00000000, 0x00CCCCCC, -0x0666666 ], [ 0x00000000, 0x00CCCCCC, 0x00000000 ],
1437 [ 0x00000000, 0x00CCCCCC, 0x00666666 ], [ 0x00000000, 0x00CCCCCC, 0x00CCCCCC ],
1438 [ 0x00666666, -0x0CCCCCC, -0x0CCCCCC ], [ 0x00666666, -0x0CCCCCC, -0x0666666 ], [ 0x00666666, -0x0CCCCCC, 0x00000000 ],
1439 [ 0x00666666, -0x0CCCCCC, 0x00666666 ], [ 0x00666666, -0x0CCCCCC, 0x00CCCCCC ],
1440 [ 0x00666666, -0x0666666, -0x0CCCCCC ], [ 0x00666666, -0x0666666, -0x0666666 ], [ 0x00666666, -0x0666666, 0x00000000 ],
1441 [ 0x00666666, -0x0666666, 0x00666666 ], [ 0x00666666, -0x0666666, 0x00CCCCCC ],
1442 [ 0x00666666, 0x00000000, -0x0CCCCCC ], [ 0x00666666, 0x00000000, -0x0666666 ], [ 0x00666666, 0x00000000, 0x00000000 ],
1443 [ 0x00666666, 0x00000000, 0x00666666 ], [ 0x00666666, 0x00000000, 0x00CCCCCC ],
1444 [ 0x00666666, 0x00666666, -0x0CCCCCC ], [ 0x00666666, 0x00666666, -0x0666666 ], [ 0x00666666, 0x00666666, 0x00000000 ],
1445 [ 0x00666666, 0x00666666, 0x00666666 ], [ 0x00666666, 0x00666666, 0x00CCCCCC ],
1446 [ 0x00666666, 0x00CCCCCC, -0x0CCCCCC ], [ 0x00666666, 0x00CCCCCC, -0x0666666 ], [ 0x00666666, 0x00CCCCCC, 0x00000000 ],
1447 [ 0x00666666, 0x00CCCCCC, 0x00666666 ], [ 0x00666666, 0x00CCCCCC, 0x00CCCCCC ],
1448 [ 0x00CCCCCC, -0x0CCCCCC, -0x0CCCCCC ], [ 0x00CCCCCC, -0x0CCCCCC, -0x0666666 ], [ 0x00CCCCCC, -0x0CCCCCC, 0x00000000 ],
1449 [ 0x00CCCCCC, -0x0CCCCCC, 0x00666666 ], [ 0x00CCCCCC, -0x0CCCCCC, 0x00CCCCCC ],
1450 [ 0x00CCCCCC, -0x0666666, -0x0CCCCCC ], [ 0x00CCCCCC, -0x0666666, -0x0666666 ], [ 0x00CCCCCC, -0x0666666, 0x00000000 ],
1451 [ 0x00CCCCCC, -0x0666666, 0x00666666 ], [ 0x00CCCCCC, -0x0666666, 0x00CCCCCC ],
1452 [ 0x00CCCCCC, 0x00000000, -0x0CCCCCC ], [ 0x00CCCCCC, 0x00000000, -0x0666666 ], [ 0x00CCCCCC, 0x00000000, 0x00000000 ],
1453 [ 0x00CCCCCC, 0x00000000, 0x00666666 ], [ 0x00CCCCCC, 0x00000000, 0x00CCCCCC ],
1454 [ 0x00CCCCCC, 0x00666666, -0x0CCCCCC ], [ 0x00CCCCCC, 0x00666666, -0x0666666 ], [ 0x00CCCCCC, 0x00666666, 0x00000000 ],
1455 [ 0x00CCCCCC, 0x00666666, 0x00666666 ], [ 0x00CCCCCC, 0x00666666, 0x00CCCCCC ],
1456 [ 0x00CCCCCC, 0x00CCCCCC, -0x0CCCCCC ], [ 0x00CCCCCC, 0x00CCCCCC, -0x0666666 ], [ 0x00CCCCCC, 0x00CCCCCC, 0x00000000 ],
1457 [ 0x00CCCCCC, 0x00CCCCCC, 0x00666666 ], [ 0x00CCCCCC, 0x00CCCCCC, 0x00CCCCCC ],
1459 const TS102366_QUANT7_MAP: [i32; 7] = [
1460 -0xDB6DB6, -0x924924, -0x492492, 0x000000, 0x492492, 0x924924, 0xDB6DB6
1462 const TS102366_QUANT11_MAP: [[i32; 2]; 121] = [
1463 [ -0x0E8BA2E, -0x0E8BA2E ], [ -0x0E8BA2E, -0x0BA2E8B ], [ -0x0E8BA2E, -0x08BA2E8 ],
1464 [ -0x0E8BA2E, -0x05D1745 ], [ -0x0E8BA2E, -0x02E8BA2 ], [ -0x0E8BA2E, 0x00000000 ],
1465 [ -0x0E8BA2E, 0x002E8BA2 ], [ -0x0E8BA2E, 0x005D1745 ], [ -0x0E8BA2E, 0x008BA2E8 ],
1466 [ -0x0E8BA2E, 0x00BA2E8B ], [ -0x0E8BA2E, 0x00E8BA2E ], [ -0x0BA2E8B, -0x0E8BA2E ],
1467 [ -0x0BA2E8B, -0x0BA2E8B ], [ -0x0BA2E8B, -0x08BA2E8 ], [ -0x0BA2E8B, -0x05D1745 ],
1468 [ -0x0BA2E8B, -0x02E8BA2 ], [ -0x0BA2E8B, 0x00000000 ], [ -0x0BA2E8B, 0x002E8BA2 ],
1469 [ -0x0BA2E8B, 0x005D1745 ], [ -0x0BA2E8B, 0x008BA2E8 ], [ -0x0BA2E8B, 0x00BA2E8B ],
1470 [ -0x0BA2E8B, 0x00E8BA2E ], [ -0x08BA2E8, -0x0E8BA2E ], [ -0x08BA2E8, -0x0BA2E8B ],
1471 [ -0x08BA2E8, -0x08BA2E8 ], [ -0x08BA2E8, -0x05D1745 ], [ -0x08BA2E8, -0x02E8BA2 ],
1472 [ -0x08BA2E8, 0x00000000 ], [ -0x08BA2E8, 0x002E8BA2 ], [ -0x08BA2E8, 0x005D1745 ],
1473 [ -0x08BA2E8, 0x008BA2E8 ], [ -0x08BA2E8, 0x00BA2E8B ], [ -0x08BA2E8, 0x00E8BA2E ],
1474 [ -0x05D1745, -0x0E8BA2E ], [ -0x05D1745, -0x0BA2E8B ], [ -0x05D1745, -0x08BA2E8 ],
1475 [ -0x05D1745, -0x05D1745 ], [ -0x05D1745, -0x02E8BA2 ], [ -0x05D1745, 0x00000000 ],
1476 [ -0x05D1745, 0x002E8BA2 ], [ -0x05D1745, 0x005D1745 ], [ -0x05D1745, 0x008BA2E8 ],
1477 [ -0x05D1745, 0x00BA2E8B ], [ -0x05D1745, 0x00E8BA2E ], [ -0x02E8BA2, -0x0E8BA2E ],
1478 [ -0x02E8BA2, -0x0BA2E8B ], [ -0x02E8BA2, -0x08BA2E8 ], [ -0x02E8BA2, -0x05D1745 ],
1479 [ -0x02E8BA2, -0x02E8BA2 ], [ -0x02E8BA2, 0x00000000 ], [ -0x02E8BA2, 0x002E8BA2 ],
1480 [ -0x02E8BA2, 0x005D1745 ], [ -0x02E8BA2, 0x008BA2E8 ], [ -0x02E8BA2, 0x00BA2E8B ],
1481 [ -0x02E8BA2, 0x00E8BA2E ], [ 0x00000000, -0x0E8BA2E ], [ 0x00000000, -0x0BA2E8B ],
1482 [ 0x00000000, -0x08BA2E8 ], [ 0x00000000, -0x05D1745 ], [ 0x00000000, -0x02E8BA2 ],
1483 [ 0x00000000, 0x00000000 ], [ 0x00000000, 0x002E8BA2 ], [ 0x00000000, 0x005D1745 ],
1484 [ 0x00000000, 0x008BA2E8 ], [ 0x00000000, 0x00BA2E8B ], [ 0x00000000, 0x00E8BA2E ],
1485 [ 0x002E8BA2, -0x0E8BA2E ], [ 0x002E8BA2, -0x0BA2E8B ], [ 0x002E8BA2, -0x08BA2E8 ],
1486 [ 0x002E8BA2, -0x05D1745 ], [ 0x002E8BA2, -0x02E8BA2 ], [ 0x002E8BA2, 0x00000000 ],
1487 [ 0x002E8BA2, 0x002E8BA2 ], [ 0x002E8BA2, 0x005D1745 ], [ 0x002E8BA2, 0x008BA2E8 ],
1488 [ 0x002E8BA2, 0x00BA2E8B ], [ 0x002E8BA2, 0x00E8BA2E ], [ 0x005D1745, -0x0E8BA2E ],
1489 [ 0x005D1745, -0x0BA2E8B ], [ 0x005D1745, -0x08BA2E8 ], [ 0x005D1745, -0x05D1745 ],
1490 [ 0x005D1745, -0x02E8BA2 ], [ 0x005D1745, 0x00000000 ], [ 0x005D1745, 0x002E8BA2 ],
1491 [ 0x005D1745, 0x005D1745 ], [ 0x005D1745, 0x008BA2E8 ], [ 0x005D1745, 0x00BA2E8B ],
1492 [ 0x005D1745, 0x00E8BA2E ], [ 0x008BA2E8, -0x0E8BA2E ], [ 0x008BA2E8, -0x0BA2E8B ],
1493 [ 0x008BA2E8, -0x08BA2E8 ], [ 0x008BA2E8, -0x05D1745 ], [ 0x008BA2E8, -0x02E8BA2 ],
1494 [ 0x008BA2E8, 0x00000000 ], [ 0x008BA2E8, 0x002E8BA2 ], [ 0x008BA2E8, 0x005D1745 ],
1495 [ 0x008BA2E8, 0x008BA2E8 ], [ 0x008BA2E8, 0x00BA2E8B ], [ 0x008BA2E8, 0x00E8BA2E ],
1496 [ 0x00BA2E8B, -0x0E8BA2E ], [ 0x00BA2E8B, -0x0BA2E8B ], [ 0x00BA2E8B, -0x08BA2E8 ],
1497 [ 0x00BA2E8B, -0x05D1745 ], [ 0x00BA2E8B, -0x02E8BA2 ], [ 0x00BA2E8B, 0x00000000 ],
1498 [ 0x00BA2E8B, 0x002E8BA2 ], [ 0x00BA2E8B, 0x005D1745 ], [ 0x00BA2E8B, 0x008BA2E8 ],
1499 [ 0x00BA2E8B, 0x00BA2E8B ], [ 0x00BA2E8B, 0x00E8BA2E ], [ 0x00E8BA2E, -0x0E8BA2E ],
1500 [ 0x00E8BA2E, -0x0BA2E8B ], [ 0x00E8BA2E, -0x08BA2E8 ], [ 0x00E8BA2E, -0x05D1745 ],
1501 [ 0x00E8BA2E, -0x02E8BA2 ], [ 0x00E8BA2E, 0x00000000 ], [ 0x00E8BA2E, 0x002E8BA2 ],
1502 [ 0x00E8BA2E, 0x005D1745 ], [ 0x00E8BA2E, 0x008BA2E8 ], [ 0x00E8BA2E, 0x00BA2E8B ],
1503 [ 0x00E8BA2E, 0x00E8BA2E ],
1505 const TS102366_QUANT15_MAP: [i32; 15] = [
1506 -0x0EEEEEE, -0x0CCCCCC, -0x0AAAAAA, -0x0888888, -0x0666666, -0x0444444, -0x0222222, 0x00000000,
1507 0x00222222, 0x00444444, 0x00666666, 0x00888888, 0x00AAAAAA, 0x00CCCCCC, 0x00EEEEEE,
1509 const TS102366_BAP_BITS: [u8; 10] = [ 5, 6, 7, 8, 9, 10, 11, 12, 14, 16 ];
1511 const TS102366_WINDOW: [f32; 256] = [
1512 0.00014, 0.00024, 0.00037, 0.00051, 0.00067, 0.00086, 0.00107, 0.00130,
1513 0.00157, 0.00187, 0.00220, 0.00256, 0.00297, 0.00341, 0.00390, 0.00443,
1514 0.00501, 0.00564, 0.00632, 0.00706, 0.00785, 0.00871, 0.00962, 0.01061,
1515 0.01166, 0.01279, 0.01399, 0.01526, 0.01662, 0.01806, 0.01959, 0.02121,
1516 0.02292, 0.02472, 0.02662, 0.02863, 0.03073, 0.03294, 0.03527, 0.03770,
1517 0.04025, 0.04292, 0.04571, 0.04862, 0.05165, 0.05481, 0.05810, 0.06153,
1518 0.06508, 0.06878, 0.07261, 0.07658, 0.08069, 0.08495, 0.08935, 0.09389,
1519 0.09859, 0.10343, 0.10842, 0.11356, 0.11885, 0.12429, 0.12988, 0.13563,
1520 0.14152, 0.14757, 0.15376, 0.16011, 0.16661, 0.17325, 0.18005, 0.18699,
1521 0.19407, 0.20130, 0.20867, 0.21618, 0.22382, 0.23161, 0.23952, 0.24757,
1522 0.25574, 0.26404, 0.27246, 0.28100, 0.28965, 0.29841, 0.30729, 0.31626,
1523 0.32533, 0.33450, 0.34376, 0.35311, 0.36253, 0.37204, 0.38161, 0.39126,
1524 0.40096, 0.41072, 0.42054, 0.43040, 0.44030, 0.45023, 0.46020, 0.47019,
1525 0.48020, 0.49022, 0.50025, 0.51028, 0.52031, 0.53033, 0.54033, 0.55031,
1526 0.56026, 0.57019, 0.58007, 0.58991, 0.59970, 0.60944, 0.61912, 0.62873,
1527 0.63827, 0.64774, 0.65713, 0.66643, 0.67564, 0.68476, 0.69377, 0.70269,
1528 0.71150, 0.72019, 0.72877, 0.73723, 0.74557, 0.75378, 0.76186, 0.76981,
1529 0.77762, 0.78530, 0.79283, 0.80022, 0.80747, 0.81457, 0.82151, 0.82831,
1530 0.83496, 0.84145, 0.84779, 0.85398, 0.86001, 0.86588, 0.87160, 0.87716,
1531 0.88257, 0.88782, 0.89291, 0.89785, 0.90264, 0.90728, 0.91176, 0.91610,
1532 0.92028, 0.92432, 0.92822, 0.93197, 0.93558, 0.93906, 0.94240, 0.94560,
1533 0.94867, 0.95162, 0.95444, 0.95713, 0.95971, 0.96217, 0.96451, 0.96674,
1534 0.96887, 0.97089, 0.97281, 0.97463, 0.97635, 0.97799, 0.97953, 0.98099,
1535 0.98236, 0.98366, 0.98488, 0.98602, 0.98710, 0.98811, 0.98905, 0.98994,
1536 0.99076, 0.99153, 0.99225, 0.99291, 0.99353, 0.99411, 0.99464, 0.99513,
1537 0.99558, 0.99600, 0.99639, 0.99674, 0.99706, 0.99736, 0.99763, 0.99788,
1538 0.99811, 0.99831, 0.99850, 0.99867, 0.99882, 0.99895, 0.99908, 0.99919,
1539 0.99929, 0.99938, 0.99946, 0.99953, 0.99959, 0.99965, 0.99969, 0.99974,
1540 0.99978, 0.99981, 0.99984, 0.99986, 0.99988, 0.99990, 0.99992, 0.99993,
1541 0.99994, 0.99995, 0.99996, 0.99997, 0.99998, 0.99998, 0.99998, 0.99999,
1542 0.99999, 0.99999, 0.99999, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000,
1543 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000,